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

feat: support [wasm_modules] for service-worker format workers #409

Merged
merged 1 commit into from
Feb 9, 2022

Conversation

threepointone
Copy link
Contributor

This lands support for [wasm_modules] as defined by cloudflare/wrangler-legacy#1677.

wasm modules can be defined in service-worker format with configuration in wrangler.toml as -

[wasm_modules]
MYWASM = "./path/to/my-wasm.wasm"

The module will then be available as the global MYWASM inside your code. Note that this ONLY makes sense in service-worker format workers (for now).

(In the future, we MAY enable wasm module imports in service-worker format (i.e. import MYWASM from './path/to/my-wasm.wasm') and global imports inside modules format workers.)

@changeset-bot
Copy link

changeset-bot bot commented Feb 7, 2022

🦋 Changeset detected

Latest commit: 2bd500d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
wrangler Patch

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

@github-actions
Copy link
Contributor

github-actions bot commented Feb 7, 2022

wrangler prerelease is available for testing:

npm install --save-dev https://prerelease-registry.developers.workers.dev/runs/1817713440/wrangler

Copy link
Contributor

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A handful of nits.

packages/example-wasm-app/package.json Show resolved Hide resolved
packages/wrangler/src/__tests__/publish.test.ts Outdated Show resolved Hide resolved
packages/wrangler/src/api/form_data.ts Outdated Show resolved Hide resolved
packages/wrangler/src/__tests__/dev.test.tsx Outdated Show resolved Hide resolved
This lands support for `[wasm_modules]` as defined by cloudflare/wrangler-legacy#1677.

wasm modules can be defined in service-worker format with configuration in wrangler.toml as -

```
[wasm_modules]
MYWASM = "./path/to/my-wasm.wasm"
```

The module will then be available as the global `MYWASM` inside your code. Note that this ONLY makes sense in service-worker format workers (for now).

(In the future, we MAY enable wasm module imports in service-worker format (i.e. `import MYWASM from './path/to/my-wasm.wasm'`) and global imports inside modules format workers.)
@threepointone threepointone merged commit f8bb523 into main Feb 9, 2022
@threepointone threepointone deleted the wasm-modules branch February 9, 2022 11:26
@github-actions github-actions bot mentioned this pull request Feb 9, 2022
threepointone added a commit that referenced this pull request Feb 10, 2022
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).
threepointone added a commit that referenced this pull request Feb 10, 2022
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).
threepointone added a commit that referenced this pull request Feb 10, 2022
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).
threepointone added a commit that referenced this pull request Feb 10, 2022
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).
threepointone added a commit that referenced this pull request Feb 11, 2022
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).
threepointone added a commit that referenced this pull request Feb 11, 2022
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).
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.

feat: support [wasm_modules]
2 participants