File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed
packages/bundler-plugin-core/src Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -346,9 +346,11 @@ export function createRollupDebugIdInjectionHooks() {
346
346
// Note: CodeQL complains that this regex potentially has n^2 runtime. This likely won't affect realistic files.
347
347
/ ^ (?: \s * | \/ \* (?: .| \r | \n ) * \* \/ | \/ \/ .* [ \n \r ] ) * (?: " [ ^ " ] * " ; | ' [ ^ ' ] * ' ; ) ? / ;
348
348
349
- if ( code . match ( commentUseStrictRegex ) ?. [ 0 ] ) {
349
+ const match = code . match ( commentUseStrictRegex ) ?. [ 0 ] ;
350
+
351
+ if ( match ) {
350
352
// Add injected code after any comments or "use strict" at the beginning of the bundle.
351
- ms . replace ( commentUseStrictRegex , ( match ) => ` ${ match } ${ codeToInject } ` ) ;
353
+ ms . appendLeft ( match . length , codeToInject ) ;
352
354
} else {
353
355
// ms.replace() doesn't work when there is an empty string match (which happens if
354
356
// there is neither, a comment, nor a "use strict" at the top of the chunk) so we
You can’t perform that action at this time.
0 commit comments