-
-
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
Use entryFileNames when generating filenames for virtual modules #4270
Use entryFileNames when generating filenames for virtual modules #4270
Conversation
Codecov Report
@@ Coverage Diff @@
## master #4270 +/- ##
=======================================
Coverage 98.39% 98.40%
=======================================
Files 204 204
Lines 7312 7319 +7
Branches 2084 2084
=======================================
+ Hits 7195 7202 +7
Misses 58 58
Partials 59 59
Continue to review full report at Codecov.
|
61e0d7d
to
a49072f
Compare
- virtual files now have a .js extension by default - systemjs module references include this file extension - amd module references omit this file extension. this seems to be consistent with amd output of other chunks
Use entryFileNames to change the extension of the filename to be mjs, and see that the file created from the virtual file chunk has a .mjs extension Note that the amd definition contains the .mjs extension, as amd ids only strip the .js file extension, which is slightly odd but probably ok as this amd is not the targetted usecase for this behaviour
a49072f
to
8f3747b
Compare
Rebased atop latest master |
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.
Thanks, looks great!
Thank you @lukastaegert <3 |
This PR contains:
Are tests included?
Breaking Changes?
List any relevant issue numbers:
Resolves #4269
Resolves rollup/plugins#1031
Resolves rollup/plugins#1037
Description
When
output.preserveModules:true
is set and there are virtual modules, rollup creates files on disk for each of those virtual modules.Prior to this PR the filename was the sanitised virtual module id but no further transformation was done. This meant that if the virtual module id had no extension, then the filename on disk lacked an extension, and if did specify an extension then the filename on disk would always be that extension, even if
output. entryFileNames
tried to use a different filename.This causes issues in cases where an environment can not load files that lack an extension (such as web browsers when the server can't set the correct mime-type - rollup/plugins#1037) or when the extension needs to be changed (such as when you want to create
.mjs
files for node esm support - rollup/plugins#1031)With this PR, the filenames of virtual modules are processed with
output.entryFileNames
in the same way as non-virtual modules - which by default will add a.js
extension to generated files and shall allow for customization of the extension of the filename.Notes
This PR has been split into three commits to try and help ease reviewing
\0virtualModule
previously generated_virtual/_virtualModule
and now generates_virtual/_virtualModule.js
\0other.js?commonjs-exports.js
previously generated_virtual/_other.js_commonjs-exports
and now generates_virtual/other.js_commonjs-exports.js
.js
extension, this seems to be consistent with how files produced from non-virtual modules are referenced.js
extension, but include other extensions, this seems to be consistent with how files produced from non-virtual modules are referenced