-
Notifications
You must be signed in to change notification settings - Fork 772
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
feat: import .wasm
modules in service worker format workers
#432
Conversation
🦋 Changeset detectedLatest commit: e681b66 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
wrangler prerelease is available for testing: npm install --save-dev https://prerelease-registry.developers.workers.dev/runs/1829576326/wrangler |
32766b9
to
f70ad18
Compare
f70ad18
to
66d53d0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that index_bg.js
is identical between the three Workers.
Perhaps we could just move that next to the index_bg.wasm
file to remove duplication?
packages/example-wasm-app/README.md
Outdated
The wasm file generated, `index_bg.wasm` is copied into `./worker`, and shared by the 2 workers. `./worker/module` contains a "modules" format worker and imports the wasm module as a regular es module, while `./worker/service-worker` contains a "service-worker" format worker and uses wrangler.toml to bind the wasm module as a global `MYWASM`. They're otherwise identical. | ||
The wasm file generated, `index_bg.wasm` is copied into `./worker`, and shared by the 3 workers. | ||
|
||
- `./worker/module` contains a "modules" format worker and imports the wasm module as a regular es module. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: Every where I look it is ES module
not es module
... 🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I replaced it across the codebase.
contents: `export default ${args.path.replace( | ||
/[^a-zA-Z0-9_$]/g, | ||
"_" | ||
)};`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A comment explaining the point of this code would be helpful here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some comments. Do they look ok to you?
This allows importing `.wasm` modules in service worker format workers. We do this by hijacking imports to `.wasm` modules, and instead registering them under `[wasm_modules]` (building on the work from #409).
66d53d0
to
e681b66
Compare
I missed the bit about |
Actually, lemme land this. We can change the comments whenever. |
…ts (#432) * Allow `string[]` for `kvNamespaces`/`r2Buckets` like Miniflare 2 In this case, the binding name is assumed to be the same as the namespace ID/bucket name. * Add API documentation
…ts (#432) * Allow `string[]` for `kvNamespaces`/`r2Buckets` like Miniflare 2 In this case, the binding name is assumed to be the same as the namespace ID/bucket name. * Add API documentation
…ts (#432) * Allow `string[]` for `kvNamespaces`/`r2Buckets` like Miniflare 2 In this case, the binding name is assumed to be the same as the namespace ID/bucket name. * Add API documentation
…ts (#432) * Allow `string[]` for `kvNamespaces`/`r2Buckets` like Miniflare 2 In this case, the binding name is assumed to be the same as the namespace ID/bucket name. * Add API documentation
This allows importing
.wasm
modules in service worker format workers. We do this by hijacking imports to.wasm
modules, and instead registering them under[wasm_modules]
(building on the work from #409).