Skip to content

Commit

Permalink
Export mjs files so Node can natively import them.
Browse files Browse the repository at this point in the history
Fixes #87.
  • Loading branch information
dfabulich committed May 2, 2020
1 parent 3553463 commit 420c24e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
16 changes: 15 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@
"version": "0.1.2",
"license": "MIT",
"description": "JSX-based components with functions, promises and generators.",
"exports": {
".": {
"import": "./esm/index.mjs",
"require": "./cjs/index.js"
},
"./html": {
"import": "./esm/html.mjs",
"require": "./cjs/html.js"
},
"./dom": {
"import": "./esm/dom.mjs",
"require": "./cjs/dom.js"
}
},
"files": [
"cjs",
"esm",
Expand All @@ -12,7 +26,7 @@
"html.js"
],
"main": "cjs/index.js",
"module": "esm/index.js",
"module": "esm/index.mjs",
"types": "esm/index.d.ts",
"scripts": {
"prebuild": "yarn run clean",
Expand Down
11 changes: 6 additions & 5 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import resolve from "@rollup/plugin-node-resolve";
import typescript from "rollup-plugin-typescript2";
export default {
input: ["src/index.ts", "src/dom.ts", "src/html.ts"],
import {basename} from "path";
export default ["src/index.ts", "src/dom.ts", "src/html.ts"].map((input) => ({
input,
output: [
{
format: "cjs",
dir: "cjs",
file: `cjs/${basename(input).replace(/\.ts$/, ".js")}`,
sourcemap: true,
},
{
format: "esm",
dir: "esm",
file: `esm/${basename(input).replace(/\.ts$/, ".mjs")}`,
sourcemap: true,
},
],
external: ["@repeaterjs/repeater"],
plugins: [typescript(), resolve()],
};
}));

0 comments on commit 420c24e

Please sign in to comment.