-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PR-URL: #55601 Reviewed-By: Marco Ippolito <[email protected]> Reviewed-By: Jacob Smith <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]>
- Loading branch information
1 parent
5de2567
commit 3477492
Showing
10 changed files
with
112 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
"강동윤 <[email protected]>" | ||
], | ||
"description": "wasm module for swc", | ||
"version": "1.7.35", | ||
"version": "1.7.40", | ||
"license": "Apache-2.0", | ||
"repository": { | ||
"type": "git", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { register } from "node:module"; | ||
|
||
register("./strip-loader.js", import.meta.url); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { register } from "node:module"; | ||
import { emitWarning, env, execArgv } from "node:process"; | ||
|
||
const hasSourceMaps = | ||
execArgv.includes("--enable-source-maps") || | ||
env.NODE_OPTIONS?.includes("--enable-source-maps"); | ||
|
||
if (!hasSourceMaps) { | ||
emitWarning("Source maps are disabled, stack traces will not accurate"); | ||
} | ||
|
||
register("./transform-loader.js", import.meta.url); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
"use strict"; | ||
import { transformSync } from "./index.js"; | ||
export async function load(url, context, nextLoad) { | ||
const { format } = context; | ||
if (format.endsWith("-typescript")) { | ||
const { source } = await nextLoad(url, { | ||
...context, | ||
format: "module" | ||
}); | ||
const { code } = transformSync(source.toString(), { | ||
mode: "strip-only" | ||
}); | ||
return { | ||
format: format.replace("-typescript", ""), | ||
// Source map is not necessary in strip-only mode. However, to map the source | ||
// file in debuggers to the original TypeScript source, add a sourceURL magic | ||
// comment to hint that it is a generated source. | ||
source: `${code} | ||
//# sourceURL=${url}` | ||
}; | ||
} | ||
return nextLoad(url, context); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
"use strict"; | ||
import { transformSync } from "./index.js"; | ||
export async function load(url, context, nextLoad) { | ||
const { format } = context; | ||
if (format.endsWith("-typescript")) { | ||
const { source } = await nextLoad(url, { | ||
...context, | ||
format: "module" | ||
}); | ||
const { code, map } = transformSync(source.toString(), { | ||
mode: "transform", | ||
sourceMap: true, | ||
filename: url | ||
}); | ||
let output = code; | ||
if (map) { | ||
const base64SourceMap = Buffer.from(map).toString("base64"); | ||
output = `${code} | ||
//# sourceMappingURL=data:application/json;base64,${base64SourceMap}`; | ||
} | ||
return { | ||
format: format.replace("-typescript", ""), | ||
source: `${output} | ||
//# sourceURL=${url}` | ||
}; | ||
} | ||
return nextLoad(url, context); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters