-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Include extensions in preserveModules output filenames for scriptified assets #3116
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
Include extensions in preserveModules output filenames for scriptified assets #3116
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3116 +/- ##
==========================================
+ Coverage 89.31% 89.32% +0.01%
==========================================
Files 165 165
Lines 5728 5734 +6
Branches 1738 1739 +1
==========================================
+ Hits 5116 5122 +6
Misses 379 379
Partials 233 233
Continue to review full report at Codecov.
|
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 a lot and sorry for the wait, just some minor comments from my side
src/Chunk.ts
Outdated
const name = renderNamePattern( | ||
options.entryFileNames || '[name].js', | ||
options.entryFileNames || | ||
(COMMON_JS_EXTENSIONS.includes(extension) ? '[name].js' : '[name].[ext].js'), |
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.
Not sure why the name is COMMON_JS...
as I do not see the connection. How about JAVASCRIPT_EXTENSION
or IGNORED_EXTENSIONS
? Also, I would rather have the default pattern to be [name][extname].js
, the reason being that otherwise, files without extension would have two subsequent .
in their name.
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.
JAVASCRIPT_EXTENSIONS
would work, just seemed a little bit inaccurate as it also includes TS extensions - i'm ok with renaming it though to whatever you see consider fitting here
Also, I would rather have the default pattern to be [name][extname].js
I've wanted to avoid output files being named like Buttonscss.js
, like - having some separator seems visually nice
files without extension would have two subsequent . in their name.
Gonna add some special handling for it + tests.
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.
I've wanted to avoid output files being named like Buttonscss.js, like - having some separator seems visually nice
Definitely, but the point of [extname]
vs [ext]
should be that [extname]
contains a leading .
if there is an extension and is an empty string otherwise. So it basically solves exactly this issue. So
filename | ext | extname | [name][extname].js |
[name].[ext].js |
---|---|---|---|---|
"test.css" |
"css" |
".css" |
"test.css.js" |
"test.css.js" |
"test" |
"" |
"" |
"test.js" |
"test..js" |
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.
i'm ok with renaming it though to whatever you see consider fitting here
How about NON_ASSET_EXTENSIONS
?
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.
Definitely, but the point of [extname] vs [ext] should be that [extname] contains a leading . if there is an extension and is an empty string otherwise.
Cool, didn't notice I could use it like this.
How about NON_ASSET_EXTENSIONS?
Sure, sounds good!
'output.entryFileNames', | ||
{ | ||
ext: () => extension.substr(1), | ||
extname: () => extension, |
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.
Would be nice to also have a test that directly uses the new pattern elements in entryFileNames
. Could also be an extension of an existing test.
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.
Sure, gonna tweak it.
@lukastaegert thanks for the review, gonna address your concerns in following days and ping you once I'm done with it. |
24fde1a
to
3560bfb
Compare
@lukastaegert I believe I've addressed all of your comment |
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 for addressing the issues, looks great!
This PR contains:
Are tests included?
Breaking Changes?
List any relevant issue numbers:
fixes #3107
Description
This adds support for
ext
andextname
replacements forentryFileNames
when usingpreserveModules
.Using this I include extname in output filenames for "scriptified" assets.