@@ -71,4 +71,40 @@ globalThis.__tw_readFile = async (path, encoding) => {
71
71
return fs . readFileSync ( path , encoding )
72
72
}
73
73
74
+ // We use a plugin to make sure that the JS APIs are bundled with the standalone
75
+ // CLI and can be imported inside configs and plugins
76
+ Bun . plugin ( {
77
+ name : 'bundle-tailwindcss-apis' ,
78
+ target : 'bun' ,
79
+ async setup ( build ) {
80
+ // These imports must be static strings otherwise they won't be bundled
81
+ let bundled = {
82
+ tailwindcss : await import ( 'tailwindcss' ) ,
83
+ 'tailwindcss/colors' : await import ( 'tailwindcss/colors' ) ,
84
+ 'tailwindcss/colors.js' : await import ( 'tailwindcss/colors' ) ,
85
+ 'tailwindcss/plugin' : await import ( 'tailwindcss/plugin' ) ,
86
+ 'tailwindcss/plugin.js' : await import ( 'tailwindcss/plugin' ) ,
87
+ 'tailwindcss/package.json' : await import ( 'tailwindcss/package.json' ) ,
88
+ 'tailwindcss/lib/util/flattenColorPalette' : await import (
89
+ 'tailwindcss/lib/util/flattenColorPalette'
90
+ ) ,
91
+ 'tailwindcss/lib/util/flattenColorPalette.js' : await import (
92
+ 'tailwindcss/lib/util/flattenColorPalette'
93
+ ) ,
94
+ 'tailwindcss/defaultTheme' : await import ( 'tailwindcss/defaultTheme' ) ,
95
+ 'tailwindcss/defaultTheme.js' : await import ( 'tailwindcss/defaultTheme' ) ,
96
+ }
97
+
98
+ for ( let [ id , exports ] of Object . entries ( bundled ) ) {
99
+ build . module ( id , ( ) => ( {
100
+ loader : 'object' ,
101
+ exports : {
102
+ ...exports ,
103
+ __esModule : true ,
104
+ } ,
105
+ } ) )
106
+ }
107
+ } ,
108
+ } )
109
+
74
110
await import ( '../../@tailwindcss-cli/src/index.ts' )
0 commit comments