Skip to content

fix: support .wasm imports during dev and build - #17823

Merged
teemingc merged 9 commits into
mainfrom
teemingc/sveltekit-issue-17749-ccda69
Nov 23, 2026
Merged

teemingc merged 9 commits into
mainfrom
teemingc/sveltekit-issue-17749-ccda69

Conversation

@teemingc

@teemingc teemingc commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Closes #17826

A dependency that imports a .wasm file under its workerd condition works in vite dev and vite build again. Importing a .wasm file from the app's own code, which never worked, now works too, including .wasm?init. The deployed Worker is unchanged and still imports the .wasm file directly. This is a stopgap that can be removed once dev, analysis and prerendering run in workerd.

.wasm is now the only import that follows Wrangler's module rules. 9.0.0 also applied them to .txt, .html, .sql and .bin imports at build, which Node cannot import during analysis either, so a .txt import worked in dev and then failed the build. Those imports are left to Vite again, as they were before 9.0.0.

import file from './file.txt';

await read(file).text();
// before: works in dev, build fails with Unknown file extension ".txt"
// after: works in both

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

Edits

  • Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed.

@pkg-svelte-dev

pkg-svelte-dev Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Install the latest version of @sveltejs/kit from 8df0b1f:

pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/8df0b1f3304d3deb18b15646e24d7518ba267fd3

Open in pkg.svelte.dev: https://pkg.svelte.dev/repos/kit/pr/17823

@changeset-bot

changeset-bot Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8df0b1f

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

This PR includes changesets to release 1 package
Name Type
@sveltejs/adapter-cloudflare 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

@svelte-docs-bot

Copy link
Copy Markdown

Comment thread packages/adapter-cloudflare/wasm.js Resolved
@teemingc
teemingc merged commit 5b6b0cd into main Nov 23, 2026
40 checks passed
@teemingc
teemingc deleted the teemingc/sveltekit-issue-17749-ccda69 branch November 23, 2026 13:56
@github-actions github-actions Bot mentioned this pull request Nov 23, 2026
teemingc added a commit that referenced this pull request Nov 24, 2026
Backport of #17823 to 8.x, based on
the 8.0.3 release. Fixes #17826 on the 8.x line.

A dependency that imports a `.wasm` file under its `workerd` condition
works in `vite dev` and `vite build` again. Importing a `.wasm` file
from the app's own code, which never worked, now works too, including
`.wasm?init`, and the Worker that Wrangler bundles still imports the
`.wasm` file directly.

---

### Please don't delete this checklist! Before submitting the PR, please
make sure you do the following:

- [x] It's really useful if your PR references an issue where it is
discussed ahead of time. In many cases, features are absent for a
reason. For large changes, please create an RFC:
https://github.com/sveltejs/rfcs
- [x] This message body should clearly illustrate what problems it
solves.
- [x] Ideally, include a test that fails without this PR but passes with
it.

### Tests

- [ ] Run the tests with `pnpm test` and lint the project with `pnpm
lint` and `pnpm check`

### Changesets

- [x] If your PR makes a change that should be noted in one or more
packages' changelogs, generate a changeset by running `pnpm changeset`
and following the prompts. Changesets that add features should be
`minor` and those that fix bugs should be `patch`. Please prefix
changeset messages with `feat:`, `fix:`, or `chore:`.

### Edits

- [x] Please ensure that 'Allow edits from maintainers' is checked. PRs
without this option may be closed.

---------

Co-authored-by: Nic Polumeyv <[email protected]>
elliott-with-the-longest-name-on-github pushed a commit that referenced this pull request Nov 25, 2026
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @sveltejs/[email protected]

### Minor Changes

- feat: allow configuring the Node.js runtime version with the adapter's
optional `nodeVersion` option
([#17272](#17272))

### Patch Changes

- Updated dependencies:
  - @sveltejs/[email protected]
## @sveltejs/[email protected]

### Minor Changes

- feat: add `trailingSlashLocation` to
`@sveltejs/adapter-server/runtime`
([#17861](#17861))

### Patch Changes

- fix: percent-encode the `location` header of trailing-slash redirects
for prerendered pages
([`1648ec3`](1648ec3))
## @sveltejs/[email protected]

### Patch Changes

- fix: use a relative `Location` when redirecting to a prerendered
page's trailing-slash form, like adapter-node
([#17861](#17861))

- chore: bump `bun-types` to `^1.4.0`
([#17842](#17842))

- fix: only use `PORT_HEADER` when the forwarded host has no port
([#17859](#17859))
- Updated dependencies:
  - @sveltejs/[email protected]
  - @sveltejs/[email protected]
## @sveltejs/[email protected]

### Patch Changes

- fix: prevent text in server code from causing files on the build
machine to be published
([#17863](#17863))

- fix: build apps that import a `.txt` file
([#17823](#17823))

- fix: support `.wasm` imports during dev and build
([#17823](#17823))
- Updated dependencies:
  - @sveltejs/[email protected]
## @sveltejs/[email protected]

### Patch Changes

- fix: respond with a 500 instead of crashing the server when serving a
static or prerendered file fails unexpectedly
([`1648ec3`](1648ec3))

- fix: only use `PORT_HEADER` when the forwarded host has no port
([#17859](#17859))

- fix: percent-encode the `location` header of trailing-slash redirects
for prerendered pages
([`1648ec3`](1648ec3))
- Updated dependencies:
  - @sveltejs/[email protected]
  - @sveltejs/[email protected]
## @sveltejs/[email protected]

### Patch Changes

- fix: avoid repeatedly processing unchanged remote form issues
([`1c27a1e`](1c27a1e))

- fix: leave unchanged route types in place during sync
([#17735](#17735))

- fix: allow literal true in remote form schemas
([#17835](#17835))

- fix: limit arrays submitted to remote forms to 1,000 missing indexes,
and allow `undefined` in `RemoteFormInput` arrays
([`062fff6`](062fff6))

- fix: re-run nested queries on each iteration of a `query.live`
function instead of returning the value from the first iteration
([#17758](#17758))

- fix: apply origin checks to more browser-generated request content
types
([`7019207`](7019207))

- fix: always add `Vary: Accept` to responses from routes with both a
page and an endpoint
([`3a5d967`](3a5d967))

- fix: copy responses before adding internal headers
([`023d0e5`](023d0e5))

- fix: key per-request `query.live` iterators by function
([`5d611c6`](5d611c6))

- fix: return 400 for malformed request paths in development
([#17651](#17651))

- fix: improve performance of matching routes with multiple params in a
segment
([`aa525f1`](aa525f1))

- fix: harden stack trace handling and validate remote function request
metadata
([`0b98dae`](0b98dae))

- fix: warn about routes with params that can be slow to match
([`aa525f1`](aa525f1))

- fix: ship less client JavaScript when the app has no `reroute` hook
([#17817](#17817))

- fix: improve memory usage when reading request bodies
([`8f2e881`](8f2e881))

- fix: avoid retaining duplicate remote metadata during development
([#17611](#17611))

- fix: preserve shallow state updates made during refreshes
([#17839](#17839))

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.wasm imports in dependencies fail since @sveltejs/[email protected]

2 participants