feat(bundler): post-process turbopack output to fix import.meta.url#5890
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 rewriteimport.metapatterns in emitted.jsfiles. - Wire the patch step into
Bundler.run()usingwrapStepfor named error wrapping and debug logging.
Deploying egg-v3 with
|
| 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 |
Deploying egg with
|
| 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 |
343d9d9
into
split/18-bundler-remove-eggjs-externals
…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)
…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)
…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)
…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)
…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)
Adds
Bundler.#patchImportMetaUrl()post-process step that walks output JS files and rewrites turbopack's throwingimport.meta.url/import.meta.dirnamegetters into working forms. Wired intoBundler.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