diff --git a/dom.js b/dom.js index 284e03034..84de6180e 100644 --- a/dom.js +++ b/dom.js @@ -1 +1 @@ -export * from "./esm/dom.js"; +export * from "./esm/dom.mjs"; diff --git a/html.js b/html.js index f640dd189..8b975ffbe 100644 --- a/html.js +++ b/html.js @@ -1 +1 @@ -export * from "./esm/html.js"; +export * from "./esm/html.mjs"; diff --git a/package.json b/package.json index 727ce8922..a0934726b 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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", diff --git a/rollup.config.js b/rollup.config.js index 9a26beba1..f76e4fbf0 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -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()], -}; +}));