-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(es/typescript): Add esm build for fast ts strip
- Loading branch information
1 parent
76fe139
commit 8c8a0fe
Showing
5 changed files
with
45 additions
and
9 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
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,15 @@ | ||
import fs from "node:fs/promises"; | ||
|
||
const pkgJsonFile = await fs.readFile("esm/package.json", "utf8"); | ||
const pkgJson = JSON.parse(pkgJsonFile); | ||
pkgJson.name = '@swc/wasm-typescript-esm'; | ||
pkgJson.exports = { | ||
types: "./wasm.d.ts", | ||
node: "./wasm-node.js", | ||
default: "./wasm.js", | ||
}; | ||
|
||
await Promise.all([ | ||
fs.cp("src/wasm-node.js", "esm/wasm-node.js"), | ||
fs.writeFile("esm/package.json", JSON.stringify(pkgJson, null, 2)), | ||
]); |
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,2 @@ | ||
wasm-pack build --out-name wasm --out-dir esm --release --scope=swc --target web | ||
node ./scripts/esm.mjs |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import fs from "node:fs/promises"; | ||
import initAsync from "./wasm.js"; | ||
|
||
const wasm = new URL("./wasm_bg.wasm", import.meta.url); | ||
|
||
export default function (init = fs.readFile(wasm)) { | ||
return initAsync(init); | ||
} | ||
|
||
export * from "./wasm.js"; |