Skip to content

Commit

Permalink
fix: fix the ES module wrapper
Browse files Browse the repository at this point in the history
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: #657
  • Loading branch information
darrachequesne committed Jan 10, 2023
1 parent bc98bf1 commit ed87609
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 5 deletions.
6 changes: 6 additions & 0 deletions examples/esm-import/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## How to use

```
$ npm link ../..
$ node index.js
```
3 changes: 3 additions & 0 deletions examples/esm-import/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { Server } from "engine.io";

console.log(Server);
6 changes: 6 additions & 0 deletions examples/esm-import/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "esm-import",
"version": "0.0.1",
"private": true,
"type": "module"
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
13 changes: 10 additions & 3 deletions wrapper.mjs
Original file line number Diff line number Diff line change
@@ -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";

0 comments on commit ed87609

Please sign in to comment.