Skip to content

Commit

Permalink
Revert "compiler: Bundle dependencies' source maps (#69)"
Browse files Browse the repository at this point in the history
As it needs more work to support TypeScript 5.x.

This reverts commit 919a4d0.
  • Loading branch information
oleavr committed Jun 1, 2023
1 parent 919a4d0 commit c02f43e
Showing 1 changed file with 1 addition and 20 deletions.
21 changes: 1 addition & 20 deletions src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -526,28 +526,9 @@ function createBundler(entrypoint: EntrypointName, projectRoot: string, assets:
const lines = code.split("\n");
const n = lines.length;
const lastLine = lines[n - 1];

const sourceMapToken = "//# sourceMappingURL=";
if (lastLine.startsWith(sourceMapToken)) {
if (lastLine.startsWith("//# sourceMappingURL=")) {
const precedingLines = lines.slice(0, n - 1);
code = precedingLines.join("\n");

const inlinedSourceMapOrPath = lastLine.substring(sourceMapToken.length);

const dataUrlToken = "data:application/json;base64,";
const isInlined = inlinedSourceMapOrPath.startsWith(dataUrlToken);

const sourceMapPath = isInlined
? `${name}.map`
: crosspath.join(crosspath.dirname(name), inlinedSourceMapOrPath);

if (!output.has(sourceMapPath)) {
const content = isInlined
? system.base64decode(inlinedSourceMapOrPath.substring(dataUrlToken.length))
: system.readFile(`.${sourceMapPath}`);

output.set(sourceMapPath, content);
}
}

if (compression === "terser") {
Expand Down

0 comments on commit c02f43e

Please sign in to comment.