webpack-contrib / imports-loader

Imports Loader
MIT License
520 stars 63 forks source link

when config 'imports-loader?this=>window' throw "options has an unknown property 'this'" #91

Closed lhsaq2009 closed 3 years ago

lhsaq2009 commented 3 years ago

Recently, I study webpack via https://webpack.js.org/guides/shimming/#granular-shimming.

Below code is my part of webPack config:

{
    test: require.resolve('./src/index.js'),
    use: 'imports-loader?this=>window',
},

when run webpack cmd,there will log exception :

ERROR in ./src/index.js
Module build failed (from ./node_modules/imports-loader/dist/cjs.js):
ValidationError: Invalid options object. Imports Loader has been initialized using an options object that does not match the API schema.
 - options should be one of these:
   object { imports, … } | object { wrapper, … } | object { additionalCode, … }
   Details:
    * options has an unknown property 'this'. These properties are valid:
      object { imports, … } | object { wrapper, … } | object { additionalCode, … }
    * options misses the property 'imports' | should be any non-object.
    * options misses the property 'wrapper' | should be any non-object.
    * options misses the property 'additionalCode' | should be any non-object.

thx!

alexander-akait commented 3 years ago

Docs it outdated, please use readma, we will update them in near future

alexander-akait commented 3 years ago

https://github.com/webpack/webpack.js.org/issues/3797