Skip to content

Commit

Permalink
Support node v13 with es modules
Browse files Browse the repository at this point in the history
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
  • Loading branch information
vikerman committed Apr 26, 2020
1 parent f6e6b0a commit 1d6b38b
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,39 @@
"umd:main": "dist/htm.umd.js",
"module": "dist/htm.module.js",
"types": "dist/htm.d.ts",
"exports": {
".": {
"import": "./dist/htm.mjs",
"require": "./dist/htm.js",
"browser": "./dist/htm.module.js",
"umd": "./dist/htm.umd.js"
},
"./": "./",
"./preact": {
"import": "./preact/index.mjs",
"require": "./preact/index.js",
"browser": "./preact/index.module.js",
"umd": "./preact/index.umd.js"
},
"./preact/standalone": {
"import": "./preact/standalone.mjs",
"require": "./preact/standalone.js",
"browser": "./preact/standalone.module.js",
"umd": "./preact/standalone.umd.js"
},
"./react": {
"import": "./react/index.mjs",
"require": "./react/index.js",
"browser": "./react/index.module.js",
"umd": "./react/index.umd.js"
},
"./mini": {
"import": "./mini/index.mjs",
"require": "./mini/index.js",
"browser": "./mini/index.module.js",
"umd": "./mini/index.umd.js"
}
},
"scripts": {
"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",
"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",
Expand Down

0 comments on commit 1d6b38b

Please sign in to comment.