-
-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Add support for more complex selectors for sideEffects #6074
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
Comments
webpack#6074 Slightly modifies `SideEffectsFlagPlugin` to consider the string `"false"` to be a valid input, whereas it previously only allowed for the boolean `false`.
I'm not quite sure how to architect the test case(s) for this issue. However, I am looking into existing tests to see if I can reuse anything. |
|
Oh, I may have completely misunderstood the issue, then. Am I just to implement the case where specifying a |
yep Array of string should be allowed too. It should support glob expressions too. "sideEffects": [
"src/**/*.js"
"./lib/abc.js"
] |
Got it - I'll work on that, and inquire further if I have any difficulties. |
I've been trying to decipher some segments of this particular Plugin instance, but I might be lacking some context. The first ambiguous thing in here (to me) is the usage of In any case, do I have access to the name of the module or the filename when |
https://github.com/webpack/webpack/blob/next/lib/optimize/SideEffectsFlagPlugin.js#L19
|
Oh, thanks for that. This will make things much easier. |
Apologies for the gap! Here's where I am at:
I need to make tests for:
I guess there might be some potential slowdown if there's a significantly larger |
Instead of using
|
Oh, interesting. I'd not thought of that. I'll convert it over accordingly! Quick question before I go too far: How complete should the conversion be? Are we only looking for |
Maybe just use https://github.com/fitzgen/glob-to-regexp |
Hi @CWelshE I want to know if you are still working on it ? |
@abiduzz420 I've got a PR that needs a modification to the glob feature. It's a pretty small change, but I'm not able to follow up on it right now. |
@reergymerej is there any notes you could provide to assist others? Happy to help find another contributor. |
The PR is #6334. I just needed to switch the library doing the glob checking to minimatch and update tests. The test structure is already there. It's should be as easy as changing the library in the source and the assertions to go along with those in the PR review notes. |
Hi, may I take up this issue and continue what @reergymerej has done? |
@jevan0307, please do. I pushed the work in progress I had. 2b45e65 |
I'm trying to use the tree shaking on 2 different bundles that imports different fn from the same code.
And 2 bundles 1 importing {square} and the other importing {cube} I was expecting to see the tree shake working but it happen to me that the both bundles contains the whole "share.js" exports. Am I doing something wrong? |
Maybe other options have a higher priority than this option .
//Bad
module.exports = {
devtool: 'inline-source-map'
}
//Good
const env = process.env.NODE_ENV;
module.exports = {
devtool: env == 'development' ? 'inline-source-map' : false,
}
{
"name": "parcel",
"sideEffects": false,
... ...
} |
Do you want to request a feature or report a bug?
Feature
What is the current behavior?
webpack searched for
"sideEffects": false
in package.json to perform the extra optimizations for esm modules. However iffalse
is a string, the optimization isn't detected.We should probably (in the case that package authors might mistake this as "false" vs
false
) put the wrong value in, and theres no simple way to detect (as a dev) why the 'deopt' occurs.If the current behavior is a bug, please provide the steps to reproduce.
What is the expected behavior?
"sideEffects": "false"
in package.json works the same as"sideEffects": false
If this is a feature request, what is motivation or use case for changing the behavior?
Motivation described above.
Please mention other relevant information such as the browser version, Node.js version, webpack version and Operating System.
webpack 4.0.0-alpha
The text was updated successfully, but these errors were encountered: