Optimize sourcemaps

This commit is contained in:
Jarred Sumner
2022-03-07 19:11:12 -08:00
parent da9a19037f
commit ce081f15e9
6 changed files with 211 additions and 91 deletions

View File

@@ -481,6 +481,24 @@ fn transformOptionsFromJSC(ctx: JSC.C.JSContextRef, temp_allocator: std.mem.Allo
transpiler.runtime.allow_runtime = flag.toBoolean();
}
if (object.get(globalThis, "sourcemap")) |flag| {
if (flag.isBoolean() or flag.isUndefinedOrNull()) {
if (flag.toBoolean()) {
transpiler.transform.source_map = Api.SourceMapMode.external;
} else {
transpiler.transform.source_map = Api.SourceMapMode.inline_into_file;
}
} else {
var sourcemap = flag.toSlice(globalThis, allocator);
if (options.SourceMapOption.map.get(sourcemap.slice())) |source| {
transpiler.transform.source_map = source.toAPI();
} else {
JSC.throwInvalidArguments("sourcemap must be one of \"inline\", \"external\", or \"none\"", .{}, ctx, exception);
return transpiler;
}
}
}
return transpiler;
}