YahooArchive / strip-loader

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

No stripping occurs if no trailing semicolon #14

Open adriano-di-giovanni opened 7 years ago

adriano-di-giovanni commented 7 years ago

Given this code

aver.isRuleProvider()
aver.isStateProvider()

no stripping occurs for the second line because there's no trailing semicolon

Please, find the regexpPattern that your plugin uses

var regexpPattern = /(?:^|\n)[ \t]*(aver\.isRuleProvider|aver\.isStateProvider)\(((\"[^\"]*\")|(\'[^\']*\')|[^\);]|\([^\);]*\))*\)[ \t]*(?:$|[;\n])/g
sbstnmsch-zz commented 7 years ago

+1

4-1-1 commented 7 years ago

+1

weishiji commented 7 years ago

+1

fabd commented 7 years ago

+1 (tested the change and confirmed it fixes the issue)

As an aside, is this the correct use in webpack2 ?

  // add after the babel-loader rule...
      {
        // strip debug code
        test:    /\.js$/,
        loader:  "strip-loader?strip[]=console.log",
        exclude: /node_modules/,
      },

I was worried it would mess with Vue, but I assume the "exclude" makes it so this loader does not apply to the vue library files.