Skip to content

[miniflare] Fix source phase imports parsing in module analysis#13238

Merged
petebacondarwin merged 4 commits intomainfrom
fix/wrangler-source-phase-imports-12995
Apr 2, 2026
Merged

[miniflare] Fix source phase imports parsing in module analysis#13238
petebacondarwin merged 4 commits intomainfrom
fix/wrangler-source-phase-imports-12995

Conversation

@guybedford
Copy link
Copy Markdown
Contributor

@guybedford guybedford commented Apr 2, 2026

Fixes module parsing to support the TC39 source phase imports proposal (import source wasm from './module.wasm'), which is required for WebAssembly ESM integration.

This is a follow-up to #12996 which added wrangler support for source phase imports. While that PR fixed wrangler's esbuild bundling and format detection, miniflare was still failing to parse Workers using this syntax with:

MiniflareCoreError [ERR_MODULE_PARSE]: Unable to parse \"build/index.js\": Unexpected token (37:14)

The issue was that miniflare uses acorn directly to analyze module dependencies, and acorn doesn't support the import source syntax by default. This PR adds the acorn-import-phases plugin to extend acorn's parser.

Part of #12995.


  • 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 is a bug fix that enables existing documented functionality to work correctly

Open with Devin

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 2, 2026

🦋 Changeset detected

Latest commit: 4f37431

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

@github-project-automation github-project-automation bot moved this to Untriaged in workers-sdk Apr 2, 2026
@workers-devprod workers-devprod requested review from a team and dario-piotrowicz and removed request for a team April 2, 2026 01:14
@workers-devprod
Copy link
Copy Markdown
Contributor

workers-devprod commented Apr 2, 2026

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler
Show detailed file reviewers

@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk bot commented Apr 2, 2026

UnknownError: ProviderInitError

github run

@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk bot commented Apr 2, 2026

@guybedford Bonk workflow failed. Check the logs for details.

View workflow run · To retry, trigger Bonk again.

Copy link
Copy Markdown
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 3 additional findings.

Open in Devin Review

@guybedford guybedford force-pushed the fix/wrangler-source-phase-imports-12995 branch from 762d667 to 14dd269 Compare April 2, 2026 01:19
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 2, 2026

create-cloudflare

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

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-shared

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

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-pool-workers

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

@cloudflare/workers-editor-shared

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

wrangler

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

commit: 4f37431

devin-ai-integration[bot]

This comment was marked as resolved.

Fixes module parsing to support the TC39 source phase imports proposal
(`import source wasm from './module.wasm'`), which is required for
WebAssembly ESM integration.

Follow-up to #12996 which added wrangler support. Part of #12995.

Changes:
- Add acorn-import-phases dependency to parse import source syntax
- Extend acorn Parser with the import phases plugin in modules.ts
- Add test for source phase imports parsing
@guybedford guybedford force-pushed the fix/wrangler-source-phase-imports-12995 branch from 14dd269 to 4f37431 Compare April 2, 2026 01:24
Copy link
Copy Markdown
Contributor

@workers-devprod workers-devprod left a comment

Choose a reason for hiding this comment

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

Codeowners reviews satisfied

@github-project-automation github-project-automation bot moved this from Untriaged to Approved in workers-sdk Apr 2, 2026
@petebacondarwin petebacondarwin merged commit b2f53ea into main Apr 2, 2026
53 of 54 checks passed
@petebacondarwin petebacondarwin deleted the fix/wrangler-source-phase-imports-12995 branch April 2, 2026 09:47
@github-project-automation github-project-automation bot moved this from Approved to Done in workers-sdk Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants