Skip to content

Commit 9ce1c98

Browse files
author
Tajudeen
committed
fix: mark React output imports as external at tsup level to prevent build errors
- Add function matcher to external array for React output imports - Fixes 'Could not resolve' errors during React build - tsup checks external array during its own resolution phase (before esbuild) - Plugin approach was too late - tsup resolves imports before esbuild plugins run - React outputs are now marked external early enough to prevent resolution failures This fixes the issue where tsup tried to resolve React output imports from files outside the React directory (e.g., cortexideSettingsPane.ts) before those output files existed.
1 parent 0449679 commit 9ce1c98

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,21 @@ export default defineConfig({
6363
injectStyle: true, // bundle css into the output file
6464
outExtension: () => ({ js: '.js' }),
6565
treeshake: true,
66-
// Mark Node.js built-ins as external
67-
// React output imports are handled by the externalReactOutputsPlugin to prevent DTS generation errors
66+
// Mark Node.js built-ins and React output imports as external
67+
// React outputs MUST be in the external array (not just plugin) because:
68+
// 1. tsup does its own import resolution BEFORE esbuild
69+
// 2. When tsup encounters imports from files outside React dir (e.g., cortexideSettingsPane.ts),
70+
// it tries to resolve them during tsup's resolution phase
71+
// 3. The external array is checked during tsup's phase, plugins only run during esbuild phase
72+
// 4. If not in external array, tsup tries to resolve files that don't exist yet → fails
6873
external: [
6974
'url', 'module', 'fs', 'path', 'os', 'crypto', 'stream', 'util', 'events', 'buffer', 'process',
75+
// React output imports - must be external at tsup level to prevent resolution errors
76+
// Using function to match both ./react/out/ and ../react/out/ patterns
77+
// tsup checks this during its own resolution phase (before esbuild)
78+
(id) => {
79+
return id.startsWith('./react/out/') || id.startsWith('../react/out/')
80+
},
7081
],
7182
// Use tsconfig.json which has ignoreDeprecations: "6.0" to suppress baseUrl deprecation warnings
7283
tsconfig: './tsconfig.json',

0 commit comments

Comments
 (0)