@@ -230,13 +230,7 @@ export function normalizeRollupOutputOptionsObject(
230
230
return 'build/qwik-city.js' ;
231
231
}
232
232
233
- // some chunk names are absolute paths and rollup doesn't accept that so we must sanitize those instead of simply returning `build/[name].js`.
234
- const path = optimizer . sys . path ;
235
- const relativePath = path . relative ( optimizer . sys . cwd ( ) , chunkInfo . name ) ;
236
- const sanitizedPath = relativePath
237
- . replace ( / ^ ( \. \. \/ ) + / , '' )
238
- . replace ( / ^ \/ + / , '' )
239
- . replace ( / \/ / g, '-' ) ;
233
+ const sanitizedPath = sanitizePath ( optimizer , chunkInfo . name ) ;
240
234
241
235
return `build/${ sanitizedPath } .js` ;
242
236
} ;
@@ -283,6 +277,20 @@ export function normalizeRollupOutputOptionsObject(
283
277
return outputOpts ;
284
278
}
285
279
280
+ /**
281
+ * @private Sanitize The path to use dashes instead of slashes, to keep the same folder strucutre as
282
+ * without debug:true. Besides, Rollup doesn't accept absolute or relative paths as inputs for the
283
+ * [name] placeholder for the same reason.
284
+ */
285
+ export function sanitizePath ( optimizer : Optimizer , pathToSanitize : string ) {
286
+ const path = optimizer . sys . path ;
287
+ const relativePath = path . relative ( optimizer . sys . cwd ( ) , pathToSanitize ) ;
288
+ return relativePath
289
+ . replace ( / ^ ( \. \. \/ ) + / , '' )
290
+ . replace ( / ^ \/ + / , '' )
291
+ . replace ( / \/ / g, '-' ) ;
292
+ }
293
+
286
294
export function createRollupError ( id : string , diagnostic : Diagnostic ) {
287
295
const loc = diagnostic . highlights [ 0 ] ?? { } ;
288
296
const err : Rollup . RollupError = Object . assign ( new Error ( diagnostic . message ) , {
0 commit comments