chentsulin / webpack-target-electron-renderer

webpack target function for electron renderer
MIT License
115 stars 12 forks source link

Socket.io-client integration #18

Open soupman99 opened 7 years ago

soupman99 commented 7 years ago

In the process of building a chat app with your package & socket.io-client.

Everything works great until I install socket.io-client and then webpack can't complete the build anymore. The error I get is:

/Users/..../Documents/mouseTracker2/_tests/v3/node_modules/webpack-target-electron-renderer/node_modules/webpack/lib/ExternalModuleFactoryPlugin.js:37
                                        if(externals === dependency.request) {
                                                                   ^
TypeError: Cannot read property 'request' of undefined

Any idea of what's going on? I tried installing the types for socket.io-client with no luck. Is this a webpack-target-electron-renderer issue or a typescript issue.

Thanks in advance for your help.

chentsulin commented 7 years ago

Could you add a console.log before this line for externals and dependency add show me the result?

adamkirkwood commented 7 years ago

I'm also encountering a similar TypeError:

TypeError: Cannot read property 'request' of undefined
    at handleExternals (/Users/adam/workbench/sketchpacks-client/node_modules/webpack-target-electron-renderer/node_modules/webpack/lib/ExternalModuleFactoryPlugin.js:37:33)
    at next (/Users/adam/workbench/sketchpacks-client/node_modules/webpack-target-electron-renderer/node_modules/webpack/lib/ExternalModuleFactoryPlugin.js:46:8)
    at handleExternals (/Users/adam/workbench/sketchpacks-client/node_modules/webpack-target-electron-renderer/node_modules/webpack/lib/ExternalModuleFactoryPlugin.js:59:7)
    at ExternalModuleFactoryPlugin.<anonymous> (/Users/adam/workbench/sketchpacks-client/node_modules/webpack-target-electron-renderer/node_modules/webpack/lib/ExternalModuleFactoryPlugin.js:79:5)
    at /Users/adam/workbench/sketchpacks-client/node_modules/webpack/lib/NormalModuleFactory.js:222:3
    at NormalModuleFactory.applyPluginsAsyncWaterfall (/Users/adam/workbench/sketchpacks-client/node_modules/tapable/lib/Tapable.js:160:70)
    at NormalModuleFactory.create (/Users/adam/workbench/sketchpacks-client/node_modules/webpack/lib/NormalModuleFactory.js:206:8)
    at async.forEach._this (/Users/adam/workbench/sketchpacks-client/node_modules/webpack/lib/Compilation.js:212:11)
    at /Users/adam/workbench/sketchpacks-client/node_modules/webpack/node_modules/async/dist/async.js:3025:16
    at eachOfArrayLike (/Users/adam/workbench/sketchpacks-client/node_modules/webpack/node_modules/async/dist/async.js:941:9)
    at eachOf (/Users/adam/workbench/sketchpacks-client/node_modules/webpack/node_modules/async/dist/async.js:991:5)
    at Object.eachLimit (/Users/adam/workbench/sketchpacks-client/node_modules/webpack/node_modules/async/dist/async.js:3089:3)
    at Compilation.addModuleDependencies (/Users/adam/workbench/sketchpacks-client/node_modules/webpack/lib/Compilation.js:193:8)
    at Compilation.processModuleDependencies (/Users/adam/workbench/sketchpacks-client/node_modules/webpack/lib/Compilation.js:178:7)
    at Compilation.moduleReady (/Users/adam/workbench/sketchpacks-client/node_modules/webpack/lib/Compilation.js:419:9)
    at Compilation.<anonymous> (/Users/adam/workbench/sketchpacks-client/node_modules/webpack/lib/Compilation.js:415:16)

Here's what console.log outputted for me:

{
  entry: [
    'react-hot-loader/patch',
    'webpack-dev-server/client?http://localhost:8080/',
    'webpack/hot/only-dev-server',
    './index.js'
  ],
  output: {
    filename: '[name].js',
    path: '/Users/adam/workbench/[REDACTED]/app/dist',
    publicPath: '/'
  },
  context: '/Users/adam/workbench/[REDACTED]/app',
  devtool: 'source-map',
  devServer: {
    hot: true,
    contentBase: '/Users/adam/workbench/[REDACTED]/app/dist',
    publicPath: 'http://localhost:8080/',
    historyApiFallback: true
  },
  module: {
    rules: [
      [
        Object
      ],
      [
        Object
      ]
    ]
  },
  plugins: [
    NamedModulesPlugin{
      options: {

      }
    },
    HotModuleReplacementPlugin{
      multiStep: undefined,
      fullBuildTimeout: 200
    },
    HtmlWebpackPlugin{
      options: [
        Object
      ]
    }
  ],
  resolve: {
    extensions: [
      '.js',
      '.scss'
    ]
  },
  target: [
    Function: webpackTargetElectronRenderer
  ]
}
set321go commented 7 years ago
start pack...
externals:desktop-capturer
dependency:undefined
/Users/Documents/3rdparty/graphql-ide/node_modules/webpack-target-electron-renderer/node_modules/webpack/lib/ExternalModuleFactoryPlugin.js:39
                    if(externals === dependency.request) {
                                               ^

TypeError: Cannot read property 'request' of undefined
set321go commented 7 years ago

This is a webpack version issue. I am trying to upgrade a project to webpack 2.2.1 if I upgrade the webpack project version for this project the problem goes away.

npm install --save webpack@2.2.1
npm test
npm run lint
npm link
npm link webpack-target-electron-renderer

Now builds without errors

domhauton commented 7 years ago

I have the same error - upgrading to webpack@2.2.1 did not solve it.

chentsulin commented 7 years ago

webpack 2 has built-in support for electron, so you should never use this module with webpack 2.

set321go commented 7 years ago

oh cool I didn't know that. will try without it thanks