-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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
"sideEffects": false
not working
#10253
Comments
The behavior of modules that are flagged as "without sideEffects" is:
The flag has no effect on statements in code. It's a module-level behavior. |
@sokra So is there any way to get webpack to dead code eliminate the |
That will also work in webpack. Only in production mode during minimizing |
@sokra You're right, however it does not work if I make a small change:
const result = /*#__PURE__*/myFunction({});
+const map = result.map; Output in production mode: })([
function(e, t, n) {
"use strict";
n.r(t);
(e => {
const t = {};
return "function" == typeof e.map && (t.map = () => {}), t;
})({}).map;
console.log(e => e);
}
]); Reduced test case: https://github.com/OliverJAsh/tree-shaking-test/tree/fp-ts-ord-rollup-custom-webpack-issue |
Yeah this works as expected
|
Note that even this code: r.map = () => {}; can potentially have side-effects when a setter is defined on |
Like this? -const map = result.map;
+const map = /*#__PURE__*/result.map; Sadly that seems to have no effect?
It's interesting that Rollup doesn't behave the same way 🤔 |
hmm, I think for But also seems like rollup is a little bit to smart here, so |
Any ideas on this? |
Maybe the If it doesn't help, it would be great if you reduce your issue to a small reproducible example. Best put this example into a github repository together with instructions how to get to the problem. |
Run Note the link is to the |
hmm... I looked up |
So there's no way to annotate |
const map = /*#__PURE__*/(() => result.map)(); |
This issue had no activity for at least three months. It's subject to automatic issue closing if there is no activity in the next 15 days. |
Issue was closed because of inactivity. If you think this is still a valid issue, please file a new issue with additional information. |
Bug report
What is the current behavior?
If the current behavior is a bug, please provide the steps to reproduce.
Now run
webpack
.What is the expected behavior?
When I run
webpack
, I expect themyFunction
call and body to removed (because I have specified"sideEffects": false
), however they are not. Excerpt below:For context, I originally discovered this whilst trying to import from an npm module:
import { max } from 'fp-ts/es6/Ord';
.Other relevant information:
webpack version: 4.39.2
Node.js version: 12.8.1
Operating System: N/A
Additional tools:
The text was updated successfully, but these errors were encountered: