Commit Graph

3 Commits

Author SHA1 Message Date
Damien Arrachequesne
bec15240ea fix: properly export io in ES modules wrapper
The syntax was invalid:

```
export const io = io;
             ^

SyntaxError: Identifier 'io' has already been declared
    at Loader.moduleStrategy (internal/modules/esm/translators.js:122:18)
```
2020-11-19 00:56:25 +01:00
Damien Arrachequesne
7b3ec9fad9 fix: add io as named exports
The TypeScript (build/index.d.ts) and ES modules exports did not match,
which caused issues with webpack and ts-loader.

Related: https://github.com/socketio/socket.io-client/issues/1396
2020-11-17 23:54:56 +01:00
Damien Arrachequesne
cbabb0308e 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
2020-10-13 22:53:53 +02:00