Skip to content

Commit

Permalink
chore: use .mjs for rollup config to instruct Rollup to treat it as a…
Browse files Browse the repository at this point in the history
… pure ES module
  • Loading branch information
wessberg committed May 31, 2022
1 parent 99f47fe commit 74d0472
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import ts from "rollup-plugin-ts";
import pkg from "./package.json" assert {type: "json"};
import {builtinModules} from "module";

const SHARED_OPTIONS = {
plugins: [
ts({
tsconfig: "tsconfig.build.json"
})
],
external: [
...builtinModules,
...Object.keys(pkg.dependencies),
...Object.keys(pkg.devDependencies),
...Object.keys(pkg.peerDependencies)
]
};

const SHARED_OUTPUT_OPTIONS = {
sourcemap: true,
hoistTransitiveImports: false,
generatedCode: "es2015",
compact: false,
minifyInternalExports: false
};


export default [
{
input: "src/index.ts",
preserveEntrySignatures: true,
output: [
{
file: pkg.exports.require,
format: "cjs",
...SHARED_OUTPUT_OPTIONS
},
{
file: pkg.exports.import,
format: "esm",
...SHARED_OUTPUT_OPTIONS
}
],
...SHARED_OPTIONS
},
{
input: "src/cli/index.ts",
preserveEntrySignatures: true,
output: [
{
dir: "./dist/cli",
format: "esm",
...SHARED_OUTPUT_OPTIONS
}
],
...SHARED_OPTIONS
}
];

0 comments on commit 74d0472

Please sign in to comment.