From ac4bc3a6c81f7b86bc5ec2b05069122a601224e7 Mon Sep 17 00:00:00 2001 From: Jeroen Claassens Date: Mon, 28 Mar 2022 21:34:58 +0200 Subject: [PATCH] chore(build): disable tsup minification & add `"use strict";` banner to CJS bundles (#7725) * chore(build): disable tsup minification * chore(build): add `"use strict";` to CJS bundles --- packages/builders/tsup.config.ts | 9 ++++++++- packages/collection/tsup.config.ts | 9 ++++++++- packages/rest/tsup.config.ts | 9 ++++++++- packages/voice/tsup.config.ts | 9 ++++++++- 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/packages/builders/tsup.config.ts b/packages/builders/tsup.config.ts index 95225fe1e..910ec4c27 100644 --- a/packages/builders/tsup.config.ts +++ b/packages/builders/tsup.config.ts @@ -5,9 +5,16 @@ export const tsup: Options = { dts: true, entryPoints: ['src/index.ts'], format: ['esm', 'cjs'], - minify: true, + minify: false, keepNames: true, skipNodeModulesBundle: true, sourcemap: true, target: 'es2021', + esbuildOptions: (options, context) => { + if (context.format === 'cjs') { + options.banner = { + js: '"use strict";', + }; + } + }, }; diff --git a/packages/collection/tsup.config.ts b/packages/collection/tsup.config.ts index 2148ae196..1747e9fdb 100644 --- a/packages/collection/tsup.config.ts +++ b/packages/collection/tsup.config.ts @@ -5,10 +5,17 @@ export const tsup: Options = { dts: true, entryPoints: ['src/index.ts'], format: ['esm', 'cjs'], - minify: true, + minify: false, // if false: causes Collection.constructor to be a minified value like: 'o' keepNames: true, skipNodeModulesBundle: true, sourcemap: true, target: 'es2021', + esbuildOptions: (options, context) => { + if (context.format === 'cjs') { + options.banner = { + js: '"use strict";', + }; + } + }, }; diff --git a/packages/rest/tsup.config.ts b/packages/rest/tsup.config.ts index d8ae5bb9a..4ab2c3bd1 100644 --- a/packages/rest/tsup.config.ts +++ b/packages/rest/tsup.config.ts @@ -5,9 +5,16 @@ export const tsup: Options = { dts: false, entryPoints: ['src/index.ts'], format: ['esm', 'cjs'], - minify: true, + minify: false, keepNames: true, skipNodeModulesBundle: true, sourcemap: true, target: 'es2021', + esbuildOptions: (options, context) => { + if (context.format === 'cjs') { + options.banner = { + js: '"use strict";', + }; + } + }, }; diff --git a/packages/voice/tsup.config.ts b/packages/voice/tsup.config.ts index e74b64848..a0c433e8d 100644 --- a/packages/voice/tsup.config.ts +++ b/packages/voice/tsup.config.ts @@ -5,9 +5,16 @@ export default defineConfig({ dts: true, entryPoints: ['src/index.ts'], format: ['esm', 'cjs'], - minify: true, + minify: false, keepNames: true, skipNodeModulesBundle: true, sourcemap: true, target: 'es2021', + esbuildOptions: (options, context) => { + if (context.format === 'cjs') { + options.banner = { + js: '"use strict";', + }; + } + }, });