-
Notifications
You must be signed in to change notification settings - Fork 18
Fix webapp issue for Safari browser #2246
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
Changes from all commits
72d5d13
9dd6f80
eabe916
99c3c4d
9cbed8b
bbbeb0e
77960b9
bc54433
36a5dee
68ea21e
97a7d3c
002b5f1
f7b3940
cc84180
cc0f206
d672ba2
ffd7e6c
ac8d765
543bde6
3d9fdd4
162cf49
2a04d49
1aed8f9
17ff7ca
a8bf57f
4202d01
2734340
d6af302
5acb848
0732311
59cad5d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,34 +1,30 @@ | ||
| const fs = require("fs"); | ||
| const { sizeCheck } = require("./sizeCheck"); | ||
| const { execSync } = require("child_process"); | ||
|
|
||
| const [isTauriBuild = false] = process.argv.slice(2); | ||
| const { buildCjs, buildEsm } = require("./buildPackage"); | ||
|
|
||
| // create root esm.js and cjs.js files with their .d.ts | ||
| fs.writeFileSync( | ||
| "./cjs.js", | ||
| '"use strict";\n\nmodule.exports = require("./dist/cjs/index");\n' | ||
| ); | ||
| fs.writeFileSync("./cjs.d.ts", 'export * from "./dist/types/index";\n'); | ||
| fs.writeFileSync("./cjs.d.ts", 'export * from "./dist/cjs/index";\n'); | ||
| fs.writeFileSync("./esm.js", 'export * from "./dist/esm/index";\n'); | ||
| fs.writeFileSync("./esm.d.ts", 'export * from "./dist/types/index";\n'); | ||
|
|
||
| // create dist dir | ||
| fs.mkdirSync("./dist/cjs", { recursive: true }); | ||
| fs.mkdirSync("./dist/esm", { recursive: true }); | ||
|
|
||
| // build for wasm32 target | ||
| execSync("npm run build-wasm"); | ||
| fs.writeFileSync("./esm.d.ts", 'export * from "./dist/esm/index";\n'); | ||
|
|
||
| // build specified packages and include them in final index file | ||
| // list of packages to build can be extended by adding new package | ||
| // names to the list below | ||
| const packages = ["js_api"]; | ||
| for (const package of packages) { | ||
| execSync(`node ./scripts/buildPackage ${package} ${isTauriBuild ? 'true' : ''}`); | ||
| const pkgs = ["js_api"]; | ||
|
|
||
| for (const pkg of pkgs) { | ||
| // build for cjs and esm | ||
| buildCjs(pkg); | ||
| buildEsm(pkg); | ||
|
|
||
| // check wasm size | ||
| sizeCheck(pkg); | ||
| } | ||
|
|
||
| // rm temp folder | ||
| execSync("npm run rm-temp"); | ||
|
|
||
| // check bindings for possible errors | ||
| execSync("npm run check"); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| const fs = require('fs'); | ||
|
|
||
| const SIZE_LIMIT = 8_388_608; // 8 MB binary | ||
|
|
||
| module.exports.sizeCheck = function (pkg) { | ||
| // we only need to check size on web/esm | ||
| const wasmEsmBytes = fs.readFileSync(`./temp/web/${pkg}/${pkg}_bg.wasm`); | ||
| if (wasmEsmBytes.length > SIZE_LIMIT) { | ||
| throw new Error("ESM wasm size exceeds 8 MB limit!") | ||
| } | ||
|
rouzwelt marked this conversation as resolved.
|
||
| } | ||
|
Comment on lines
+1
to
+11
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Add error handling for missing package argument and file not found. The script will throw an unhelpful error if the Apply these improvements: const fs = require('fs');
const SIZE_LIMIT = 8_388_608; // 8 MB binary
const [pkg] = process.argv.slice(2);
+
+if (!pkg) {
+ throw new Error("Package name argument is required");
+}
// we only need to check size on web/esm
+const wasmPath = `./temp/web/${pkg}/${pkg}_bg.wasm`;
+if (!fs.existsSync(wasmPath)) {
+ throw new Error(`WASM file not found at ${wasmPath}`);
+}
-const wasmEsmBytes = fs.readFileSync(`./temp/web/${pkg}/${pkg}_bg.wasm`);
+const wasmEsmBytes = fs.readFileSync(wasmPath);
if (wasmEsmBytes.length > SIZE_LIMIT) {
throw new Error("ESM wasm size exceeds 8 MB limit!")
}🤖 Prompt for AI Agents
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not needed
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @rouzwelt, understood. I've noted your preference for these build scripts. ✏️ Learnings added
🧠 Learnings used |
||
Uh oh!
There was an error while loading. Please reload this page.