-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add originalFIleName property to emitted assets #5596
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Thank you for your contribution! ❤️You can try out this pull request locally by installing Rollup via npm install rollup/rollup#gh-4724_emit_with_file_name Notice: Ensure you have installed the latest stable Rust toolchain. If you haven't installed it yet, please see https://www.rust-lang.org/tools/install to learn how to download Rustup and install Rust. or load it into the REPL: |
Performance report!Rough benchmark
Internal benchmark
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #5596 +/- ##
=======================================
Coverage 99.05% 99.05%
=======================================
Files 242 242
Lines 9304 9307 +3
Branches 2463 2465 +2
=======================================
+ Hits 9216 9219 +3
Misses 58 58
Partials 30 30 ☔ View full report in Codecov by Sentry. |
This PR has been released as part of rollup@4.20.0. You can test it via |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏽
@lukastaegert In Vite, we had a internal list to manage the mapping between the original file name and the output file, so it won't be a problem. But maybe there's some users that wants to know that information. |
That is a good point. We can still rework the API to be a list instead in Rollup 5. |
<!-- Thank you for contributing! --> ### Description Add originalFileName to EmittedAsset, ref rollup/rollup#5596 <!-- Please insert your description here and provide especially info about the "what" this PR is solving -->
This PR contains:
Are tests included?
Breaking Changes?
List any relevant issue numbers:
output.assetFileNames()
: provide original file path of assets #4724Description
This is a long-requested feature for emitting assets. It adds a new optional property
originalFileName
tothis.emitFile({type: 'asset'})
calls that will be present in theoutput.assetFileNames
option and in thegenerateBundle
hook to identify from which file an asset was emitted.This was a long-requested feature, but I was hesitant to implement it because it requires changes in plugins that emit files to work. In short:
Plugins that use
this.emitFile
for an asset that corresponds to an actual source file should not set theoriginalFileName
property to the absolute path of the source file.Not only will this property then passed on, the source file will also automatically be watched in watch mode.
cc @patak-dev @sapphi-red @yyx990803 @antfu: As Vite implements many asset handling plugins, does this API look fine to you and would you be interested in supporting it in Vite?