diff --git a/packages/api/tsup.config.ts b/packages/api/tsup.config.ts index 423f6dfe2e..b9ff3588e6 100644 --- a/packages/api/tsup.config.ts +++ b/packages/api/tsup.config.ts @@ -1,13 +1,24 @@ import { defineConfig } from 'tsup'; import baseConfig from '../../tsup.base.config'; -export default defineConfig({ +const config: typeof baseConfig = { ...baseConfig, entry: { 'botframework-webchat-api': './src/index.ts', 'botframework-webchat-api.internal': './src/internal.ts', 'botframework-webchat-api.decorator': './src/decorator/index.ts' + } +}; + +export default defineConfig([ + { + ...config, + format: 'esm', + noExternal: ['globalize'] }, - noExternal: ['globalize'], - format: ['esm', 'cjs'] -}); + { + ...config, + format: 'cjs', + target: [...config.target, 'es2019'] + } +]); diff --git a/packages/base/tsup.config.ts b/packages/base/tsup.config.ts index 4c25ec196d..0021615804 100644 --- a/packages/base/tsup.config.ts +++ b/packages/base/tsup.config.ts @@ -1,11 +1,22 @@ import { defineConfig } from 'tsup'; import baseConfig from '../../tsup.base.config'; -export default defineConfig({ +const config: typeof baseConfig = { ...baseConfig, entry: { 'botframework-webchat-base': './src/index.ts', 'botframework-webchat-base.utils': './src/utils/index.ts' + } +}; + +export default defineConfig([ + { + ...config, + format: 'esm' }, - format: ['esm', 'cjs'] -}); + { + ...config, + format: 'cjs', + target: [...config.target, 'es2019'] + } +]); diff --git a/packages/bundle/tsup.config.ts b/packages/bundle/tsup.config.ts index 1b2201ca35..ad95fd81c7 100644 --- a/packages/bundle/tsup.config.ts +++ b/packages/bundle/tsup.config.ts @@ -13,7 +13,7 @@ const resolveCognitiveServicesToES2015 = { } }; -export default defineConfig({ +const config: typeof baseConfig = { ...baseConfig, entry: { 'botframework-webchat': './src/index.ts', @@ -34,6 +34,17 @@ export default defineConfig({ 'memoize-one', 'microsoft-cognitiveservices-speech-sdk', 'web-speech-cognitive-services' - ], - format: ['esm', 'cjs'] -}); + ] +}; + +export default defineConfig([ + { + ...config, + format: 'esm' + }, + { + ...config, + format: 'cjs', + target: [...config.target, 'es2019'] + } +]); diff --git a/packages/component/tsup.config.ts b/packages/component/tsup.config.ts index d3afbefcba..7df5a259f5 100644 --- a/packages/component/tsup.config.ts +++ b/packages/component/tsup.config.ts @@ -1,10 +1,10 @@ +import { injectCSSPlugin } from 'botframework-webchat-styles/build'; import { defineConfig } from 'tsup'; import baseConfig from '../../tsup.base.config'; import { componentStyleContent as componentStyleContentPlaceholder } from './src/Styles/createStyles'; import { decoratorStyleContent as decoratorStyleContentPlaceholder } from './src/decorator/private/createStyles'; -import { injectCSSPlugin } from 'botframework-webchat-styles/build'; -export default defineConfig({ +const config: typeof baseConfig = { ...baseConfig, loader: { ...baseConfig.loader, @@ -18,6 +18,17 @@ export default defineConfig({ 'botframework-webchat-component': './src/index.ts', 'botframework-webchat-component.internal': './src/internal.ts', 'botframework-webchat-component.decorator': './src/decorator/index.ts' + } +}; + +export default defineConfig([ + { + ...config, + format: 'esm' }, - format: ['esm', 'cjs'] -}); + { + ...config, + format: 'cjs', + target: [...config.target, 'es2019'] + } +]); diff --git a/packages/core/tsup.config.ts b/packages/core/tsup.config.ts index 50741e1df5..a7638de4bf 100644 --- a/packages/core/tsup.config.ts +++ b/packages/core/tsup.config.ts @@ -1,10 +1,21 @@ import { defineConfig } from 'tsup'; import baseConfig from '../../tsup.base.config'; -export default defineConfig({ +const config: typeof baseConfig = { ...baseConfig, entry: { 'botframework-webchat-core': './src/index.ts' + } +}; + +export default defineConfig([ + { + ...config, + format: 'esm' }, - format: ['esm', 'cjs'] -}); + { + ...config, + format: 'cjs', + target: [...config.target, 'es2019'] + } +]); diff --git a/packages/directlinespeech/tsup.config.ts b/packages/directlinespeech/tsup.config.ts index e715a24b09..f4de4f27a8 100644 --- a/packages/directlinespeech/tsup.config.ts +++ b/packages/directlinespeech/tsup.config.ts @@ -13,7 +13,7 @@ const resolveCognitiveServicesToES2015 = { } }; -export default defineConfig({ +const config: typeof baseConfig = { ...baseConfig, entry: { 'botframework-directlinespeech-sdk': './src/index.js' @@ -29,4 +29,16 @@ export default defineConfig({ esbuildPlugins: [resolveCognitiveServicesToES2015], // We need to internalize event-target-shim because it appear as transient packages with a different version. noExternal: ['event-target-shim'] -}); +}; + +export default defineConfig([ + { + ...config, + format: 'esm' + }, + { + ...config, + format: 'cjs', + target: [...config.target, 'es2019'] + } +]); diff --git a/packages/fluent-theme/tsup.config.ts b/packages/fluent-theme/tsup.config.ts index 39963d95dc..d890eef93d 100644 --- a/packages/fluent-theme/tsup.config.ts +++ b/packages/fluent-theme/tsup.config.ts @@ -44,7 +44,8 @@ export default defineConfig([ '.css': 'local-css' }, esbuildPlugins: [...(baseConfig.esbuildPlugins || []), injectCSSPlugin({ stylesPlaceholder: fluentStyleContentPlaceholder })], - format: ['cjs'] + format: ['cjs'], + target: [...baseConfig.target, 'es2019'] }, { ...baseConfig, diff --git a/packages/styles/tsup.config.ts b/packages/styles/tsup.config.ts index a0796ae4c3..d49c9aef7a 100644 --- a/packages/styles/tsup.config.ts +++ b/packages/styles/tsup.config.ts @@ -1,12 +1,23 @@ import { defineConfig } from 'tsup'; import baseConfig from '../../tsup.base.config'; -export default defineConfig({ +const config: typeof baseConfig = { ...baseConfig, entry: { 'botframework-webchat-styles': './src/index.ts', 'botframework-webchat-styles.build': './src/build/index.ts', 'botframework-webchat-styles.react': './src/react/index.ts' + } +}; + +export default defineConfig([ + { + ...config, + format: 'esm' }, - format: ['esm', 'cjs'] -}); + { + ...config, + format: 'cjs', + target: [...config.target, 'es2019'] + } +]); diff --git a/tsup.base.config.ts b/tsup.base.config.ts index 04b003fb6a..0c9afec711 100644 --- a/tsup.base.config.ts +++ b/tsup.base.config.ts @@ -1,11 +1,13 @@ -import { defineConfig, type Options } from 'tsup'; +import { type Options } from 'tsup'; import { babelPlugin, defaultPredicate, type Predicate } from './esbuildBabelPluginIstanbul'; +type Target = Exclude | undefined>; + const env = process.env.NODE_ENV || 'development'; const { npm_package_version } = process.env; const istanbulPredicate: Predicate = args => defaultPredicate(args) && !/\.worker\.[cm]?[jt]s$/u.test(args.path); -export default defineConfig({ +const baseConfig: Options & { target: Target[] } = { dts: true, env: { build_tool: 'tsup', @@ -52,5 +54,7 @@ export default defineConfig({ minify: env === 'production', platform: 'browser', sourcemap: true, - target: ['chrome100', 'firefox100', 'safari15'] -}) as Options; + target: ['chrome100', 'firefox100', 'safari15'] satisfies Target[] +}; + +export default baseConfig;