module.noParse with Array of RegExp no longer works

I’m submitting a bug report

Webpack version:
2.1.0-beta.24 – 26

Please tell us about your environment:
OSX Sierra 10.12.1

Current behavior:
module.noParse no longer accepts array of RegExp, but spits out an error stating it should either be RegExp or [RegExp]:

Invalid configuration object. Webpack has been initialised using a configuration object that does not match the 
API schema.                                                                                                     
 - configuration.module.noParse should be one of these:                                                         
   [RegExp] | RegExp                                                                                            
   Don't parse files matching. It's matched against the full resolved request.

Expected/desired behavior:
That it should work as it did in -beta.22 and down.

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem along with a gist/jsbin of your webpack configuration.
    I’m dynamically adding vendor scripts and noParse entries, but it has worked up until now:
const vendorDictionary = {
    'jquery': join(nodeModulesRoot, 'jquery', 'dist', 'jquery.min.js'),
    'angular': join(nodeModulesRoot, 'angular', 'angular.min.js'),
    '@scholastic/reader': join(nodeModulesRoot, '@scholastic', 'ereader', 'dist', 'bundle.reader.js')
};

// condensed to only include what is necessary...
let config = {
    resolve: {
        alias: {}
    }
    entry: {
        vendorJs: []
    }
    module: {
        noParse: []
    }
}

function addVendor(name, vendorPath) {
    config.resolve.alias[name] = vendorPath;
    // using noParse for build perf gains
    config.module.noParse.push(new RegExp(vendorPath));
    if (config.entry.vendorJs.indexOf(name) === -1) {
        config.entry.vendorJs.push(name);
    }
}

Object.keys(vendorDictionary).forEach(v => addVendor(v, vendorDictionary[v]));
  • Language: ES6 w/ babel-loader

Author: Fantashit

1 thought on “module.noParse with Array of RegExp no longer works

Comments are closed.