Skip to content

Commit cbabb03

Browse files
feat: add ES6 module export
- with `{ "type": "commonjs" }` in the package.json file ```js const io = require("socket.io-client"); const socket = io("/"); ``` - with `{ "type": "module" }` ```js import io from "socket.io-client"; const socket = io("/"); // or import { Manager } from "socket.io-client"; const manager = new Manager(); const socket = manager.socket("/"); ``` Related: https://nodejs.org/api/packages.html#packages_dual_commonjs_es_module_packages
1 parent e826992 commit cbabb03

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,17 @@
1313
"dist/",
1414
"build/"
1515
],
16+
"type": "commonjs",
1617
"main": "./build/index.js",
18+
"exports": {
19+
"./package.json": "./package.json",
20+
"./dist/socket.io.js": "./dist/socket.io.js",
21+
"./dist/socket.io.js.map": "./dist/socket.io.js.map",
22+
".": {
23+
"import": "./wrapper.mjs",
24+
"require": "./build/index.js"
25+
}
26+
},
1727
"types": "./build/index.d.ts",
1828
"dependencies": {
1929
"backo2": "1.0.2",

wrapper.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import io from "./build/index.js";
2+
3+
export const Manager = io.Manager;
4+
export default io;

0 commit comments

Comments
 (0)