node-addon-loader icon indicating copy to clipboard operation
node-addon-loader copied to clipboard

Cannot read property 'nodeAddonLoader' of undefined

Open dvsekhvalnov opened this issue 6 years ago • 5 comments

Hi, attempted plugin on latest webpack 4.12.0.

Config:

module: {
    rules: [
      {
        test: /\.node$/,
        use: {
          loader: "node-addon-loader",
          options: {}          
        }
      }
    ]
  }

Failing with

Module build failed (from ./node_modules/node-addon-loader/index.js):
TypeError: Cannot read property 'nodeAddonLoader' of undefined
    at Object.module.exports (node_modules/node-addon-loader/index.js:16:29)

Sounds like some breaking changes in newest webpack?

dvsekhvalnov avatar Jun 14 '18 14:06 dvsekhvalnov

Quick googling shows that since webpack 4: this.options is going to be this._compiler.options

Don't know if you'd like to support both for backward compatibility.

dvsekhvalnov avatar Jun 14 '18 15:06 dvsekhvalnov

@dvsekhvalnov did you come right here using webpack 4.x?

shainegordon avatar Jul 18 '18 12:07 shainegordon

Hi @shainegordon , yeah see my message above. We just fixed package locally and it works correctly.

dvsekhvalnov avatar Jul 18 '18 16:07 dvsekhvalnov

@dvsekhvalnov can you create a pull request?

geraintwhite avatar Aug 09 '18 15:08 geraintwhite

Hi @grit96 , probably no:

  • we moved different direction without addon because hit the wall with dynamically linked dependencies from native module.
  • as i commented above our fix was only to make it work under webpack 4 while most likely sacrificing webpack 3 and below. So to make it right probably more work needed to support all webpack versions.

dvsekhvalnov avatar Aug 10 '18 10:08 dvsekhvalnov