Created
January 21, 2021 17:57
-
-
Save phated/79b85f735bdd52bbec4f4b1879c9fcc5 to your computer and use it in GitHub Desktop.
Neat little Rollup script for generating a CJS version of an ESM module.
This file contains hidden or 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
import fs from "fs"; | |
import { builtinModules as builtin } from "module"; | |
const pkg = JSON.parse(fs.readFileSync("./package.json")); | |
export default { | |
input: "./src/index.js", | |
output: { | |
file: "build/index.cjs", | |
format: "cjs", | |
}, | |
external: [ | |
...Object.keys(pkg.dependencies), | |
...builtin, | |
] | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment