Skip to content

fix: add EMPTY_IMPORT_META warning for non-node CJS output#10222

Merged
graphite-app[bot] merged 1 commit into
mainfrom
07-10-fix_add_empty_import_meta_warning_for_non-node_cjs_output
Jul 17, 2026
Merged

fix: add EMPTY_IMPORT_META warning for non-node CJS output#10222
graphite-app[bot] merged 1 commit into
mainfrom
07-10-fix_add_empty_import_meta_warning_for_non-node_cjs_output

Conversation

@sapphi-red

@sapphi-red sapphi-red commented Jul 10, 2026

Copy link
Copy Markdown
Member

The EMPTY_IMPORT_META warning was no emitted for non-node CJS output. This PR fixes that.

sapphi-red commented Jul 10, 2026

Copy link
Copy Markdown
Member Author

How to use the Graphite Merge Queue

Add the label graphite: merge-when-ready to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@codspeed-hq

codspeed-hq Bot commented Jul 10, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 7 untouched benchmarks
⏩ 10 skipped benchmarks1


Comparing 07-10-fix_add_empty_import_meta_warning_for_non-node_cjs_output (a3fbccf) with main (0e1e8aa)

Open in CodSpeed

Footnotes

  1. 10 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

Comment thread crates/rolldown/src/module_finalizers/impl_visit_mut.rs Outdated
@sapphi-red
sapphi-red changed the base branch from 07-10-fix_incorrect_empty_import_meta_warning_for_import.meta.rollup_file_url__for_cjs_output to graphite-base/10222 July 13, 2026 03:43
@sapphi-red
sapphi-red marked this pull request as draft July 13, 2026 04:10
@sapphi-red
sapphi-red force-pushed the 07-10-fix_add_empty_import_meta_warning_for_non-node_cjs_output branch from f2d8191 to 4ed5cbc Compare July 13, 2026 04:28
@sapphi-red
sapphi-red force-pushed the graphite-base/10222 branch from 9e0e85d to bad54f7 Compare July 13, 2026 04:28
@sapphi-red
sapphi-red changed the base branch from graphite-base/10222 to main July 13, 2026 04:28
graphite-app Bot pushed a commit that referenced this pull request Jul 13, 2026
`import.meta['url']` is rewritten by Rollup, but Rolldown didn't support it.
Also the EMPTY_IMPORT_META warning was not output for it, while it was replaced with `{}['url']`.

This PR also adds tests for `import.meta?.url` which was working.

This was found while investigating #10222 (comment)
@sapphi-red
sapphi-red changed the base branch from main to graphite-base/10222 July 13, 2026 05:50
@sapphi-red
sapphi-red force-pushed the 07-10-fix_add_empty_import_meta_warning_for_non-node_cjs_output branch from 4ed5cbc to 8ddebf0 Compare July 13, 2026 05:50
@sapphi-red
sapphi-red changed the base branch from graphite-base/10222 to 07-13-feat_rewrite_import.meta_url_ July 13, 2026 05:50
Base automatically changed from 07-13-feat_rewrite_import.meta_url_ to main July 13, 2026 05:52
@sapphi-red
sapphi-red force-pushed the 07-10-fix_add_empty_import_meta_warning_for_non-node_cjs_output branch from 8ddebf0 to 7310ce0 Compare July 13, 2026 06:37
@netlify

netlify Bot commented Jul 13, 2026

Copy link
Copy Markdown

Deploy Preview for rolldown-rs canceled.

Name Link
🔨 Latest commit e3345c0
🔍 Latest deploy log https://app.netlify.com/projects/rolldown-rs/deploys/6a5a30cb99a51f00089f7582

Comment thread crates/rolldown/src/stages/generate_stage/finalize_modules.rs Outdated
@sapphi-red
sapphi-red marked this pull request as ready for review July 13, 2026 06:42
@sapphi-red
sapphi-red requested a review from hyfdev July 13, 2026 06:43

@hyfdev hyfdev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Verified the finalizer-based warning flow and the computed/optional import.meta.url regression cases. LGTM.

