Skip to content

Commit 237399a

Browse files
committed
Move to ESM
1 parent ffc8492 commit 237399a

File tree

5 files changed

+1044
-1126
lines changed

5 files changed

+1044
-1126
lines changed

.github/workflows/test.yml

+3-4
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ env:
66
FORCE_COLOR: 2
77
jobs:
88
full:
9-
name: Node.js 15 Full
9+
name: Node.js 16 Full
1010
runs-on: ubuntu-latest
1111
steps:
1212
- name: Checkout the repository
1313
uses: actions/checkout@v2
1414
- name: Install Node.js
1515
uses: actions/setup-node@v2
1616
with:
17-
node-version: 15
17+
node-version: 16
1818
- name: Install dependencies
1919
uses: bahmutov/npm-install@v1
2020
- name: Run tests
@@ -26,7 +26,6 @@ jobs:
2626
node-version:
2727
- 14
2828
- 12
29-
- 10
3029
name: Node.js ${{ matrix.node-version }} Quick
3130
steps:
3231
- name: Checkout the repository
@@ -38,4 +37,4 @@ jobs:
3837
- name: Install dependencies
3938
uses: bahmutov/npm-install@v1
4039
- name: Run unit tests
41-
run: npx jest
40+
run: node --experimental-vm-modules node_modules/.bin/jest

index.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
let createNanoEvents = () => ({
1+
export let createNanoEvents = () => ({
22
events: {},
33
emit(event, ...args) {
44
;(this.events[event] || []).forEach(i => i(...args))
@@ -9,5 +9,3 @@ let createNanoEvents = () => ({
99
(this.events[event] = (this.events[event] || []).filter(i => i !== cb))
1010
}
1111
})
12-
13-
module.exports = { createNanoEvents }

package.json

+30-21
Original file line numberDiff line numberDiff line change
@@ -14,42 +14,46 @@
1414
"subscribe"
1515
],
1616
"scripts": {
17-
"test": "jest --coverage && eslint . && check-dts && size-limit && yaspeller *.md"
17+
"test": "node --experimental-vm-modules node_modules/.bin/jest --coverage && eslint . && check-dts && size-limit && yaspeller *.md"
1818
},
1919
"author": "Andrey Sitnik <[email protected]>",
2020
"license": "MIT",
2121
"repository": "ai/nanoevents",
2222
"engines": {
23-
"node": ">=6.0.0"
23+
"node": "^12.0.0 || ^14.0.0 || >=16.0.0"
2424
},
2525
"sideEffects": false,
26+
"type": "module",
2627
"types": "./index.d.ts",
28+
"exports": {
29+
".": "./index.js"
30+
},
2731
"devDependencies": {
28-
"@logux/eslint-config": "^45.2.0",
29-
"@logux/sharec-config": "^0.9.0",
30-
"@size-limit/dual-publish": "^4.10.1",
31-
"@size-limit/preset-small-lib": "^4.10.1",
32-
"@types/jest": "^26.0.20",
33-
"@typescript-eslint/eslint-plugin": "^4.17.0",
34-
"@typescript-eslint/parser": "^4.17.0",
32+
"@babel/core": "^7.13.16",
33+
"@logux/eslint-config": "^45.3.0",
34+
"@logux/sharec-config": "^0.10.1",
35+
"@size-limit/preset-small-lib": "^4.10.2",
36+
"@types/jest": "^26.0.22",
37+
"@typescript-eslint/eslint-plugin": "^4.22.0",
38+
"@typescript-eslint/parser": "^4.22.0",
3539
"check-dts": "^0.4.4",
36-
"dual-publish": "^1.0.5",
37-
"eslint": "^7.22.0",
40+
"clean-publish": "^2.1.1",
41+
"eslint": "^7.25.0",
3842
"eslint-config-standard": "^16.0.2",
3943
"eslint-plugin-import": "^2.22.1",
40-
"eslint-plugin-jest": "^24.3.1",
44+
"eslint-plugin-jest": "^24.3.5",
4145
"eslint-plugin-node": "^11.1.0",
4246
"eslint-plugin-prefer-let": "^1.1.0",
43-
"eslint-plugin-promise": "^4.3.1",
47+
"eslint-plugin-promise": "^5.1.0",
4448
"eslint-plugin-security": "^1.4.0",
45-
"eslint-plugin-unicorn": "^28.0.2",
46-
"jest": "^26.6.3",
49+
"eslint-plugin-unicorn": "^31.0.0",
50+
"jest": "^27.0.0-next.8",
4751
"lint-staged": "^10.5.4",
4852
"prettier": "^2.2.1",
49-
"simple-git-hooks": "^2.0.3",
50-
"size-limit": "^4.10.1",
51-
"ts-jest": "^26.5.3",
52-
"typescript": "^4.2.3",
53+
"simple-git-hooks": "^2.4.1",
54+
"size-limit": "^4.10.2",
55+
"ts-jest": "^27.0.0-next.11",
56+
"typescript": "^4.2.4",
5357
"yaspeller": "^7.0.0"
5458
},
5559
"size-limit": [
@@ -59,7 +63,12 @@
5963
}
6064
],
6165
"jest": {
62-
"preset": "ts-jest",
66+
"preset": "ts-jest/presets/default-esm",
67+
"globals": {
68+
"ts-jest": {
69+
"useESM": true
70+
}
71+
},
6372
"testEnvironment": "node",
6473
"coverageThreshold": {
6574
"global": {
@@ -122,6 +131,6 @@
122131
},
123132
"sharec": {
124133
"config": "@logux/sharec-config",
125-
"version": "0.9.0"
134+
"version": "0.10.1"
126135
}
127136
}

tsconfig.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
{
22
"compilerOptions": {
33
"target": "es2018",
4-
"module": "commonjs",
4+
"module": "esnext",
5+
"moduleResolution": "node",
6+
"esModuleInterop": true,
57
"allowJs": true,
68
"strict": true,
79
"noEmit": true

0 commit comments

Comments
 (0)