istarkov / babel-plugin-webpack-loaders

babel 6 plugin which allows to use webpack loaders
623 stars 43 forks source link

Some webpack plugins are not run #362

Open autra opened 7 years ago

autra commented 7 years ago

Description

Some webpack plugin are not used at all when using this plugin. For instance, definePlugin and uglifyJsPlugin don't seem to affect files.

My use case: together, they can perform some dead code elimination on if (DEBUG) statement, allowing me to have a bundle without debug stuff. However, I'm also transpiling each file individually, and those still have the if (__DEBUG__) statements in them.

Reproducing steps

Expected results

The last command yields no result

Actual results

The last command still shows some __DEBUG__ instance in my transpiled code.

autra commented 7 years ago

Oups clicked on submit too soon. I'm editing the description.

autra commented 7 years ago

So these plugins seems to run in some lifecycle steps of webpack not reached by this plugin. Is there any workaround or possibility to have them nonetheless?

autra commented 7 years ago

Ok after digging a bit more: plugins are indeed run, but not on the file I think. Every individual js files are directly processed by babel, thus they don't go through webpack loaders. Only other files (in my case, glsl files for instance) are going through the webpack loading process, and then through plugins.

I'm actually not sure if this bug is still valid. It'd be nice if this plugin could load everything through webpack though.