Skip to content

Commit

Permalink
Make this module esm only
Browse files Browse the repository at this point in the history
  • Loading branch information
perrin4869 committed Apr 30, 2022
1 parent 3daf0dd commit a4e0f34
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 67 deletions.
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
node_modules/
coverage/
dist/
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,3 @@ node_modules
npm-debug.log

.eslintcache

dist/
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ $ npm install --save socket.io-as-promised

```js
// server.js
const io = require('socket.io')();
const socketAsPromised = require('socket.io-as-promised');
import { Server } from 'socket.io';
import asPromised from 'socket.io-as-promised';

io.attach(5000);
const io = new Server(5000);

// on the main '/' namespare
io.use(socketAsPromised());

// on a custom namespace
io.of('/foo').use(socketAsPromised);
io.of('/foo').use(socketAsPromised());

io.on('connection', socket => {
// Client will get a response with the string 'returned a promise'
Expand Down
File renamed without changes.
25 changes: 0 additions & 25 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 4 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,21 @@
"version": "2.0.1",
"description": "Socket.IO middleware for supporting returning promises from handlers",
"type": "module",
"main": "dist/index.cjs",
"main": "/index.js",
"exports": {
".": {
"import": "./dist/index.js",
"require": "./dist/index.cjs"
},
".": "./index.js",
"./package.json": "./package.json"
},
"scripts": {
"lint": "eslint --cache .",
"build": "rollup -c",
"test": "mocha",
"cover": "c8 npm test",
"prepare": "npm run build"
"cover": "c8 npm test"
},
"engines": {
"node": ">=16.0.0"
},
"files": [
"dist"
"index.js"
],
"repository": {
"type": "git",
Expand Down Expand Up @@ -53,7 +48,6 @@
"eslint-plugin-node": "^11.1.0",
"mocha": "^9.2.2",
"p-event": "^5.0.1",
"rollup": "^2.70.2",
"socket.io": "^4.5.0",
"socket.io-client": "^4.5.0"
}
Expand Down
19 changes: 0 additions & 19 deletions rollup.config.js

This file was deleted.

6 changes: 0 additions & 6 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { createRequire } from 'module';
import { setTimeout } from 'timers/promises';
import { expect } from 'chai';
import io from 'socket.io-client';
Expand Down Expand Up @@ -96,9 +95,4 @@ describe('socket.io-as-promised', () => {
return expect(client.emitAsync('test')).to.eventually.be.rejected
.and.deep.equal({ name: 'Error', message: 'serialized error' });
});

it('should require cjs module', () => {
const require = createRequire(import.meta.url);
expect(require('..')).to.be.a('function');
});
});

0 comments on commit a4e0f34

Please sign in to comment.