From c6b22d399ff9168aed895efa11de1d3d6b3f8aa8 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Mon, 23 Dec 2024 03:40:00 -0800 Subject: [PATCH] Fix showing source code that looks like `export default "file-path"` (#15957) --- src/bun.js/javascript.zig | 3 ++- src/bun.js/module_loader.zig | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/bun.js/javascript.zig b/src/bun.js/javascript.zig index 9418c2fe39d68d..5db69ffbf25901 100644 --- a/src/bun.js/javascript.zig +++ b/src/bun.js/javascript.zig @@ -3620,7 +3620,8 @@ pub const VirtualMachine = struct { if (frame.source_url.hasPrefixComptime("bun:") or frame.source_url.hasPrefixComptime("node:") or frame.source_url.isEmpty() or - frame.source_url.eqlComptime("native")) + frame.source_url.eqlComptime("native") or + frame.source_url.eqlComptime("unknown")) { top_frame_is_builtin = true; continue; diff --git a/src/bun.js/module_loader.zig b/src/bun.js/module_loader.zig index a16a51a4a4802e..b316a1d764839c 100644 --- a/src/bun.js/module_loader.zig +++ b/src/bun.js/module_loader.zig @@ -1505,6 +1505,19 @@ pub const ModuleLoader = struct { ) !ResolvedSource { const disable_transpilying = comptime flags.disableTranspiling(); + if (comptime disable_transpilying) { + if (!(loader.isJavaScriptLike() or loader == .toml or loader == .text or loader == .json)) { + // Don't print "export default " + return ResolvedSource{ + .allocator = null, + .source_code = bun.String.empty, + .specifier = input_specifier, + .source_url = input_specifier.createIfDifferent(path.text), + .hash = 0, + }; + } + } + switch (loader) { .js, .jsx, .ts, .tsx, .json, .toml, .text => { jsc_vm.transpiled_count += 1;