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 ad95eca
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 8 deletions.
2 changes: 1 addition & 1 deletion dom.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from "./esm/dom.js";
export * from "./esm/dom.mjs";
2 changes: 1 addition & 1 deletion html.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from "./esm/html.js";
export * from "./esm/html.mjs";
28 changes: 27 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,32 @@
"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"
},
"./cjs/html": {
"require": "./cjs/html.js"
},
"./cjs/dom": {
"require": "./cjs/dom.js"
},
"./cjs/html.js": {
"require": "./cjs/html.js"
},
"./cjs/dom.js": {
"require": "./cjs/dom.js"
}
},
"files": [
"cjs",
"esm",
Expand All @@ -12,7 +38,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 ad95eca

Please sign in to comment.