You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reacted by Ed Morley, NoScripter, João Dias, April Mintac Pineda, coderaiser, Revelup Zilvinas Rudzionis, Andrius K, Andrii Oriekhov and Hasmasan Dragos
@sokra I think although there's no deep scope analysis strategy in webpack, by using ModuleConcaatenationPlugin and minifiers that supports dead code removal (e.g. UglifyJSPlugin), the same result can be achieved.
@chengluyu finally got around to trying this. What I found was that by applying all your changes except ModuleConcatenationPlugin, things still work as I wanted them. Which is nice. But I still wonder, how exactly did you expect the ModuleConcatenationPlugin to help us with this case? I admit I don't quite understand what that plugin does, so if you can dumb it down for me, great, if not, still great :}
@dmwyatt Thanks for following. My plugin has been released for a while, and I rarely receive bugs report. I don't know if it's really tested by the community even though I have a lot of unit tests. Because shaking wrong modules would make production code crash. I am worried.
@sokra Maybe I could submit a PR for integrating the plugin as an optional parameter, people can choose to use it.
I'm not sure how relevant this is but when using your example repo the production mode achieves the elimination of external2 based on the optimizations. So for development this is reproducable with enabling the corresponding optimizations: optimization: { providedExports: true, usedExports: true, concatenateModules: true }
Which actually results in the usage of beforementioned ModuleConcatenationPlugin.
Did I misunterstand something in your requirements, @Birowsky , or does this mean the problem is fixed in webpack 4?
@jschmuecking, thanx for that. I can confirm that just by switching mode to 'production' in the demo repo, the unused functions are being shaken off the emitted code, and that solves my original issue.
However, extra quality work was being done by @vincentdchan, so I'd like you to chip in.
@tomkel, you too had some meaningful input. Please confirm that this is closable.
Activity
EugeneHlushko commentedon Jan 14, 2018
While this might not be what you want, but i suggest trying webpack 4 which does not include that external2 thing.
Birowsky commentedon Jan 16, 2018
@EugeneHlushko tried compiling with:
Got:
sokra commentedon Jan 16, 2018
This doesn't work yet. We don't do this kind of scope analysis yet, but this is prepared in some places and could be added.
chengluyu commentedon Mar 23, 2018
By using
ModuleConcatenationPlugin, webpack does eliminateexternal2stuff correctly.Here's output from webpack 4 with
ModuleConcatenationPluginandUglifyJSPlugin: gist link.chengluyu commentedon Mar 23, 2018
@Birowsky You really should try out webpack 4 and
ModuleConcatenationPluginAnd don't forget to upgrade
ts-loaderto 4.x to avoid the errorCannot read property 'ts' of undefined.Or you can just try out my fork of your repo.
chengluyu commentedon Mar 23, 2018
@sokra I think although there's no deep scope analysis strategy in webpack, by using
ModuleConcaatenationPluginand minifiers that supports dead code removal (e.g.UglifyJSPlugin), the same result can be achieved.Birowsky commentedon Mar 24, 2018
@chengluyu hey mate, thanx for figuring it out. However, I don't see you using the
ModuleConcatenationPluginin your fork.chengluyu commentedon Mar 24, 2018
@Birowsky I forgot to push the commit. Updated here.
Birowsky commentedon Apr 2, 2018
@chengluyu finally got around to trying this. What I found was that by applying all your changes except
ModuleConcatenationPlugin, things still work as I wanted them. Which is nice. But I still wonder, how exactly did you expect theModuleConcatenationPluginto help us with this case? I admit I don't quite understand what that plugin does, so if you can dumb it down for me, great, if not, still great :}8 remaining items
Birowsky commentedon May 21, 2018
Sorry, I won't be able to have a look into this for the next couple of weeks.
dmwyatt commentedon Mar 10, 2019
Did anything ever come of this? Any plans to integrate @vincentdchan 's work?
vincentdchan commentedon Mar 11, 2019
@dmwyatt Thanks for following. My plugin has been released for a while, and I rarely receive bugs report. I don't know if it's really tested by the community even though I have a lot of unit tests. Because shaking wrong modules would make production code crash. I am worried.
@sokra Maybe I could submit a PR for integrating the plugin as an optional parameter, people can choose to use it.
webpack-bot commentedon Dec 3, 2019
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.
Birowsky commentedon Dec 3, 2019
Don't you dare.
jschmuecking commentedon Dec 20, 2019
I'm not sure how relevant this is but when using your example repo the
productionmode achieves the elimination of external2 based on the optimizations. So for development this is reproducable with enabling the corresponding optimizations:optimization: { providedExports: true, usedExports: true, concatenateModules: true }Which actually results in the usage of beforementioned
ModuleConcatenationPlugin.Did I misunterstand something in your requirements, @Birowsky , or does this mean the problem is fixed in webpack 4?
Birowsky commentedon Dec 30, 2019
@jschmuecking, thanx for that. I can confirm that just by switching
modeto'production'in the demo repo, the unused functions are being shaken off the emitted code, and that solves my original issue.However, extra quality work was being done by @vincentdchan, so I'd like you to chip in.
@tomkel, you too had some meaningful input. Please confirm that this is closable.
fregante commentedon Apr 12, 2020
A "Very Important" issue should not be marked "inactive."
Bad bot!
fregante commentedon Apr 12, 2020
Good boy
vankop commentedon Apr 12, 2020
Work done in
webpack@5. Provided example works with latest beta ([email protected]).I think this issue could be closed @evilebottnawi