-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: use .mjs for rollup config to instruct Rollup to treat it as a…
… pure ES module
- Loading branch information
Showing
1 changed file
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
]; |