Use tsconfig.json

This commit is contained in:
Adria Navarro 2023-05-03 14:04:54 +01:00
parent d7f7ad5b5f
commit 561cd40666
4 changed files with 10 additions and 6 deletions

View File

@ -15,7 +15,7 @@
"license": "GPL-3.0",
"scripts": {
"prebuild": "rimraf dist/",
"build": "node ../../scripts/build.js -p tsconfig.build.json --outdir dist/mjs/src && node ../../scripts/build.js -p tsconfig-cjs.build.json --outdir dist/cjs/src",
"build": "node ../../scripts/build.js && node ../../scripts/build.js -p tsconfig-cjs.build.json",
"build:dev": "yarn prebuild && tsc --build --watch --preserveWatchOutput",
"dev:builder": "yarn prebuild && concurrently \"tsc -p tsconfig.build.json --watch\" \"tsc -p tsconfig-cjs.build.json --watch\""
},

View File

@ -2,6 +2,7 @@
"extends": "./tsconfig-base.build.json",
"compilerOptions": {
"module": "commonjs",
"outDir": "dist/cjs/src",
"target": "es2015"
}
}

View File

@ -2,6 +2,7 @@
"extends": "./tsconfig-base.build.json",
"compilerOptions": {
"module": "esnext",
"outDir": "dist/mjs/src",
"target": "esnext"
}
}

View File

@ -15,12 +15,15 @@ var argv = require("minimist")(process.argv.slice(2))
function runBuild(entry, outfile) {
const isDev = process.env.NODE_ENV !== "production"
const tsconfig = argv["p"] || `tsconfig.build.json`
const tsconfigContent = require(`${process.cwd()}/${tsconfig}`)
const sharedConfig = {
entryPoints: [entry],
bundle: true,
minify: !isDev,
tsconfig: argv["p"] || `tsconfig.build.json`,
tsconfig,
plugins: [
sveltePlugin(),
NodeResolve({
@ -40,12 +43,12 @@ function runBuild(entry, outfile) {
external: isDev ? ["@budibase/client"] : [],
}
const outdir = argv["outdir"]
const outdir = tsconfigContent.compilerOptions?.outDir
build({
...sharedConfig,
platform: "node",
outdir,
outfile: outdir ? undefined : outfile,
outfile,
}).then(() => {
glob(`${process.cwd()}/src/**/*.hbs`, {}, (err, files) => {
for (const file of files) {
@ -62,8 +65,7 @@ function runBuild(entry, outfile) {
if (require.main === module) {
const entry = argv["e"] || "./src/index.ts"
const outfile = `dist/${entry.split("/").pop().replace(".ts", ".js")}`
runBuild(entry, outfile)
runBuild(entry)
} else {
module.exports = runBuild
}