From 4ba586fbe80e603842ee58320cccd4672ba305a3 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 3 Oct 2023 09:49:58 +0200 Subject: [PATCH] Clean build flags --- scripts/build.js | 44 +++++++++++++++++++------------------------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/scripts/build.js b/scripts/build.js index a3a377593a..0175388051 100755 --- a/scripts/build.js +++ b/scripts/build.js @@ -15,11 +15,7 @@ const { nodeExternalsPlugin } = require("esbuild-node-externals") var argv = require("minimist")(process.argv.slice(2)) -function runBuild( - entry, - outfile, - opts = { skipMeta: false, bundle: true, silent: false } -) { +function runBuild(entry, outfile) { const isDev = process.env.NODE_ENV !== "production" const tsconfig = argv["p"] || `tsconfig.build.json` const tsconfigPathPluginContent = JSON.parse( @@ -40,16 +36,12 @@ function runBuild( ] } - const metafile = !opts.skipMeta - const { bundle } = opts - const sharedConfig = { entryPoints: [entry], - bundle, + bundle: true, minify: !isDev, sourcemap: isDev, tsconfig, - format: opts?.forcedFormat, plugins: [ TsconfigPathsPlugin({ tsconfig: tsconfigPathPluginContent }), nodeExternalsPlugin(), @@ -58,10 +50,15 @@ function runBuild( loader: { ".svelte": "copy", }, - metafile, - external: bundle - ? ["deasync", "mock-aws-s3", "nock", "pino", "koa-pino-logger", "bull"] - : undefined, + metafile: true, + external: [ + "deasync", + "mock-aws-s3", + "nock", + "pino", + "koa-pino-logger", + "bull", + ], } build({ @@ -74,19 +71,16 @@ function runBuild( fs.copyFileSync(file, `${process.cwd()}/dist/${path.basename(file)}`) } - !opts.silent && - console.log( - "\x1b[32m%s\x1b[0m", - `Build successfully in ${(Date.now() - start) / 1000} seconds` - ) + console.log( + "\x1b[32m%s\x1b[0m", + `Build successfully in ${(Date.now() - start) / 1000} seconds` + ) }) - if (metafile) { - fs.writeFileSync( - `dist/${path.basename(outfile)}.meta.json`, - JSON.stringify(result.metafile) - ) - } + fs.writeFileSync( + `dist/${path.basename(outfile)}.meta.json`, + JSON.stringify(result.metafile) + ) }) }