feat: support import.meta.ROLLUP_FILE_URL_(referenceId)#3488
Merged
IWANABETHATGUY merged 10 commits intorolldown:mainfrom Feb 5, 2025
Merged
feat: support import.meta.ROLLUP_FILE_URL_(referenceId)#3488IWANABETHATGUY merged 10 commits intorolldown:mainfrom
import.meta.ROLLUP_FILE_URL_(referenceId)#3488IWANABETHATGUY merged 10 commits intorolldown:mainfrom
Conversation
| let importer_dir = importer_chunk | ||
| .absolute_preliminary_filename | ||
| .as_ref() | ||
| .unwrap() |
Member
There was a problem hiding this comment.
We should either add SAFETY comments or expect instead of unwrap, attend to give a more friendly panic message.
Collaborator
Author
There was a problem hiding this comment.
Replaced unwrap with expect 👍
FYI, I referenced the code from Chunk::import_path_for, which computes relative chunk path. I'll try to refactor some repeated code separately later.
rolldown/crates/rolldown_common/src/chunk/mod.rs
Lines 88 to 92 in aad0c09
IWANABETHATGUY
approved these changes
Feb 5, 2025
This was referenced Feb 6, 2025
github-merge-queue bot
pushed a commit
that referenced
this pull request
Feb 6, 2025
<!-- Thank you for contributing! --> ### Description Follow up to #3488. I forgot to test `emitFile({ type: "chunk" })` case and I just realized it's not working on hi-ogawa/vite-environment-examples#154. Currently, `FileEmitter::emitted_chunks` is not defined during scope hoisting finalizer, but it looks possible to define it earlier right after `generate_chunk_name_and_preliminary_filenames` instead of waiting until `instantiate_chunks`.
IWANABETHATGUY
pushed a commit
that referenced
this pull request
Feb 7, 2025
### Description Minor cleanup as I mentioned in #3488 (comment)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Reviving #1928. I came across
import.meta.url.ROLLUP_FILE_URL_xxxin one of my plugins (hi-ogawa/vite-plugins#673) and I think having the compat in rolldown is nice to have (though it's also possible to have a compat in rolldown-vite or user land level via a custom plugin'srenderChunkreplacing).Sapphi also mentioned that Astro uses this feature #819 (comment). I'm hoping the complexity required on rolldown side is low and it's worth the inclusion. Let me know what you think.
Example user-land plugin to replace "import.meta.ROLLUP_FILE_URL_xxx"
From hi-ogawa/vite-plugins#673