Skip to content
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

Switch to wasm-pack build --target bundler and Vite plugins for loading WebAssembly component #75

Merged
merged 5 commits into from
Jul 20, 2024

Conversation

ntninja
Copy link
Contributor

@ntninja ntninja commented Jul 18, 2024

Fixes dev-mode. This makes use of native Vite capabilities to load the WebAssembly component and appears to be the recommended approach nowadays.

See: rustwasm/wasm-pack#1106 (comment)

@ekzhang
Copy link
Owner

ekzhang commented Jul 18, 2024

Sweet, thanks! I hope this fixes the Docker build issue too, let's see.

Edit: It doesn't, I'll try to fix that in a separate PR!

@ekzhang
Copy link
Owner

ekzhang commented Jul 18, 2024

Getting this error in npm run build in CI:

#25 10.67 rendering chunks...
#25 12.53 x Build failed in 11.28s
#25 12.53 error during build:
#25 12.53 [vite-plugin-top-level-await] missing field `ctxt`
#25 12.53     at Compiler.printSync (/usr/src/app/node_modules/@swc/core/index.js:194:29)
#25 12.53     at Object.printSync (/usr/src/app/node_modules/@swc/core/index.js:348:21)
#25 12.53     at /usr/src/app/node_modules/vite-plugin-top-level-await/dist/index.js:103:32
#25 12.53     at Array.map (<anonymous>)
#25 12.53     at Object.generateBundle (/usr/src/app/node_modules/vite-plugin-top-level-await/dist/index.js:95:57)
#25 12.53     at async Bundle.generate (file:///usr/src/app/node_modules/rollup/dist/es/shared/node-entry.js:18122:9)
#25 12.53     at async file:///usr/src/app/node_modules/rollup/dist/es/shared/node-entry.js:20661:27
#25 12.53     at async catchUnfinishedHookActions (file:///usr/src/app/node_modules/rollup/dist/es/shared/node-entry.js:20088:16)
#25 12.53     at async build (file:///usr/src/app/node_modules/vite/dist/node/chunks/dep-D8YhmIY-.js:65743:16)
#25 12.53     at async CAC.<anonymous> (file:///usr/src/app/node_modules/vite/dist/node/cli.js:828:5)
#25 ERROR: process "/bin/sh -c npm run build" did not complete successfully: exit code: 1

@ekzhang
Copy link
Owner

ekzhang commented Jul 18, 2024

Hi @ntninja, thank you for contributing. I think the build is failing though after adding the vite-plugin-top-level-await in this PR, would you know why?

ntninja and others added 4 commits July 19, 2024 13:59
…ding WebAssembly component

Fixes dev-mode. This makes use of native Vite capabilities to load the
WebAssembly component and appears to be the recommended approach nowadays.

See: rustwasm/wasm-pack#1106 (comment)
Apparently @swc/core 1.7.0 (recently released) has a regression that breaks
vite-plugin-top-level-await:
Menci/vite-plugin-top-level-await#52
@ntninja ntninja force-pushed the rftr-wasm-loading branch from 66e38ba to 1867423 Compare July 19, 2024 12:00
@ntninja
Copy link
Contributor Author

ntninja commented Jul 19, 2024

Unfortunately there appears to be a regression between vite-plugin-top-level-await and recently released @swc/core 1.7.0:
Menci/vite-plugin-top-level-await#52

I’ve pinned @swc/core 1.6.* to work around this.

Sorry for the noise!

@ekzhang
Copy link
Owner

ekzhang commented Jul 20, 2024

Hi @ntninja — it looks like it's still failing CI due to an issue with package installation in npm ci.

@ntninja
Copy link
Contributor Author

ntninja commented Jul 20, 2024

It seems that the package-lock.json generated by NPM 9 (local) and NPM 10 (Dockerfile) slightly differs in regards to the directory dependency, which made the npm clean-install step fail.

@ekzhang
Copy link
Owner

ekzhang commented Jul 20, 2024

Thank you!

@ekzhang ekzhang merged commit 4901667 into ekzhang:main Jul 20, 2024
1 check passed
@ntninja ntninja deleted the rftr-wasm-loading branch July 22, 2024 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants