@@ -183,11 +183,21 @@ function fixImportPaths() {
183183 }
184184
185185 // Replace all relative imports with absolute paths
186- // BUT keep chunk imports relative (they're part of the bundle )
186+ // BUT keep chunk imports relative (they're in the same directory structure and work with relative paths )
187187 const convertRelativeFromImport = ( match , quote , dots , rest ) => {
188- if ( rest . startsWith ( './' ) || rest . startsWith ( 'vs/' ) || rest . startsWith ( 'chunk-' ) ) {
188+ // Skip if already absolute (starts with vs/)
189+ if ( rest . startsWith ( 'vs/' ) ) {
189190 return match ;
190191 }
192+ // Keep chunk imports relative - they're in the same directory structure
193+ if ( rest . startsWith ( 'chunk-' ) ) {
194+ return match ; // Keep relative path
195+ }
196+ // Skip relative imports starting with ./
197+ if ( rest . startsWith ( './' ) ) {
198+ return match ;
199+ }
200+ // Convert other relative imports to absolute paths
191201 const resolved = resolveRelativeImport ( `${ dots } ${ rest } ` ) ;
192202 if ( resolved !== `${ dots } ${ rest } ` ) {
193203 return `from ${ quote } ${ resolved } ${ quote } ` ;
@@ -203,9 +213,19 @@ function fixImportPaths() {
203213 content = content . replace (
204214 / i m p o r t \s + ( [ ' " ] ) ( (?: \. \. \/ ) + ) ( [ ^ ' " ; \n ] + ) \1/ g,
205215 ( match , quote , dots , rest ) => {
206- if ( rest . startsWith ( './' ) || rest . startsWith ( 'vs/' ) || rest . startsWith ( 'chunk-' ) ) {
216+ // Skip if already absolute (starts with vs/)
217+ if ( rest . startsWith ( 'vs/' ) ) {
218+ return match ;
219+ }
220+ // Keep chunk imports relative - they're in the same directory structure
221+ if ( rest . startsWith ( 'chunk-' ) ) {
222+ return match ; // Keep relative path
223+ }
224+ // Skip relative imports starting with ./
225+ if ( rest . startsWith ( './' ) ) {
207226 return match ;
208227 }
228+ // Convert other relative imports to absolute paths
209229 const resolved = resolveRelativeImport ( `${ dots } ${ rest } ` ) ;
210230 if ( resolved !== `${ dots } ${ rest } ` ) {
211231 return `import ${ quote } ${ resolved } ${ quote } ` ;
@@ -214,22 +234,6 @@ function fixImportPaths() {
214234 }
215235 ) ;
216236
217- // Also fix any absolute chunk imports that were incorrectly converted
218- // Convert them back to relative imports
219- content = content . replace (
220- / f r o m \s + ( [ ' " ] ) v s \/ w o r k b e n c h \/ c o n t r i b \/ c o r t e x i d e \/ b r o w s e r \/ r e a c t \/ o u t \/ ( c h u n k - [ ^ ' " ] + ) \1/ g,
221- ( match , quote , chunkName ) => {
222- // Get the directory of the current file relative to react/out/
223- const currentFileDir = path . dirname ( fileRelPath ) ;
224- // Chunks are in react/out/, entry points are in react/out/subdir/
225- if ( currentFileDir === 'vs/workbench/contrib/cortexide/browser/react/out' ) {
226- return `from ${ quote } ./${ chunkName } ${ quote } ` ;
227- }
228- // If in a subdirectory (e.g., void-settings-tsx/), use relative path
229- return `from ${ quote } ../${ chunkName } ${ quote } ` ;
230- }
231- ) ;
232-
233237 // Ensure browser-level modules always point to the browser directory
234238 content = content
235239 . replace ( / v s \/ w o r k b e n c h \/ c o n t r i b \/ c o r t e x i d e \/ a c t i o n I D s \. j s / g, 'vs/workbench/contrib/cortexide/browser/actionIDs.js' )
@@ -395,6 +399,7 @@ if (isWatch) {
395399 execSync ( 'npx tsup' , { stdio : 'inherit' } ) ;
396400
397401 // Fix import paths in bundled files
402+ // allow-any-unicode-next-line
398403 console . log ( '🔧 Fixing import paths...' ) ;
399404 fixImportPaths ( ) ;
400405
0 commit comments