Skip to content

Commit 2e6b7e5

Browse files
committed
fix: rename esm to .mjs and add exports
1 parent b690693 commit 2e6b7e5

2 files changed

Lines changed: 23 additions & 4 deletions

File tree

package.json

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,29 @@
22
"name": "permitio",
33
"version": "2.5.2",
44
"description": "Node.js client library for the Permit.io full-stack permissions platform",
5+
"type": "commonjs",
56
"main": "build/main/index.js",
67
"typings": "build/main/index.d.ts",
7-
"module": "build/module/index.js",
8-
"repository": "https://github.com/permitio/permit-node",
8+
"module": "build/module/index.mjs",
9+
"exports": {
10+
".": {
11+
"types": "./build/module/index.d.ts",
12+
"import": "./build/module/index.mjs",
13+
"require": "./build/main/index.js"
14+
},
15+
"./build/main/*": "./build/main/*",
16+
"./build/module/*": "./build/module/*"
17+
},
18+
"repository": {
19+
"type": "git",
20+
"url": "git+https://github.com/permitio/permit-node.git"
21+
},
922
"license": "MIT",
1023
"keywords": [],
1124
"scripts": {
1225
"build": "run-p build:*",
1326
"build:main": "tsc -p tsconfig.json",
14-
"build:module": "tsc -p tsconfig.module.json",
27+
"build:module": "tsc -p tsconfig.module.json && yarn rename:esm",
1528
"fix": "run-s fix:*",
1629
"fix:prettier": "prettier --config .prettierrc \"src/**/*.{ts,css,less,scss,js}\" --write",
1730
"fix:lint": "eslint src --ext .ts --fix",
@@ -33,6 +46,7 @@
3346
"docs": "typedoc",
3447
"docs:watch": "typedoc --watch",
3548
"version": "2.5.2",
49+
"rename:esm": "/bin/zsh ./scripts/rename-mjs.sh",
3650
"reset-hard": "git clean -dfx && git reset --hard && yarn",
3751
"prepare": "npm run build && husky install",
3852
"prepare-release": "run-s reset-hard test cov:check doc:html version doc:publish",
@@ -119,5 +133,6 @@
119133
"exclude": [
120134
"**/*.spec.js"
121135
]
122-
}
136+
},
137+
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
123138
}

scripts/rename-mjs.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
for file in ./build/module/**/*.js; do
2+
sed -i '' "s/\.js'/\.mjs'/g" "$file"
3+
mv "$file" "${file%.js}.mjs"
4+
done

0 commit comments

Comments
 (0)