Skip to content

Commit 5e0fc4a

Browse files
authored
Add ESM build
See [#11]. [#11]: #11
1 parent 4f2dca8 commit 5e0fc4a

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

package.json

+12-3
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,22 @@
2424
"engines": {
2525
"node": ">=18.0.0"
2626
},
27+
"sideEffects": false,
2728
"main": "./dist/index.js",
2829
"typings": "./dist/index.d.ts",
30+
"exports": {
31+
".": {
32+
"types": "./dist/index.d.ts",
33+
"import": "./dist/index.mjs",
34+
"default": "./dist/index.js"
35+
},
36+
"./package.json": "./package.json"
37+
},
2938
"files": [
3039
"LICENSE",
3140
"README.md",
3241
"CHANGELOG.md",
33-
"dist/index.js",
34-
"dist/index.d.ts"
42+
"dist"
3543
],
3644
"scripts": {
3745
"pretest": "npm run lint",
@@ -41,7 +49,8 @@
4149
"lint:prettier": "prettier --check .",
4250
"format": "prettier --write .",
4351
"clean": "rm -rf dist",
44-
"build": "npm run clean && tsc",
52+
"build": "npm run clean && tsc && npm run build:esm",
53+
"build:esm": "sed 's/module.exports =/export default/' dist/index.js > dist/index.mjs",
4554
"test": "ts-node test.ts"
4655
},
4756
"devDependencies": {

test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import assert = require("node:assert/strict");
2-
import builder = require("./index");
1+
import assert from "node:assert/strict";
2+
import builder from "./index";
33

44
const test = (
55
message: string,

tsconfig.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"include": ["index.ts"],
23
"compilerOptions": {
34
"declaration": true,
45
"esModuleInterop": true,

0 commit comments

Comments
 (0)