Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webpack setup throwing "ReferenceError: Worker is not defined" #119

Open
johnstew opened this issue Sep 11, 2018 · 3 comments
Open

Webpack setup throwing "ReferenceError: Worker is not defined" #119

johnstew opened this issue Sep 11, 2018 · 3 comments

Comments

@johnstew
Copy link

Hi there,

I was able to get this working when dropping clooney onto a basic index.html page then running a script beneath it but went to set this up with Webpack and ran into an issue with Worker not being defined. This issue seems more in Webpack territory but figured I'd ask here to see if there is anything in particular that needs to be done in a Webpack config for this.

Example project: https://github.com/johnstew/clooney-demo

Thanks!

@surma
Copy link
Contributor

surma commented Sep 19, 2018

Sorry for the late reply.

First of: 10 points to you for a demo repository!

But it compiles and runs just fine for me. Did you fix it or is it still broken for you?

@johnstew
Copy link
Author

Hmm, I'll try again this morning. Thanks for taking a look!

@johnstew
Copy link
Author

I recloned it and it looks like I'm still getting the error.

screen shot 2018-09-20 at 1 05 11 pm

Here is how I'm using it:

import { spawn } from 'clooney';

(async function() {
  class MyRemoteClass {
    doExpensiveCalculation(a, b) {
      return a + b;
    }
  }

  const instance = await spawn(MyRemoteClass);
  console.log(await instance.doExpensiveCalculation(5, 23));
})();

and my webpack config:

const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
  entry: {
    index: path.resolve(__dirname, './src/index')
  },
  output: {
    path: path.resolve(__dirname, './dist'),
    filename: 'index.bundle.js',
    globalObject: 'this'
  },
  plugins: [new HtmlWebpackPlugin()]
};

It seems it runs and returns the result as 28 but still see the error.

Also I'm running webpack with this command:

webpack-dev-server --mode development --port 5001 --config ./webpack.config.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants