Support array in package.json's sideEffects property#1766
Conversation
There was a problem hiding this comment.
Because findPackage() will add a pkgdir property to the package, which is needed later for globbing the sideEffects array entries.
There was a problem hiding this comment.
You can use path.normalize(sideEffects) instead of manually checking for windows and using replace
Oh, you're doing the opposite, nevermind
There was a problem hiding this comment.
Thinking again, this is not necessary at all. "sideEffects": ["foo\\bar.js"] is not supported in package.json anyway.
There was a problem hiding this comment.
You can save some I/O and async overhead by setting pkgdir in cacheData preemptively in hoist.js like we do for sideEffects :
parcel/src/scope-hoisting/hoist.js
Lines 34 to 38 in 7423541
There was a problem hiding this comment.
nit: defaulting sideEffects using {sideEffects} = asset.cacheData could make the if conditions using it cleaner (await hasSideEffects(asset))
d7ccd48 to
69859fb
Compare
|
@fathyb Thanks for the review. I have addressed all your comments. |
There was a problem hiding this comment.
this function could probably go in hoist.js. That way asset.cacheData.sideEffects could always be a boolean computed using this function. Might be slightly faster, especially since we can cache the results.
There was a problem hiding this comment.
I actually liked your original solution using the resolver. This one will result in two lookups.
69859fb to
870edf7
Compare
|
Thanks @devongovett for your review. I have addressed your comments as well now. |
fathyb
left a comment
There was a problem hiding this comment.
LGTM, thanks for working on this 👍
This pull request implements array support for the
package.json'ssideEffectsproperty, like webpack does. Example:Fixes #1566.