-
Notifications
You must be signed in to change notification settings - Fork 22
fix: wasm init #740
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
fix: wasm init #740
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
db99a3d
chore: add types/node to project
cedoor c87c2e7
chore: ts not ignored by npm
cedoor 486ac42
chore: add inline wasm to web bundle
cedoor bb2971a
chore: remove base64 to uint8 array function
cedoor 37a3ea0
docs: add license header to build script
cedoor 6a50383
chore: delete node gitignore
cedoor 5d30950
chore: update import path to correctweb bundle
cedoor f06ee8a
chore: add type to package.json
cedoor aa34e6c
chore: update import path to correct bundle
cedoor 6577ac2
chore: update build script to use rm from fs
cedoor 04e7e98
chore: disable wasm URL in web bundle
cedoor eff9042
chore: remove type=module from wasm package
cedoor 0704286
chore: update import path to correct bundle
cedoor afb9478
fix: remove unexisting variables
cedoor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -1,6 +1,5 @@ | ||
| src/ | ||
| scripts/ | ||
| *.ts | ||
| tsconfig.json | ||
| .gitignore | ||
| node_modules/ |
This file contains hidden or 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 hidden or 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 hidden or 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,48 @@ | ||
| // SPDX-License-Identifier: LGPL-3.0-only | ||
| // | ||
| // This file is provided WITHOUT ANY WARRANTY; | ||
| // without even the implied warranty of MERCHANTABILITY | ||
| // or FITNESS FOR A PARTICULAR PURPOSE. | ||
|
|
||
| import { execa } from "execa"; | ||
| import { readFile, writeFile, rm } from "fs/promises"; | ||
| import replaceInFile from "replace-in-file"; | ||
|
|
||
| try { | ||
| // Build WASM with web and node target - generates e3_wasm.js and e3_wasm_bg.wasm. | ||
| await execa("wasm-pack", [ | ||
| "build", | ||
| "--target=web", | ||
| "--out-dir=dist/web", | ||
| "--no-pack", | ||
| ]); | ||
| await execa("wasm-pack", [ | ||
| "build", | ||
| "--target=nodejs", | ||
| "--out-dir=dist/node", | ||
| "--no-pack", | ||
| ]); | ||
|
|
||
| // Convert WASM binary to base64 for bundler compatibility. | ||
| const wasmBinary = await readFile("./dist/web/e3_wasm_bg.wasm"); | ||
| const base64Src = `export default '${wasmBinary.toString("base64")}';\n`; | ||
|
|
||
| // Parallel cleanup and JS modification to prevent Next.js and other bundlers static analysis issues. | ||
| await Promise.all([ | ||
| await Promise.all([ | ||
| rm("./dist/web/e3_wasm_bg.wasm", { force: true }), | ||
| rm("./dist/web/e3_wasm_bg.wasm.d.ts", { force: true }), | ||
| rm("./dist/web/.gitignore", { force: true }), | ||
| rm("./dist/node/.gitignore", { force: true }), | ||
| ]), | ||
| replaceInFile({ | ||
| files: "./dist/web/e3_wasm.js", | ||
| from: /module_or_path\s*=\s*new URL\(['"]e3_wasm_bg\.wasm['"],\s*import\.meta\.url\);\s*/g, | ||
| to: "/* wasm URL disabled: load via @enclave-e3/wasm/init */\n", | ||
| }), | ||
| writeFile("./dist/web/e3_wasm_base64.js", base64Src), | ||
| ]); | ||
| } catch (error) { | ||
| console.error(error); | ||
| process.exit(1); | ||
| } | ||
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.