@sapphi-red
sapphi-red force-pushed the 07-10-fix_add_empty_import_meta_warning_for_non-node_cjs_output branch from 7310ce0 to a3fbccf Compare July 17, 2026 10:31

sapphi-red commented Jul 17, 2026

Copy link
Copy Markdown
Member Author

Merge activity

  • Jul 17, 10:33 AM UTC: The merge label 'graphite: merge-when-ready' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Jul 17, 1:39 PM UTC: sapphi-red added this pull request to the Graphite merge queue.
  • Jul 17, 1:45 PM UTC: Merged by the Graphite merge queue.

@sapphi-red
sapphi-red marked this pull request as draft July 17, 2026 10:39

@hyfdev hyfdev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Moving EMPTY_IMPORT_META into the finalizer is the right fix for non-node CJS: warn when rewrite actually replaces import.meta with {}, rather than guessing from format alone in the scanner. The new non-node and ESM fixtures look good, and the focused Rust fixtures pass on this head.

The remaining problem is ownership of the warning for default ROLLUP_FILE_URL_* rewrites on iife/umd: resolve_file_urls still emits RolldownFileUrl, and the finalizer emits again for the collapsed generated import.meta.url. That doubles the log count and fails the Node fixtures listed in the inline comment.

— AI review by grok-4.5

Comment thread crates/rolldown/src/module_finalizers/finalizer_context.rs
Comment thread crates/rolldown/src/module_finalizers/impl_visit_mut.rs Outdated
@sapphi-red
sapphi-red force-pushed the 07-10-fix_add_empty_import_meta_warning_for_non-node_cjs_output branch from a3fbccf to 0a7e3c8 Compare July 17, 2026 11:39
@sapphi-red
sapphi-red marked this pull request as ready for review July 17, 2026 12:22
@sapphi-red
sapphi-red marked this pull request as draft July 17, 2026 12:23
@sapphi-red
sapphi-red force-pushed the 07-10-fix_add_empty_import_meta_warning_for_non-node_cjs_output branch from 0a7e3c8 to 8ed7fce Compare July 17, 2026 12:29
@sapphi-red
sapphi-red marked this pull request as ready for review July 17, 2026 12:33
@sapphi-red
sapphi-red requested a review from hyfdev July 17, 2026 12:38

@hyfdev hyfdev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The double-count path is gone: resolve_file_urls no longer pre-warns, and the finalizer owns a single EMPTY_IMPORT_META for default FILE_URL rewrites by recording RolldownFileUrl on the original span and reusing that span on the generated import.meta. Non-node CJS plain / optional / computed accesses warn correctly, and node CJS polyfills stay silent.

I left one non-blocking note about covering non-node CJS FILE_URL with a fixture.

— AI review by grok-4.5

Comment thread crates/rolldown/src/module_finalizers/mod.rs
@sapphi-red
sapphi-red force-pushed the 07-10-fix_add_empty_import_meta_warning_for_non-node_cjs_output branch from 8ed7fce to 86be453 Compare July 17, 2026 13:34
<!--
- What is this PR solving? Write a clear and concise description.
- Reference the issues it solves (e.g. `fixes #123`).
- What other alternatives have you explored?
- Are there any parts you think require more attention from reviewers?

Also, please make sure you do the following:

- Read the Contributing Guidelines at https://rolldown.rs/contribution-guide/.
- Check that there isn't already a PR that solves the problem the same way. If you find a duplicate, please help us review it.
- Update the corresponding documentation if needed.
- Include relevant tests that fail without this PR but pass with it. If the tests are not included, explain why.

Thank you for contributing to Rolldown!
-->

The `EMPTY_IMPORT_META` warning was no emitted for non-node CJS output. This PR fixes that.
@graphite-app
graphite-app Bot force-pushed the 07-10-fix_add_empty_import_meta_warning_for_non-node_cjs_output branch from 86be453 to e3345c0 Compare July 17, 2026 13:40
@graphite-app
graphite-app Bot merged commit e3345c0 into main Jul 17, 2026
34 checks passed
@graphite-app
graphite-app Bot deleted the 07-10-fix_add_empty_import_meta_warning_for_non-node_cjs_output branch July 17, 2026 13:45
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.

4 participants