Skip to content

fix: support bare Node built-ins and .wasm/font files in Netlify edge functions - #17324

Merged
teemingc merged 7 commits into
sveltejs:mainfrom
dlebech:fix/netlify-edge-builtins-wasm
Oct 5, 2026
Merged

teemingc merged 7 commits into
sveltejs:mainfrom
dlebech:fix/netlify-edge-builtins-wasm

Conversation

@dlebech

@dlebech dlebech commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

closes #17323

Fixes two regressions from the esbuild → rolldown migration (#15432) in the Netlify edge function bundle:

  • Replaces the resolve.alias for Node built-ins with a small resolveId plugin. With the alias, rolldown tries to resolve node:crypto itself and errors before external is checked.
  • Restores the esbuild copy loaders for .wasm and font files via moduleTypes.

Adds a bare crypto import and a .wasm import (via a local test dependency) to the edge test app, with build tests that fail without this change. I also ran the built edge function in Deno 2.9 to confirm both routes work.


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

  • 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
  • This message body should clearly illustrate what problems it solves.
  • 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

  • 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.

🤖 Generated with Claude Code

… functions

The migration from esbuild to rolldown (#15432) regressed two cases in the
edge function bundle:

- `resolve.alias` rewrites `crypto` to `node:crypto`, but rolldown then tries
  to resolve `node:crypto` itself and errors before `external` is checked.
  Replace the alias with a `resolveId` plugin that marks it external.
- The esbuild `copy` loaders for `.wasm` and font files were dropped, so
  rolldown tried to parse them as JS. Restore them via `moduleTypes`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pkg-svelte-dev

pkg-svelte-dev Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Install the latest version of @sveltejs/kit from 931571d:

pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/931571d894928daccbc4df12bd6bfd8e20c22d3f

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

Note

This PR is from a fork. A maintainer must approve approve each commit before it can be built and installed.

@changeset-bot

changeset-bot Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 931571d

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-netlify 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

@teemingc teemingc added pkg:adapter-netlify needs-platform-tests This PR needs to run platform tests in order to merge. labels Oct 4, 2026
@svelte-docs-bot

Copy link
Copy Markdown

Comment thread packages/adapter-netlify/index.js Outdated
@teemingc

teemingc commented Oct 5, 2026

Copy link
Copy Markdown
Member

Test failures are related to the Netlify CLI rather than the change itself. Verified manually

@teemingc teemingc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you! I made a small tweak by replacing the custom plugin with specifying platform: 'node' instead (this is what Netlify's edge bundler does)

@teemingc
teemingc merged commit 13f6c91 into sveltejs:main Oct 5, 2026
37 of 38 checks passed
@github-actions github-actions Bot mentioned this pull request Oct 5, 2026
@dlebech
dlebech deleted the fix/netlify-edge-builtins-wasm branch October 20, 2026 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-platform-tests This PR needs to run platform tests in order to merge. pkg:adapter-netlify

Projects

None yet

Development

Successfully merging this pull request may close these issues.

adapter-netlify 7: edge build fails on bare Node built-in imports and .wasm files (rolldown migration regression)

2 participants