Build both cjs and mjs versions

This commit is contained in:
Adria Navarro 2024-02-21 22:35:02 +01:00
parent 667a5ab990
commit 2339030fe2
2 changed files with 28 additions and 26 deletions

View File

@ -4,13 +4,12 @@
"version": "0.0.0", "version": "0.0.0",
"description": "Handlebars wrapper for Budibase templating.", "description": "Handlebars wrapper for Budibase templating.",
"main": "dist/bundle.cjs", "main": "dist/bundle.cjs",
"module": "src/index.ts", "module": "dist/bundle.mjs",
"license": "MPL-2.0", "license": "MPL-2.0",
"types": "dist/index.d.ts",
"exports": { "exports": {
".": { ".": {
"require": "./dist/bundle.cjs", "require": "./dist/bundle.cjs",
"import": "./src/index.ts" "import": "./dist/bundle.mjs"
}, },
"./package.json": "./package.json", "./package.json": "./package.json",
"./test/utils": "./test/utils.js" "./test/utils": "./test/utils.js"

View File

@ -9,28 +9,31 @@ import injectProcessEnv from "rollup-plugin-inject-process-env"
const production = !process.env.ROLLUP_WATCH const production = !process.env.ROLLUP_WATCH
export default [ const config = (format, outputFile) => ({
{ input: "src/index.ts",
input: "src/index.ts", output: {
output: { sourcemap: !production,
sourcemap: !production, format,
format: "cjs", file: outputFile,
file: "./dist/bundle.cjs",
},
plugins: [
typescript({ tsconfig: "tsconfig.json" }),
resolve({
preferBuiltins: true,
browser: true,
}),
commonjs(),
globals(),
builtins(),
json(),
injectProcessEnv({
NO_JS: process.env.NO_JS,
}),
production && terser(),
],
}, },
plugins: [
typescript({ tsconfig: "tsconfig.json" }),
resolve({
preferBuiltins: true,
browser: true,
}),
commonjs(),
globals(),
builtins(),
json(),
injectProcessEnv({
NO_JS: process.env.NO_JS,
}),
// production && terser(),
],
})
export default [
config("cjs", "./dist/bundle.cjs"),
config("esm", "./dist/bundle.mjs"),
] ]