Skip to content

[wrangler] Support source phase imports#12996

Open
guybedford wants to merge 3 commits intomainfrom
fix/wrangler-source-phase-imports-12995
Open

[wrangler] Support source phase imports#12996
guybedford wants to merge 3 commits intomainfrom
fix/wrangler-source-phase-imports-12995

Conversation

@guybedford
Copy link

@guybedford guybedford commented Mar 21, 2026

Fixes #12995.

Wrangler's shared esbuild config targeted es2024 without enabling source phase import syntax, which caused import source Wasm imports to fail before Wrangler could preserve them in deploy output.

This enables esbuild's import-source syntax support in Wrangler's shared build options so source phase Wasm imports work in both bundled and --no-bundle deploy paths. It also adds regression coverage for worker format detection, wrangler deploy --no-bundle --dry-run, and bundled deploy output written via --outdir and --outfile.


  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: this fixes Wrangler's handling of an existing Wasm import syntax without changing the documented API.

A small sea otter successfully carrying a very important pebble.

@guybedford guybedford requested a review from a team as a code owner March 21, 2026 00:44
@changeset-bot
Copy link

changeset-bot bot commented Mar 21, 2026

🦋 Changeset detected

Latest commit: ef02bad

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

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

@workers-devprod
Copy link
Contributor

workers-devprod commented Mar 21, 2026

Codeowners approval required for this PR:

  • @cloudflare/wrangler
Show detailed file reviewers
  • packages/wrangler/src/tests/deploy/build.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/deploy/formats.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/guess-worker-format.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/deployment-bundle/bundle.ts: [@cloudflare/wrangler]

@github-actions
Copy link
Contributor

github-actions bot commented Mar 21, 2026

✅ All changesets look good

@ask-bonk
Copy link
Contributor

ask-bonk bot commented Mar 21, 2026

The review is complete. Let me analyze the changes:

  1. COMMON_ESBUILD_OPTIONS at bundle.ts:49 adds supported: { "import-source": true } — this tells esbuild to recognize source phase import syntax.

  2. guess-worker-format.ts:27 already spreads ...COMMON_ESBUILD_OPTIONS, so it automatically picks up the new supported field. This fixes the format detection path.

  3. bundle.ts:388 explicitly passes supported: COMMON_ESBUILD_OPTIONS.supported in the bundleWorker build options. This fixes the --no-bundle deploy path.

  4. Tests cover both the format detection path and the --no-bundle --dry-run deploy path.

The fix is correct and minimal:

  • guess-worker-format.ts uses spread so it inherits supported automatically — no change needed.
  • bundleWorker doesn't spread COMMON_ESBUILD_OPTIONS; it picks fields individually. The PR correctly adds the supported field alongside the existing target and loader references.
  • The changeset is properly scoped as a patch to wrangler.
  • Tests are well-targeted regression tests.

LGTM

github run

Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 21, 2026

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@12996

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@12996

miniflare

npm i https://pkg.pr.new/miniflare@12996

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@12996

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@12996

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@12996

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@12996

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@12996

wrangler

npm i https://pkg.pr.new/wrangler@12996

commit: ef02bad

@guybedford guybedford changed the title [wrangler] Fix no-bundle source phase imports [wrangler] Support source phase imports Mar 21, 2026
@guybedford guybedford force-pushed the fix/wrangler-source-phase-imports-12995 branch from cbfae6c to ef02bad Compare March 23, 2026 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Untriaged

Development

Successfully merging this pull request may close these issues.

Source Phase Imports support

2 participants