fix: add EMPTY_IMPORT_META warning for non-node CJS output#10222
Conversation
How to use the Graphite Merge QueueAdd 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. |
Merging this PR will not alter performance
Comparing Footnotes
|
f2d8191 to
4ed5cbc
Compare
9e0e85d to
bad54f7
Compare
`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)
4ed5cbc to
8ddebf0
Compare
8ddebf0 to
7310ce0
Compare
✅ Deploy Preview for rolldown-rs canceled.
|
hyfdev
left a comment
There was a problem hiding this comment.
Verified the finalizer-based warning flow and the computed/optional import.meta.url regression cases. LGTM.
7310ce0 to
a3fbccf
Compare
Merge activity
|
hyfdev
left a comment
There was a problem hiding this comment.
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
a3fbccf to
0a7e3c8
Compare
0a7e3c8 to
8ed7fce
Compare
hyfdev
left a comment
There was a problem hiding this comment.
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
8ed7fce to
86be453
Compare
<!-- - 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.
86be453 to
e3345c0
Compare

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