Skip to content

fix(bundle): transform import.meta.main #29830

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 23, 2025

Conversation

nathanwhit
Copy link
Member

For entrypoints, it remains untouched. For non-entrypoints it becomes false.

Copy link
Contributor

@Copilot 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

This PR adds a new AST transform to rewrite import.meta.main to false for bundled non-entrypoint modules, integrates it into the bundler pipeline, and updates tests to cover the new behavior.

  • Introduce BundleTransform in transform.rs to detect and replace import.meta.main for non-entrypoints
  • Wire up the transform in cli/tools/bundle/mod.rs, updating loader logic and error variants
  • Add end-to-end tests under tests/specs/bundle/import_meta_main

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/specs/bundle/import_meta_main/main.ts Test entrypoint logging import.meta.main
tests/specs/bundle/import_meta_main/a.ts Test non-entrypoint a.ts export of import.meta.main
tests/specs/bundle/import_meta_main/b.ts Test non-entrypoint b.ts export of import.meta.main
tests/specs/bundle/import_meta_main/test.jsonc Expected bundle output and runtime logs
cli/tools/bundle/transform.rs New AST visitor to replace import.meta.main for non-entrypoints
cli/tools/bundle/mod.rs Hook up transform, extend loader return types, update error enum

@nathanwhit nathanwhit enabled auto-merge (squash) June 23, 2025 20:14
@nathanwhit nathanwhit merged commit 19d08d1 into denoland:main Jun 23, 2025
18 checks passed
@nathanwhit nathanwhit deleted the bundle-import-meta-main branch June 23, 2025 21:01
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