pladaria / reconnecting-websocket

Reconnecting WebSocket. For Web, React Native, cli (Node.js)
MIT License
1.22k stars 197 forks source link

Webpack? #41

Closed jfuehner closed 6 years ago

jfuehner commented 6 years ago

How can I use this library with webpack? Using this doens't work...

import ReconnectingWebsocket from 'reconnecting-websocket'

syuilo commented 6 years ago

try:

const ReconnectingWebSocket = require('reconnecting-websocket');
jfuehner commented 6 years ago

Sorry, I should of been more clear. The require syntax works with Webpack but, I want to use the import syntax for this library.

const ReconnectingWebSocket = require('reconnecting-websocket'); <-- this works

import ReconnectingWebsocket from 'reconnecting-websocket <-- this doesn't

syuilo commented 6 years ago

Hmm, another idea came up:

import * as ReconnectingWebsocket from 'reconnecting-websocket';
syuilo commented 6 years ago

or

import ReconnectingWebsocket = require('reconnecting-websocket');
jfuehner commented 6 years ago

Hmm... Doing this, import * as ReconnectingWebsocket from 'reconnecting-websocket' ReconnectingWebsocket comes back as undefined.

syuilo commented 6 years ago

I cannot reproduce it... import * as ReconnectingWebsocket from 'reconnecting-websocket'; is works well. Make sure there are no misspellings (eg 's' is not uppercase 'S')

jfuehner commented 6 years ago

Was there perhaps something you had to configure in your webpack config to get the import syntax to work?

syuilo commented 6 years ago

I think that there is no settings. Just to be sure, can you tell me the version of your webpack?

pladaria commented 6 years ago

@jfuehner are you importing the library into javascript or typescript?

jfuehner commented 6 years ago

@pladaria I'm importing into javascript using webpack v2.6.1

pladaria commented 6 years ago

@jfuehner we are using this module with webpack since webpack 1.x without any issues. Please, create a repo with the steps to reproduce and then feel free to reopen this issue.