diff options
author | 2022-08-03 20:50:22 -0700 | |
---|---|---|
committer | 2022-08-03 20:52:17 -0700 | |
commit | 290fb7f7e721d0ed39a4e360e92f121cad6ca680 (patch) | |
tree | 2f4dc2690b8bed3f95b06f1398eb67d4c3f3ccdd /src | |
parent | aa0be51d40afe4d49d6474db9e270564511f2171 (diff) | |
download | bun-290fb7f7e721d0ed39a4e360e92f121cad6ca680.tar.gz bun-290fb7f7e721d0ed39a4e360e92f121cad6ca680.tar.zst bun-290fb7f7e721d0ed39a4e360e92f121cad6ca680.zip |
[Bun.Transpiler] Fix bug that would cause some bun-specific transforms to run
Diffstat (limited to 'src')
-rw-r--r-- | src/bundler.zig | 124 |
1 files changed, 84 insertions, 40 deletions
diff --git a/src/bundler.zig b/src/bundler.zig index aa2096b5a..4ad75ecfa 100644 --- a/src/bundler.zig +++ b/src/bundler.zig @@ -943,46 +943,90 @@ pub const Bundler = struct { &bundler.linker, enable_source_map, ), - .esm_ascii => try js_printer.printAst( - Writer, - writer, - ast, - js_ast.Symbol.Map.initList(symbols), - &result.source, - true, - js_printer.Options{ - .to_module_ref = Ref.RuntimeRef, - .externals = ast.externals, - .runtime_imports = ast.runtime_imports, - .require_ref = ast.require_ref, - .css_import_behavior = bundler.options.cssImportBehavior(), - .source_map_handler = source_map_context, - .rewrite_require_resolve = bundler.options.platform != .node, - }, - Linker, - &bundler.linker, - enable_source_map, - ), - .cjs_ascii => try js_printer.printCommonJS( - Writer, - writer, - ast, - js_ast.Symbol.Map.initList(symbols), - &result.source, - true, - js_printer.Options{ - .to_module_ref = Ref.RuntimeRef, - .externals = ast.externals, - .runtime_imports = ast.runtime_imports, - .require_ref = ast.require_ref, - .css_import_behavior = bundler.options.cssImportBehavior(), - .source_map_handler = source_map_context, - .rewrite_require_resolve = bundler.options.platform != .node, - }, - Linker, - &bundler.linker, - enable_source_map, - ), + .esm_ascii => if (bundler.options.platform.isBun()) + try js_printer.printAst( + Writer, + writer, + ast, + js_ast.Symbol.Map.initList(symbols), + &result.source, + true, + js_printer.Options{ + .to_module_ref = Ref.RuntimeRef, + .externals = ast.externals, + .runtime_imports = ast.runtime_imports, + .require_ref = ast.require_ref, + .css_import_behavior = bundler.options.cssImportBehavior(), + .source_map_handler = source_map_context, + .rewrite_require_resolve = bundler.options.platform != .node, + }, + Linker, + &bundler.linker, + enable_source_map, + ) + else + try js_printer.printAst( + Writer, + writer, + ast, + js_ast.Symbol.Map.initList(symbols), + &result.source, + false, + js_printer.Options{ + .to_module_ref = Ref.RuntimeRef, + .externals = ast.externals, + .runtime_imports = ast.runtime_imports, + .require_ref = ast.require_ref, + .css_import_behavior = bundler.options.cssImportBehavior(), + .source_map_handler = source_map_context, + .rewrite_require_resolve = bundler.options.platform != .node, + }, + Linker, + &bundler.linker, + enable_source_map, + ), + .cjs_ascii => if (bundler.options.platform.isBun()) + try js_printer.printCommonJS( + Writer, + writer, + ast, + js_ast.Symbol.Map.initList(symbols), + &result.source, + true, + js_printer.Options{ + .to_module_ref = Ref.RuntimeRef, + .externals = ast.externals, + .runtime_imports = ast.runtime_imports, + .require_ref = ast.require_ref, + .css_import_behavior = bundler.options.cssImportBehavior(), + .source_map_handler = source_map_context, + .rewrite_require_resolve = bundler.options.platform != .node, + }, + Linker, + &bundler.linker, + enable_source_map, + ) + else + try js_printer.printCommonJS( + Writer, + writer, + ast, + js_ast.Symbol.Map.initList(symbols), + &result.source, + false, + js_printer.Options{ + .to_module_ref = Ref.RuntimeRef, + .externals = ast.externals, + .runtime_imports = ast.runtime_imports, + .require_ref = ast.require_ref, + .css_import_behavior = bundler.options.cssImportBehavior(), + .source_map_handler = source_map_context, + .rewrite_require_resolve = bundler.options.platform != .node, + }, + Linker, + &bundler.linker, + enable_source_map, + ), }; } |