Lurch
Lurch

Reputation: 137

Config for webpack expose-loader after upgrade to v1.0

The webpack.config.js line for exposing the Bluebird promise library in my (Aurelia) webapp is as follows:

module.exports = {
  module: {
    rules: [
      {
        test: /[\/\\]node_modules[\/\\]bluebird[\/\\].+\.js$/,
        loader: 'expose-loader?Promise'
      },
    ],
  },
};

I have since updated the expose-loader to v1.0. Now, after bundling, I get this error in the browser console:

Error: Module build failed (from ./node_modules/expose-loader/dist/cjs.js): ValidationError: Invalid options object. Expose Loader has been initialized using an options object that does not match the API schema.

  • options misses the property 'exposes'. Should be: non-empty string | object { globalName, moduleLocalName?, override? } | [non-empty string | object { globalName, moduleLocalName?, override? }, ...] (should not have fewer than 1 item)

How should the config be changed to reflect the new API?

Many thanks!

Upvotes: 3

Views: 3969

Answers (2)

Akaisteph7
Akaisteph7

Reputation: 6416

I was using AngularJS. From checking the console, Angular was suggesting installing angular-route. For whatever reason, that fixed the issue.

Upvotes: 0

tsoiland
tsoiland

Reputation: 101

I had the same problem upgrading.

This worked for me:

{
  test: /[\/\\]node_modules[\/\\]bluebird[\/\\].+\.js$/,
  loader: 'expose-loader',
  options: {
    exposes: {
      globalName: 'Promise',
      override: true
    },
  }
},

Based on the following example and a little guess work: https://www.npmjs.com/package/expose-loader

Upvotes: 6

Related Questions