feat: implement resolveFileUrl plugin hook#10291
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. |
91d05f8 to
d5636e2
Compare
23f6bfe to
44cda05
Compare
d5636e2 to
5cf730e
Compare
5cf730e to
d305d46
Compare
✅ Deploy Preview for rolldown-rs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
d305d46 to
1146c28
Compare
@rolldown/browser
@rolldown/debug
rolldown
@rolldown/binding-android-arm64
@rolldown/binding-darwin-arm64
@rolldown/binding-darwin-x64
@rolldown/binding-freebsd-x64
@rolldown/binding-linux-arm-gnueabihf
@rolldown/binding-linux-arm64-gnu
@rolldown/binding-linux-arm64-musl
@rolldown/binding-linux-ppc64-gnu
@rolldown/binding-linux-s390x-gnu
@rolldown/binding-linux-x64-gnu
@rolldown/binding-linux-x64-musl
@rolldown/binding-openharmony-arm64
@rolldown/binding-wasm32-wasi
@rolldown/binding-win32-arm64-msvc
@rolldown/binding-win32-x64-msvc
commit: |
6168288 to
5f32fc5
Compare
Merging this PR will not alter performance
Comparing Footnotes
|
IWANABETHATGUY
left a comment
There was a problem hiding this comment.
Take it or leave it — fixture coverage is already strong; two gaps if you want them closed:
- a hashed-filename case (
chunkFileNames: '[name]-[hash].js'+ an emitted chunk) proving the hash placeholder infileName/chunkIdround-trips through plugin-returned code; - a cjs-format case — the hook is typed for
'es' | 'cjs' | 'iife' | 'umd'but only es and iife are exercised.
hyfdev
left a comment
There was a problem hiding this comment.
The overall direction and the two-stage design make sense, but I found one behavior difference that can make an otherwise successful build fail, so I'm requesting changes.
In priority order:
- Blocker:
resolveFileUrlis called for file-URL occurrences that tree-shaking removes. See the inline comment. - Rollup compatibility:
ResolveFileUrlArgsomits Rollup's requiredattributesfield. See the inline comment. This is also why the two chunking tests moved from passing to unsupported: Rollup passes{}even for an ordinary module, while this branch passes no field. - Rollup compatibility: On the existing computed-property thread, Rollup 4.62.2 does support
import.meta['ROLLUP_FILE_URL_x']via its stringpropertyKey, so the scanner should be extended rather than restricting the finalizer. - Docs: The AST-parsing behavior is worth documenting as already noted. The File URLs link should also target
Interface.Plugin#resolvefileurl, and the "independent of the output format" wording should be qualified because the default IIFE/UMD fallback warns and produces{}.url.
I also verified that hash placeholders round-trip through hook-returned code, output-only plugins work, and repeated ES/CJS generation receives the correct format; I did not find issues in those paths.
b20c409 to
ada3be7
Compare
|
I also refactored the code to use |
hyfdev
left a comment
There was a problem hiding this comment.
I re-reviewed the latest head. The computed-key and common whole-statement tree-shaking cases are fixed. I’m treating the remaining nested-expression liveness timing difference as non-blocking and will clarify that in the existing thread.
I found one live-code issue that still blocks approval, plus one non-blocking implementation difference; see the inline comments.
Two documentation items from my previous review also remain:
- The File URLs page links
resolveFileUrltoInterface.PluginContext; it should link to/reference/Interface.Plugin#resolvefileurl. - The hook documentation says the default URL works “independent of the output format”, but the current IIFE/UMD fallback warns and emits
{}.url. This should be qualified to mention the need for animport.meta.urlpolyfill or a custom hook.
Everything else I checked looks good. The focused fixtures, injected-expression unit tests, local build, and relevant CI all pass.
ada3be7 to
ba62cde
Compare
ba62cde to
072d54e
Compare
Fixed these in this PR |
Merge activity
|
This PR implements the `resolveFileUrl` hook, which exists in Rollup. 1. Collect `import.meta.ROLLUP_FILE_URL_*` information in the AstScanner 1. Rewrite the `import.meta.ROLLUP_FILE_URL_*` places in GenerateStage with the information collected https://rollupjs.org/plugin-development/#resolvefileurl refs vitejs/vite#22709
072d54e to
c31bc56
Compare

This PR implements the
resolveFileUrlhook, which exists in Rollup.import.meta.ROLLUP_FILE_URL_*information in the AstScannerimport.meta.ROLLUP_FILE_URL_*places in GenerateStage with the information collectedhttps://rollupjs.org/plugin-development/#resolvefileurl
refs vitejs/vite#22709