mirror of
https://github.com/socketio/socket.io.git
synced 2026-01-09 15:08:12 -05:00
fix: fix the ES module wrapper
The package does not have a default export, so importing it from a project using ES modules would break in some cases. > Cannot destructure property 'Server' of '_engineIo.default' Related: https://github.com/socketio/engine.io/issues/657
This commit is contained in:
6
examples/esm-import/README.md
Normal file
6
examples/esm-import/README.md
Normal file
@@ -0,0 +1,6 @@
|
||||
## How to use
|
||||
|
||||
```
|
||||
$ npm link ../..
|
||||
$ node index.js
|
||||
```
|
||||
3
examples/esm-import/index.js
Normal file
3
examples/esm-import/index.js
Normal file
@@ -0,0 +1,3 @@
|
||||
import { Server } from "engine.io";
|
||||
|
||||
console.log(Server);
|
||||
6
examples/esm-import/package.json
Normal file
6
examples/esm-import/package.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"name": "esm-import",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"type": "module"
|
||||
}
|
||||
@@ -62,8 +62,8 @@
|
||||
"test:compat-v3": "EIO_CLIENT=3 mocha --exit",
|
||||
"test:eiows": "EIO_WS_ENGINE=eiows mocha --exit",
|
||||
"test:uws": "EIO_WS_ENGINE=uws mocha --exit",
|
||||
"format:check": "prettier --check \"lib/**/*.ts\" \"test/**/*.js\"",
|
||||
"format:fix": "prettier --write \"lib/**/*.ts\" \"test/**/*.js\"",
|
||||
"format:check": "prettier --check \"wrapper.mjs\" \"lib/**/*.ts\" \"test/**/*.js\"",
|
||||
"format:fix": "prettier --write \"wrapper.mjs\" \"lib/**/*.ts\" \"test/**/*.js\"",
|
||||
"prepack": "npm run compile"
|
||||
},
|
||||
"repository": {
|
||||
|
||||
13
wrapper.mjs
13
wrapper.mjs
@@ -1,3 +1,10 @@
|
||||
import lib from "./build/engine.io.js";
|
||||
|
||||
export const { Server, Socket, Transport, transports, listen, attach, parser, protocol } = lib;
|
||||
export {
|
||||
Server,
|
||||
Socket,
|
||||
Transport,
|
||||
transports,
|
||||
listen,
|
||||
attach,
|
||||
parser,
|
||||
protocol,
|
||||
} from "./build/engine.io.js";
|
||||
|
||||
Reference in New Issue
Block a user