@@ -27,6 +27,19 @@ const externalVSCodePlugin = {
2727 }
2828}
2929
30+ // Plugin to mark React output imports as external during DTS generation
31+ // This prevents tsup from trying to resolve imports to files that don't exist yet during the build
32+ const externalReactOutputsPlugin = {
33+ name : 'external-react-outputs' ,
34+ setup ( build ) {
35+ build . onResolve ( { filter : / ^ \. \/ r e a c t \/ o u t \/ | ^ \. \. \/ r e a c t \/ o u t \/ / } , ( args ) => {
36+ // Mark React output imports as external during build (they'll be available at runtime)
37+ // This prevents DTS generation from failing when these files don't exist yet
38+ return { path : args . path , external : true }
39+ } )
40+ }
41+ }
42+
3043export default defineConfig ( {
3144 entry : [
3245 './src2/void-editor-widgets-tsx/index.tsx' ,
@@ -51,8 +64,7 @@ export default defineConfig({
5164 outExtension : ( ) => ( { js : '.js' } ) ,
5265 treeshake : true ,
5366 // Mark Node.js built-ins as external
54- // Note: React output files are NOT marked as external here because they need to be
55- // bundled together. The external plugin handles VS Code imports only.
67+ // React output imports are handled by the externalReactOutputsPlugin to prevent DTS generation errors
5668 external : [
5769 'url' , 'module' , 'fs' , 'path' , 'os' , 'crypto' , 'stream' , 'util' , 'events' , 'buffer' , 'process' ,
5870 ] ,
@@ -63,8 +75,9 @@ export default defineConfig({
6375 // Note: Memory limits are set via Node.js --max-old-space-size flag in build.js
6476 // Use tsconfig.json which already has experimentalDecorators enabled
6577 options . tsconfig = './tsconfig.json'
66- // Add plugin to mark VS Code code as external
78+ // Add plugins to mark VS Code code and React outputs as external
6779 options . plugins = options . plugins || [ ]
6880 options . plugins . push ( externalVSCodePlugin )
81+ options . plugins . push ( externalReactOutputsPlugin )
6982 }
7083} )
0 commit comments