-
-
Notifications
You must be signed in to change notification settings - Fork 594
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
fix(node-resolve): update side effects logic to be deep when glob doesn’t contain /
#1148
Conversation
👋 I’m wondering if this is this something we should do or should packages themselves already be including |
I've debated this as well. The disconnect for me is that, in my testing, nested files are included in I'll be honest and say I'm not sure if that alone is a good reason to change it. I couldn't find the official spec for I chose to start here because I use rollup more out of preference and am (slightly) more familiar with the codebase. I debated several possible fixes but in the end this one seemed simpliest |
Hmm yeh I think I’ve looked for a spec in the past and there might not be one :/ It’s a shame we aren’t already in line with the webpack/parcel implementations. Maybe this is something where we should add a flag like you proposed and in the next major version make it true by default to being us inline with the other bundlers? One concern I have with the flag at the moment is that it applies to everything, so you could end up with an annoying problem where one dependency needs it to be true to work and another only works with false. Maybe the chance of that is so unlikely it’s not worth worrying about though? |
I'm okay with making it the default behavior over time, I wanted to make sure it was a non-breaking change when introduced.
I hadn't even thought about that scenario. How could we address something like that? I don't want to add even more configuration but my first idea goes to another configuration item: // Brainstorming
// assuming it's default behavior in the future
const bundle = await rollup({
input: 'deep-side-effects/index.js',
onwarn: failOnWarn(t),
plugins: [
nodeResolve({
rootDir: 'deep-side-effects',
ignoreDeepEffectsForPackages: [/* list of packages to ignore the deep effects */]
})
]
}); |
Yeh that looks like it would work. Imo let’s not worry about it until someone needs it @shellscape do we have a way of keeping a list of defaults that may change in a future major version? If not maybe in the readme we could say there the default will become true in the future? On that topic please can you add this option to the readme? Other than that lgtm |
Whoops, good call. I added a brief description to the readme. Happy to edit the description or include an example if you think that would be beneficial. |
Looks good. Got another question though after thinking about this a bit more. If you have the following structure
and wanted Do you know if the other bundlers would support it being And if that's the case we should probably do the same and not add the |
I'm not sure. I'll experiment with how webpack handles it and use that to inform if we should add the |
@TheMcMurder I just found the webpack docs and they were more specific than I remembered.
https://webpack.js.org/guides/tree-shaking/ That last part is the key and what we should do I think, and then we don't need the extra option.
|
@tjenkinson fantastic! I'm really glad you found the docs that I failed to find because it enables a much cleaner solution. I updated the MR.
|
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.
Looks great. One 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.
Lgtm!
Rollup Plugin Name:
node-resolve
This PR contains:
Are tests included?
Breaking Changes?
If yes, then include "BREAKING CHANGES:" in the first commit message body, followed by a description of what is breaking.
List any relevant issue numbers:
Description
node-resolve doesn't include files from nested folders even when they match files in
sideEffects
.Example:
the side-effects of
other-file.js
will not be included becausepicomatch
only matches items in the root dir unless we change thesideEffects
block to include wildcards.This should fix this issue by doing a deep search when the glob does not contain a
/
. This matches the same behaviour as webpack.