From 8b1f160bb58a36a6f75759165f91de8c5c7afe06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Wed, 6 Mar 2024 13:17:49 +0000 Subject: fix: Provide source map for internal extension code (#22716) This commit adds support for source maps for `ext/` crates that are authored in TypeScript. As a result any exceptions thrown from eg. `ext/node` will now have correct stack traces. This is only enabled in debug mode as it adds about 2Mb to the binary. --- runtime/shared.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/shared.rs b/runtime/shared.rs index fc91be145..f9af2c7d4 100644 --- a/runtime/shared.rs +++ b/runtime/shared.rs @@ -97,8 +97,13 @@ pub fn maybe_transpile_source( let transpiled_source = parsed.transpile(&deno_ast::EmitOptions { imports_not_used_as_values: deno_ast::ImportsNotUsedAsValues::Remove, inline_source_map: false, + source_map: cfg!(debug_assertions), ..Default::default() })?; - Ok((transpiled_source.text.into(), None)) + let maybe_source_map: Option = transpiled_source + .source_map + .map(|sm| sm.into_bytes().into()); + + Ok((transpiled_source.text.into(), maybe_source_map)) } -- cgit v1.2.3