Skip to content

Commit ff5d5df

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

File tree

4 files changed

+793
-6
lines changed

4 files changed

+793
-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

+15-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,20 @@
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+
".": {
29+
"types": {
30+
"import": "./dist/index.d.mts",
31+
"require": "./dist/index.d.ts"
32+
},
33+
"import": "./dist/index.mjs",
34+
"require": "./dist/index.js"
35+
},
36+
"./package.json": "./package.json"
37+
},
38+
"main": "dist/index.js",
2839
"engines": {
2940
"node": ">=12.0.0"
3041
},
@@ -43,6 +54,7 @@
4354
"eslint-plugin-no-only-tests": "^3.1.0",
4455
"postcss": "^8.3.11",
4556
"prettier": "^2.6.2",
57+
"tsup": "^8.0.2",
4658
"typescript": "^5.4.2",
4759
"typescript-eslint": "^7.3.1",
4860
"vite": "^4.0.0",

0 commit comments

Comments
 (0)