@@ -6,6 +6,7 @@ var SourceMapConsumer = require("webpack-core/lib/source-map").SourceMapConsumer
66var SourceMapSource = require ( "webpack-core/lib/SourceMapSource" ) ;
77var RawSource = require ( "webpack-core/lib/RawSource" ) ;
88var RequestShortener = require ( "../RequestShortener" ) ;
9+ var ModuleFilenameHelpers = require ( "../ModuleFilenameHelpers" ) ;
910var uglify = require ( "uglify-js" ) ;
1011
1112function UglifyJsPlugin ( options ) {
@@ -19,7 +20,6 @@ module.exports = UglifyJsPlugin;
1920
2021UglifyJsPlugin . prototype . apply = function ( compiler ) {
2122 var options = this . options ;
22- var that = this ;
2323 options . test = options . test || / \. j s ( $ | \? ) / i;
2424
2525 var requestShortener = new RequestShortener ( compiler . context ) ;
@@ -40,7 +40,7 @@ UglifyJsPlugin.prototype.apply = function(compiler) {
4040 compilation . additionalChunkAssets . forEach ( function ( file ) {
4141 files . push ( file ) ;
4242 } ) ;
43- files = files . filter ( that . matchObject . bind ( that , options ) ) ;
43+ files = files . filter ( ModuleFilenameHelpers . matchObject . bind ( undefined , options ) ) ;
4444 files . forEach ( function ( file ) {
4545 var oldWarnFunction = uglify . AST_Node . warn_function ;
4646 var warnings = [ ] ;
@@ -133,30 +133,3 @@ UglifyJsPlugin.prototype.apply = function(compiler) {
133133 } ) ;
134134 } ) ;
135135} ;
136-
137- function asRegExp ( test ) {
138- if ( typeof test == "string" ) test = new RegExp ( "^" + test . replace ( / [ - [ \] { } ( ) * + ? . , \\ ^ $ | # \s ] / g, "\\$&" ) ) ;
139- return test ;
140- }
141-
142- UglifyJsPlugin . prototype . matchPart = function matchPart ( str , test ) {
143- if ( ! test ) return true ;
144- test = asRegExp ( test ) ;
145- if ( Array . isArray ( test ) ) {
146- return test . map ( asRegExp ) . filter ( function ( regExp ) {
147- return regExp . test ( str ) ;
148- } ) . length > 0 ;
149- } else {
150- return test . test ( str ) ;
151- }
152- } ;
153-
154- UglifyJsPlugin . prototype . matchObject = function matchObject ( obj , str ) {
155- if ( obj . test )
156- if ( ! this . matchPart ( str , obj . test ) ) return false ;
157- if ( obj . include )
158- if ( ! this . matchPart ( str , obj . include ) ) return false ;
159- if ( obj . exclude )
160- if ( this . matchPart ( str , obj . exclude ) ) return false ;
161- return true ;
162- } ;
0 commit comments