Skip to content

Commit 46d6e97

Browse files
committed
feat: emit esm and cjs exports.
1 parent fbafc7f commit 46d6e97

File tree

5 files changed

+30
-6
lines changed

5 files changed

+30
-6
lines changed

package.json

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "1.0.2",
44
"author": "Alex Miller <[email protected]>",
55
"description": "Execute a given command after a bundle has been written",
6+
"type": "module",
67
"homepage": "https://github.com/Codex-/rollup-plugin-conditional-exec#readme",
78
"repository": {
89
"type": "git",
@@ -18,10 +19,22 @@
1819
"conditional-exec",
1920
"exec"
2021
],
21-
"main": "dist/index.js",
22-
"types": "dist/index.d.ts",
22+
"main": "dist/cjs/index.js",
23+
"types": "dist/cjs/index.d.ts",
24+
"exports": {
25+
".": {
26+
"import": {
27+
"types": "./dist/esm/index.d.ts",
28+
"default": "./dist/esm/index.js"
29+
},
30+
"require": {
31+
"types": "./dist/cjs/index.d.cts",
32+
"default": "./dis/cjs/index.cjs"
33+
}
34+
}
35+
},
2336
"scripts": {
24-
"build": "tsc -p tsconfig.build.json",
37+
"build": "tsc -p tsconfig.cjs.json & tsc -p tsconfig.esm.json",
2538
"format:check": "prettier --check \"{**/*,*}.{js,ts}\"",
2639
"format:write": "npm run format:check -- --write",
2740
"lint": "eslint --ext \".js,.ts\" .",

tsconfig.build.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"extends": "./tsconfig.json",
3-
"compilerOptions": { "sourceMap": false },
3+
"compilerOptions": { "noEmit": false, "sourceMap": false },
44
"exclude": ["**/__fixtures__/**/*", "**/*.spec.*"]
55
}

tsconfig.cjs.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"extends": "./tsconfig.build.json",
3+
"compilerOptions": { "module": "commonjs", "outDir": "dist/cjs" },
4+
"exclude": ["**/__fixtures__/**/*", "**/*.spec.*"]
5+
}

tsconfig.esm.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"extends": "./tsconfig.build.json",
3+
"compilerOptions": { "module": "esnext", "outDir": "dist/esm" },
4+
"exclude": ["**/__fixtures__/**/*", "**/*.spec.*"]
5+
}

tsconfig.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
{
22
"compilerOptions": {
33
"target": "es2016",
4-
"module": "commonjs",
4+
"module": "esnext",
55
"pretty": true,
66
"sourceMap": true,
77
"declaration": true,
8+
"noEmit": true,
89

9-
"outDir": "dist",
1010
"rootDir": "src",
1111

1212
"allowSyntheticDefaultImports": true,
1313
"esModuleInterop": true,
14+
"moduleResolution": "node",
1415
"strict": true
1516
},
1617
"include": ["src"]

0 commit comments

Comments
 (0)