Skip to content

Commit

Permalink
Better support for dual ESM/CJS (#301)
Browse files Browse the repository at this point in the history
- Use exports field
- Ship local package.json files with `type` specified.
  • Loading branch information
zpao committed Aug 17, 2023
1 parent 8f54672 commit 15f4b93
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ examples/iife/demo.js: lib/esm/index.js ${EXAMPLE_DEPS}
yarn run build:examples

clean:
rm -rf lib examples/iife/demo.js
git clean -fX lib examples
3 changes: 3 additions & 0 deletions lib/esm/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "module"
}
3 changes: 3 additions & 0 deletions lib/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "commonjs"
}
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
"main": "./lib/index.js",
"module": "./lib/esm/index.js",
"types": "./lib/index.d.ts",
"exports": {
".": {
"import": "./lib/esm/index.js",
"require": "./lib/index.js"
}
},
"scripts": {
"build": "yarn run build:code && yarn run build:examples",
"build:code": "tsup src/index.tsx -d lib --format esm,cjs --dts --legacy-output --target=es2017 --platform=browser",
Expand Down

0 comments on commit 15f4b93

Please sign in to comment.