Skip to content

Commit 0f20aa2

Browse files
committed
Support node v13 with es modules
Creates conditional export that points "import" conditional exports to mjs files. This lets node load the esm version with having to set "type": "module" on the main package.json. This is similar to the approach in the main preact repo - preactjs/preact#2451
1 parent ae45408 commit 0f20aa2

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

package.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,39 @@
66
"umd:main": "dist/htm.umd.js",
77
"module": "dist/htm.module.js",
88
"types": "dist/htm.d.ts",
9+
"exports": {
10+
".": {
11+
"import": "./dist/htm.mjs",
12+
"require": "./dist/htm.js",
13+
"browser": "./dist/htm.module.js",
14+
"umd": "./dist/htm.umd.js"
15+
},
16+
"./": "./",
17+
"./preact": {
18+
"import": "./preact/index.mjs",
19+
"require": "./preact/index.js",
20+
"browser": "./preact/index.module.js",
21+
"umd": "./preact/index.umd.js"
22+
},
23+
"./preact/standalone": {
24+
"import": "./preact/standalone.mjs",
25+
"require": "./preact/standalone.js",
26+
"browser": "./preact/standalone.module.js",
27+
"umd": "./preact/standalone.umd.js"
28+
},
29+
"./react": {
30+
"import": "./react/index.mjs",
31+
"require": "./react/index.js",
32+
"browser": "./react/index.module.js",
33+
"umd": "./react/index.umd.js"
34+
},
35+
"./mini": {
36+
"import": "./mini/index.mjs",
37+
"require": "./mini/index.js",
38+
"browser": "./mini/index.module.js",
39+
"umd": "./mini/index.umd.js"
40+
}
41+
},
942
"scripts": {
1043
"build": "npm run -s build:main && npm run -s build:mini && npm run -s build:preact && npm run -s build:react && npm run -s build:babel && npm run -s build:babel-transform-jsx && npm run -s build:mjsalias",
1144
"build:main": "microbundle src/index.mjs -f es,umd --no-sourcemap --target web && microbundle src/cjs.mjs -f iife --no-sourcemap --target web && cp src/index.d.ts dist/htm.d.ts",

0 commit comments

Comments
 (0)