-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Parcel 2: Default bundle namer #2424
Conversation
if (bundle.filePath) { | ||
// TODO: what about multiple assets in the same dep? | ||
// e.g. input is a Vue file, output is JS + CSS | ||
// which is defined as a target in package.json? |
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.
Any ideas how we could tell which one is the main one? Should we take the specified filename and just replace the extension with the bundle type?
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.
Yeah, I think that works.
return bundle.filePath; | ||
} | ||
|
||
// TODO: if split bundle, base name on original bundle names? |
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.
Any ideas on how to get the information on the original bundles that the split bundle originated from here? I'd rather not add a reference to the original bundles to the bundle object but that may be the only way...
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.
Only other way I could think of would be to pass in the bundleGraph along with the bundle to be named.
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.
That could possibly work. The split bundle will be connected to both original bundle groups, but there is currently no way to know which bundle connected to a bundle group was the original one...
let entryFilePath = entryAsset.filePath; | ||
let name = path.basename(entryFilePath, path.extname(entryFilePath)); | ||
|
||
// If this is an entry bundle, exclude the hash and use the original relative path. |
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.
What's the reasoning for this again?
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.
If you have index.html
as an entry point, you typically want to keep that name rather than adding a content hash. Otherwise the link would change every time you deploy. Same thing for things like service workers, where the URL can never change.
Here is the original RFC: #872
This implements bundle naming using namer plugins, and provides the default namer plugin for Parcel 2.
Closes #2240. Fixes #2140.
Summary of changes:
outputHash
property toAsset
which is computed at the end of the transformer pipeline. The currenthash
property is computed after the first transform and is used for caching. TheoutputHash
is used for content hashing.