YahooArchive / strip-loader

Webpack loader to strip arbitrary functions out of your production code.
Other
282 stars 14 forks source link

About require('debug')('MyFile'); #3

Closed gpbl closed 9 years ago

gpbl commented 9 years ago

Hi, thank you for this loader! Using the webpack's IgnorePlugin, debug’s inits like:

var debug = require('debug')('MyFile’);

cause a Cannot find module “debug” webpack error. I solved with the NormalModuleReplacementPlugin, however I wonder if there's a better way for it. Thanks!

new webpack.NormalModuleReplacementPlugin(/debug/, process.cwd() + '/emptyDebug.js'),
Vijar commented 9 years ago

Hey @gpbl, you're right.

I started work in a branch on trying to use the loader to potentially strip out the debug declaration as well, but that is turning out to be more difficult than I thought. I haven't had time but I want to play around with recast to see if that would help in finding and stripping the declarations.

Vijar commented 9 years ago

For now tough, feel free to do a docs PR for the README.

gpbl commented 9 years ago

Indeed recast looks like the right way :+1: