Skip to content

Commit 8050021

Browse files
committed
Dual-package CJS & ESM
1 parent 6f9f857 commit 8050021

File tree

4 files changed

+790
-6
lines changed

4 files changed

+790
-6
lines changed

.gitignore

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@ yarn-error.log
55
coverage/
66

77
# build products
8-
index.js
9-
index.d.ts
8+
dist/*

eslint.config.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default tseslint.config(
1414
eslint.configs.recommended,
1515
...tseslint.configs.recommended,
1616
{
17-
ignores: ["coverage/*", "index.js", "index.test.mjs", "index.d.ts"],
17+
ignores: ["coverage/*", "dist"],
1818
},
1919
{
2020
languageOptions: {

package.json

+12-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"postcss-assign-layer"
1010
],
1111
"scripts": {
12-
"build": "tsc -p tsconfig.json",
12+
"build": "tsup src/index.ts --format esm,cjs --dts",
1313
"test": "vitest run --coverage && eslint .",
1414
"test:watch": "vitest",
1515
"prepublishOnly": "pnpm build && pnpm test"
@@ -22,9 +22,17 @@
2222
},
2323
"homepage": "https://github.com/DefinedNet/postcss-assign-layer#readme",
2424
"files": [
25-
"index.js",
26-
"index.d.ts"
25+
"dist"
2726
],
27+
"exports": {
28+
"types": {
29+
"import": "./dist/index.d.mts",
30+
"require": "./dist/index.d.ts"
31+
},
32+
"import": "./dist/index.mjs",
33+
"require": "./dist/index.js"
34+
},
35+
"main": "dist/index.js",
2836
"engines": {
2937
"node": ">=12.0.0"
3038
},
@@ -43,6 +51,7 @@
4351
"eslint-plugin-no-only-tests": "^3.1.0",
4452
"postcss": "^8.3.11",
4553
"prettier": "^2.6.2",
54+
"tsup": "^8.0.2",
4655
"typescript": "^5.4.2",
4756
"typescript-eslint": "^7.3.1",
4857
"vite": "^4.0.0",

0 commit comments

Comments
 (0)