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

Is it possible to use this library with webpack? #5

Open
Krasnov8953 opened this issue May 28, 2020 · 5 comments
Open

Is it possible to use this library with webpack? #5

Krasnov8953 opened this issue May 28, 2020 · 5 comments

Comments

@Krasnov8953
Copy link

Krasnov8953 commented May 28, 2020

I have an error wile importing lib like this in angular 9 project
import * as io from 'socketio-shared-webworker';
or
const wio = require('socketio-shared-webworker');

Module parse failed: Unexpected token (9:15)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| class SharedWorkerSocketIO {
|
>     WorkerType = global.SharedWorker || global.Worker
|     worker = null
|     workerUri = null
i 「wdm」: Failed to compile.
@baluhman
Copy link

Same problem too! Any idea?

@arily
Copy link

arily commented Oct 24, 2020

hi, this problem is caused by exporting /src/ instead of /dist/ library, which is using ES7 syntax.
edit index.js change './src/socket.io-worker' to './dist/socket.io-worker' will solve this problem

require('socketio-shared-webworker') // returns {} idk y
const io = global.wio

@warrenspe
Copy link

Hi there!

I'm afraid I'm not quite understanding how to use this library with ES6 syntax; would anyone happen to have an example using import?

I've tried a few variations of the below, but I can't seem to make anything stick
import * as wio from 'socketio-shared-webworker/dist/socket.io-worker';

@fijiwebdesign
Copy link
Contributor

You can use this with babel but you'll need to enable the babel plugin https://babeljs.io/docs/en/babel-plugin-proposal-class-properties

Here is the .babelrc file used by the project:

{
  "presets": ["@babel/preset-env"],
  "plugins": ["@babel/plugin-proposal-class-properties"]
}

@vickyMeheraj
Copy link

vickyMeheraj commented Apr 10, 2023

How can I use it in the next.js project...
TypeError: socketio_shared_webworker__WEBPACK_IMPORTED_MODULE_2___default(...) is not a function

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

6 participants