diff options
author | 2023-06-22 01:06:50 -0700 | |
---|---|---|
committer | 2023-06-22 01:06:50 -0700 | |
commit | 4a13a53058eca1c3d96847277878a19192dd2a34 (patch) | |
tree | ae686eff3869384fb9b858df806c0398f565d772 /src | |
parent | 5fa13625a1ca0ea1a3a1c5bb86d0880dcfac349f (diff) | |
download | bun-4a13a53058eca1c3d96847277878a19192dd2a34.tar.gz bun-4a13a53058eca1c3d96847277878a19192dd2a34.tar.zst bun-4a13a53058eca1c3d96847277878a19192dd2a34.zip |
CommonJS bun build cannot use import.meta (#3378)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/js_printer.zig | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/js_printer.zig b/src/js_printer.zig index 913aaded3..bd771d7b8 100644 --- a/src/js_printer.zig +++ b/src/js_printer.zig @@ -845,7 +845,14 @@ fn NewPrinter( fn printBunJestImportStatement(p: *Printer, import: S.Import) void { if (comptime !is_bun_platform) unreachable; - printInternalBunImport(p, import, @TypeOf("globalThis.Bun.jest(import.meta.path)"), "globalThis.Bun.jest(import.meta.path)"); + switch (p.options.module_type) { + .cjs => { + printInternalBunImport(p, import, @TypeOf("globalThis.Bun.jest(__filename)"), "globalThis.Bun.jest(__filename)"); + }, + else => { + printInternalBunImport(p, import, @TypeOf("globalThis.Bun.jest(import.meta.path)"), "globalThis.Bun.jest(import.meta.path)"); + }, + } } fn printGlobalBunImportStatement(p: *Printer, import: S.Import) void { |