Skip to content

fix(cloudflare): use native worker module identity - #3250

Open
james-elicx wants to merge 1 commit into
mainfrom
codex/remove-legacy-import-meta-registry
Open

fix(cloudflare): use native worker module identity#3250
james-elicx wants to merge 1 commit into
mainfrom
codex/remove-legacy-import-meta-registry

Conversation

@james-elicx

Copy link
Copy Markdown
Member

Summary

  • rely on Workerd's new_module_registry for dependency ESM and emitted module URLs instead of rewriting import.meta.url through private sentinels
  • retain source import.meta.url rewriting for Next.js parity and retain bundled CommonJS __filename / __dirname support
  • make new_module_registry part of generated, migrated, documented, example, and test Wrangler configurations
  • remove the Cloudflare environment filename resolver and the legacy Workerd simulation fixture

Cloudflare's registry contract now provides file URLs such as file:///bundle/index.js: https://github.com/cloudflare/workerd/blob/main/docs/reference/detail/new-module-registry.md

Project-source rewriting remains because Next.js still specifies source-module identity: https://github.com/vercel/next.js/blob/canary/test/e2e/import-meta/import-meta.test.ts

Validation

  • vp check
  • vp run vinext#build
  • vp test run tests/import-meta-url.test.ts
  • vp test run tests/init.test.ts
  • vp test run tests/pages-router.test.ts -t 'Pages Router import.meta.url in production'
  • vp test run tests/cjs-globals-runtime.test.ts (Node dev, Node production, Cloudflare dev, App Router Worker, Pages-only Worker, Nitro)
  • vp test run tests/after-response-close-worker.test.ts tests/cache-adapters-build.test.ts tests/cdn-adapter-build.test.ts tests/css-url-assets.test.ts tests/static-image-emission.test.ts tests/tsconfig-path-alias-build.test.ts
  • PLAYWRIGHT_PROJECT=cloudflare-encoded-paths pnpm run test:e2e -- module-identity.spec.ts

@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues

@pkg-pr-new

pkg-pr-new Bot commented Sep 14, 2026

Copy link
Copy Markdown

Open in StackBlitz

@vinext/cloudflare

npm i https://pkg.pr.new/cloudflare/vinext/@vinext/cloudflare@3250

create-vinext-app

npm i https://pkg.pr.new/cloudflare/vinext/create-vinext-app@3250

@vinext/types

npm i https://pkg.pr.new/cloudflare/vinext/@vinext/types@3250

vinext

npm i https://pkg.pr.new/cloudflare/vinext@3250

@cloudflare/workers-response-store

npm i https://pkg.pr.new/cloudflare/vinext/@cloudflare/workers-response-store@3250

commit: a545dd4

@github-actions

Copy link
Copy Markdown
Contributor
Example Preview Production Original
app-router-cloudflare preview production
pages-router-cloudflare preview production
app-router-playground preview production original
realworld-api-rest preview production
nextra-docs-template preview production
benchmarks preview production
hackernews preview production original
response-store-demo preview production
static-export preview production
web preview production

@github-actions

Copy link
Copy Markdown
Contributor

Performance benchmarks

Compared a545dd4 against base 8eccc20 using alternating same-runner rounds. Next.js was unchanged and skipped.

1 improved · 0 regressed · 5 within ±1.5%

Scenario Framework Baseline Current Change
Client bundle size (gzip) vinext 142.2 KB 142.3 KB ⚫ +0.0%
Client entry size (gzip) vinext 129.6 KB 129.6 KB ⚫ +0.0%
Dev server cold start vinext 3.46 s 3.38 s 🟢 -2.3%
Production build time vinext 3.84 s 3.82 s ⚫ -0.7%
RSC entry closure size (gzip) vinext 125.8 KB 125.8 KB ⚫ -0.0%
Server bundle size (gzip) vinext 216.5 KB 216.4 KB ⚫ -0.0%

View detailed results and traces

🟢 improvement · 🔴 regression · ⚫ change below 1.5% · paired base/head

@ask-bonk

ask-bonk Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

@james-elicx Bonk workflow was cancelled.

View workflow run · To retry, trigger Bonk again.

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.

1 participant