Skip to content

Commit 0449679

Browse files
author
Tajudeen
committed
fix: mark React output imports as external during DTS generation to prevent build errors
1 parent 3949ed7 commit 0449679

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

src/vs/workbench/contrib/cortexide/browser/react/tsup.config.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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: /^\.\/react\/out\/|^\.\.\/react\/out\// }, (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+
3043
export 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

Comments
 (0)