Skip to content

Commit

Permalink
Add ESM build
Browse files Browse the repository at this point in the history
See [#11].

[#11]: #11
  • Loading branch information
frandiox authored Apr 25, 2024
1 parent 4f2dca8 commit 5e0fc4a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
15 changes: 12 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,22 @@
"engines": {
"node": ">=18.0.0"
},
"sideEffects": false,
"main": "./dist/index.js",
"typings": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"default": "./dist/index.js"
},
"./package.json": "./package.json"
},
"files": [
"LICENSE",
"README.md",
"CHANGELOG.md",
"dist/index.js",
"dist/index.d.ts"
"dist"
],
"scripts": {
"pretest": "npm run lint",
Expand All @@ -41,7 +49,8 @@
"lint:prettier": "prettier --check .",
"format": "prettier --write .",
"clean": "rm -rf dist",
"build": "npm run clean && tsc",
"build": "npm run clean && tsc && npm run build:esm",
"build:esm": "sed 's/module.exports =/export default/' dist/index.js > dist/index.mjs",
"test": "ts-node test.ts"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import assert = require("node:assert/strict");
import builder = require("./index");
import assert from "node:assert/strict";
import builder from "./index";

const test = (
message: string,
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"include": ["index.ts"],
"compilerOptions": {
"declaration": true,
"esModuleInterop": true,
Expand Down

0 comments on commit 5e0fc4a

Please # to comment.