Skip to content

feat(bundler): post-process turbopack output to fix import.meta.url#5890

Merged
killagu merged 3 commits intosplit/18-bundler-remove-eggjs-externalsfrom
split/19-bundler-patch-import-meta
Apr 27, 2026
Merged

feat(bundler): post-process turbopack output to fix import.meta.url#5890
killagu merged 3 commits intosplit/18-bundler-remove-eggjs-externalsfrom
split/19-bundler-patch-import-meta

Conversation

@killagu
Copy link
Copy Markdown
Contributor

@killagu killagu commented Apr 21, 2026

Adds Bundler.#patchImportMetaUrl() post-process step that walks output JS files and rewrites turbopack's throwing import.meta.url / import.meta.dirname getters into working forms. Wired into Bundler.run() after PackRunner with named error wrapping.

This is the final PR in the #5863 split. With all 19 PRs merged, the full bundler functionality from #5863 is available.

Part of #5863 split. Tracking: #5871.

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings April 21, 2026 15:21
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 21, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 76d7b235-d826-4f9d-837c-083415c733e3

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch split/19-bundler-patch-import-meta

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a post-processing step to the bundling process that patches import.meta in Turbopack-generated ESM chunks, enabling url, dirname, and filename to function correctly at runtime. Feedback was provided to ensure the patching logic recursively scans subdirectories, as Turbopack may generate chunks in nested folders that would otherwise be missed.

Comment thread tools/egg-bundler/src/lib/Bundler.ts Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a post-processing step in Bundler.run() to rewrite Turbopack-emitted throwing import.meta getters into runtime-working url/dirname/filename forms.

Changes:

  • Add Bundler.#patchImportMetaUrl() to rewrite import.meta patterns in emitted .js files.
  • Wire the patch step into Bundler.run() using wrapStep for named error wrapping and debug logging.

Comment thread tools/egg-bundler/src/lib/Bundler.ts Outdated
Comment thread tools/egg-bundler/src/lib/Bundler.ts Outdated
Comment thread tools/egg-bundler/src/lib/Bundler.ts Outdated
Comment thread tools/egg-bundler/src/lib/Bundler.ts Outdated
Comment thread tools/egg-bundler/src/lib/Bundler.ts Outdated
Comment thread tools/egg-bundler/src/lib/Bundler.ts Outdated
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Apr 27, 2026

Deploying egg-v3 with  Cloudflare Pages  Cloudflare Pages

Latest commit: 2b524f4
Status: ✅  Deploy successful!
Preview URL: https://92499ccc.egg-v3.pages.dev
Branch Preview URL: https://split-19-bundler-patch-impor.egg-v3.pages.dev

View logs

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Apr 27, 2026

Deploying egg with  Cloudflare Pages  Cloudflare Pages

Latest commit: 2b524f4
Status: ✅  Deploy successful!
Preview URL: https://23242781.egg-cci.pages.dev
Branch Preview URL: https://split-19-bundler-patch-impor.egg-cci.pages.dev

View logs

@killagu killagu merged commit 343d9d9 into split/18-bundler-remove-eggjs-externals Apr 27, 2026
7 checks passed
@killagu killagu deleted the split/19-bundler-patch-import-meta branch April 27, 2026 15:19
killagu added a commit that referenced this pull request Apr 30, 2026
…5890)

Adds `Bundler.#patchImportMetaUrl()` post-process step that walks output
JS files and rewrites turbopack's throwing `import.meta.url` /
`import.meta.dirname` getters into working forms. Wired into
`Bundler.run()` after PackRunner with named error wrapping.

This is the final PR in the #5863 split. With all 19 PRs merged, the
full bundler functionality from #5863 is available.

Part of #5863 split. Tracking: #5871.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
killagu added a commit that referenced this pull request Apr 30, 2026
…5890)

Adds `Bundler.#patchImportMetaUrl()` post-process step that walks output
JS files and rewrites turbopack's throwing `import.meta.url` /
`import.meta.dirname` getters into working forms. Wired into
`Bundler.run()` after PackRunner with named error wrapping.

This is the final PR in the #5863 split. With all 19 PRs merged, the
full bundler functionality from #5863 is available.

Part of #5863 split. Tracking: #5871.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
killagu added a commit that referenced this pull request Apr 30, 2026
…5890)

Adds `Bundler.#patchImportMetaUrl()` post-process step that walks output
JS files and rewrites turbopack's throwing `import.meta.url` /
`import.meta.dirname` getters into working forms. Wired into
`Bundler.run()` after PackRunner with named error wrapping.

This is the final PR in the #5863 split. With all 19 PRs merged, the
full bundler functionality from #5863 is available.

Part of #5863 split. Tracking: #5871.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
killagu added a commit that referenced this pull request May 1, 2026
…5890)

Adds `Bundler.#patchImportMetaUrl()` post-process step that walks output
JS files and rewrites turbopack's throwing `import.meta.url` /
`import.meta.dirname` getters into working forms. Wired into
`Bundler.run()` after PackRunner with named error wrapping.

This is the final PR in the #5863 split. With all 19 PRs merged, the
full bundler functionality from #5863 is available.

Part of #5863 split. Tracking: #5871.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
killagu added a commit that referenced this pull request May 1, 2026
…5890)

Adds `Bundler.#patchImportMetaUrl()` post-process step that walks output
JS files and rewrites turbopack's throwing `import.meta.url` /
`import.meta.dirname` getters into working forms. Wired into
`Bundler.run()` after PackRunner with named error wrapping.

This is the final PR in the #5863 split. With all 19 PRs merged, the
full bundler functionality from #5863 is available.

Part of #5863 split. Tracking: #5871.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
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.

2 participants