diff options
-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, + ), }; } |