@@ -5,33 +5,38 @@ import baseConfig from '../../tsdown.base.config';
55import { fluentStyleContent as fluentStyleContentPlaceholder } from './src/styles/createStyles' ;
66import { injectCSSPlugin } from 'botframework-webchat-styles/build' ;
77import LightningCSS from 'unplugin-lightningcss' ;
8+ import type { Plugin } from 'rollup' ;
89
9- const umdResolvePlugin = {
10- name : 'umd-resolve' ,
11- setup ( build ) {
12- build . onResolve ( { filter : / ^ r e a c t $ / u } , ( ) => ( {
13- path : join ( fileURLToPath ( import . meta. url ) , '../src/external.umd/react.ts' )
14- } ) ) ;
15-
16- build . onResolve ( { filter : / ^ b o t f r a m e w o r k - w e b c h a t - a p i $ / u } , ( ) => ( {
17- path : join ( fileURLToPath ( import . meta. url ) , '../src/external.umd/botframework-webchat-api/index.ts' )
18- } ) ) ;
19-
20- build . onResolve ( { filter : / ^ b o t f r a m e w o r k - w e b c h a t - a p i \/ d e c o r a t o r $ / u } , ( ) => ( {
21- path : join ( fileURLToPath ( import . meta. url ) , '../src/external.umd/botframework-webchat-api/decorator.ts' )
22- } ) ) ;
23-
24- build . onResolve ( { filter : / ^ b o t f r a m e w o r k - w e b c h a t - c o m p o n e n t $ / u } , ( ) => ( {
25- path : join ( fileURLToPath ( import . meta. url ) , '../src/external.umd/botframework-webchat-component/index.ts' )
26- } ) ) ;
10+ import pkg from './package.json' ;
2711
28- build . onResolve ( { filter : / ^ b o t f r a m e w o r k - w e b c h a t - c o m p o n e n t \/ i n t e r n a l $ / u } , ( ) => ( {
29- path : join ( fileURLToPath ( import . meta. url ) , '../src/external.umd/botframework-webchat-component/internal.ts' )
30- } ) ) ;
12+ const iifeDeps = [
13+ 'botframework-webchat-component/decorator' ,
14+ 'botframework-webchat-api/decorator' ,
15+ 'botframework-webchat-component/internal'
16+ ] . concat ( Object . keys ( pkg . dependencies ) ) ;
3117
32- build . onResolve ( { filter : / ^ b o t f r a m e w o r k - w e b c h a t - c o m p o n e n t \/ d e c o r a t o r $ / u } , ( ) => ( {
33- path : join ( fileURLToPath ( import . meta. url ) , '../src/external.umd/botframework-webchat-component/decorator.ts' )
34- } ) ) ;
18+ const umdResolvePlugin : Plugin = {
19+ name : 'umd-resolve' ,
20+ resolveId ( source ) {
21+ if ( source === 'react' ) {
22+ return join ( fileURLToPath ( import . meta. url ) , '../src/external.umd/react.ts' ) ;
23+ }
24+ if ( source === 'botframework-webchat-api' ) {
25+ return join ( fileURLToPath ( import . meta. url ) , '../src/external.umd/botframework-webchat-api/index.ts' ) ;
26+ }
27+ if ( source === 'botframework-webchat-api/decorator' ) {
28+ return join ( fileURLToPath ( import . meta. url ) , '../src/external.umd/botframework-webchat-api/decorator.ts' ) ;
29+ }
30+ if ( source === 'botframework-webchat-component' ) {
31+ return join ( fileURLToPath ( import . meta. url ) , '../src/external.umd/botframework-webchat-component/index.ts' ) ;
32+ }
33+ if ( source === 'botframework-webchat-component/internal' ) {
34+ return join ( fileURLToPath ( import . meta. url ) , '../src/external.umd/botframework-webchat-component/internal.ts' ) ;
35+ }
36+ if ( source === 'botframework-webchat-component/decorator' ) {
37+ return join ( fileURLToPath ( import . meta. url ) , '../src/external.umd/botframework-webchat-component/decorator.ts' ) ;
38+ }
39+ return null ;
3540 }
3641} ;
3742
@@ -40,45 +45,61 @@ export default defineConfig([
4045 ...baseConfig ,
4146 entry : { 'botframework-webchat-fluent-theme' : './src/index.ts' } ,
4247 env : { ...baseConfig . env , module_format : 'commonjs' } ,
43- plugins : [
44- LightningCSS . rolldown ( )
48+ plugins : [ LightningCSS . rolldown ( ) ] ,
49+ esbuildPlugins : [
50+ ...( baseConfig . esbuildPlugins || [ ] ) ,
51+ injectCSSPlugin ( { stylesPlaceholder : fluentStyleContentPlaceholder } )
4552 ] ,
46- esbuildPlugins : [ ...( baseConfig . esbuildPlugins || [ ] ) , injectCSSPlugin ( { stylesPlaceholder : fluentStyleContentPlaceholder } ) ] ,
4753 format : [ 'cjs' ] ,
48- target : [ ...baseConfig . target , 'es2019' ]
54+ target : [ ...baseConfig . target , 'es2019' ] ,
4955 } ,
5056 {
5157 ...baseConfig ,
5258 entry : { 'botframework-webchat-fluent-theme' : './src/index.ts' } ,
53- plugins : [
54- LightningCSS . rolldown ( )
59+ plugins : [ LightningCSS . rolldown ( ) ] ,
60+ esbuildPlugins : [
61+ ...( baseConfig . esbuildPlugins || [ ] ) ,
62+ injectCSSPlugin ( { stylesPlaceholder : fluentStyleContentPlaceholder } )
5563 ] ,
56- esbuildPlugins : [ ...( baseConfig . esbuildPlugins || [ ] ) , injectCSSPlugin ( { stylesPlaceholder : fluentStyleContentPlaceholder } ) ] ,
5764 format : [ 'esm' ]
5865 } ,
5966 {
6067 ...baseConfig ,
6168 entry : { 'botframework-webchat-fluent-theme.development' : './src/bundle.ts' } ,
62- esbuildPlugins : [ ... ( baseConfig . esbuildPlugins || [ ] ) , injectCSSPlugin ( { stylesPlaceholder : fluentStyleContentPlaceholder } ) , umdResolvePlugin ] ,
63- plugins : [
64- LightningCSS . rolldown ( )
69+ esbuildPlugins : [
70+ ... ( baseConfig . esbuildPlugins || [ ] ) ,
71+ injectCSSPlugin ( { stylesPlaceholder : fluentStyleContentPlaceholder } )
6572 ] ,
73+ plugins : [ LightningCSS . rolldown ( ) , umdResolvePlugin ] ,
6674 format : 'iife' ,
67- outExtension ( ) {
68- return { js : '.js' } ;
69- }
75+ outputOptions ( outputOptions ) {
76+ outputOptions . entryFileNames = '[name].js' ;
77+ outputOptions . globals = {
78+ react : 'React' ,
79+ 'react/jsx-runtime' : 'React'
80+ } ;
81+ return outputOptions ;
82+ } ,
83+ noExternal : iifeDeps
7084 } ,
7185 {
7286 ...baseConfig ,
7387 entry : { 'botframework-webchat-fluent-theme.production.min' : './src/bundle.ts' } ,
74- esbuildPlugins : [ ... ( baseConfig . esbuildPlugins || [ ] ) , injectCSSPlugin ( { stylesPlaceholder : fluentStyleContentPlaceholder } ) , umdResolvePlugin ] ,
75- plugins : [
76- LightningCSS . rolldown ( )
88+ esbuildPlugins : [
89+ ... ( baseConfig . esbuildPlugins || [ ] ) ,
90+ injectCSSPlugin ( { stylesPlaceholder : fluentStyleContentPlaceholder } )
7791 ] ,
92+ plugins : [ LightningCSS . rolldown ( ) , umdResolvePlugin ] ,
7893 format : 'iife' ,
7994 minify : true ,
80- outExtension ( ) {
81- return { js : '.js' } ;
82- }
95+ outputOptions ( outputOptions ) {
96+ outputOptions . entryFileNames = '[name].js' ;
97+ outputOptions . globals = {
98+ react : 'React' ,
99+ 'react/jsx-runtime' : 'React'
100+ } ;
101+ return outputOptions ;
102+ } ,
103+ noExternal : iifeDeps
83104 }
84105] ) ;
0 commit comments