File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed
packages/bundler-plugin-core/src Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -443,11 +443,12 @@ export function serializeIgnoreOptions(ignoreValue: string | string[] | undefine
443443export function containsOnlyImports ( code : string ) : boolean {
444444 const codeWithoutImports = code
445445 // Remove side effect imports: import '/path'; or import "./path";
446- . replace ( / ^ \s * i m p o r t \s + ( [ ' " ` ] ) .* ?\1\s * ; ? \s * $ / gm, "" )
446+ // Using explicit negated character classes to avoid polynomial backtracking
447+ . replace ( / ^ \s * i m p o r t \s + (?: ' [ ^ ' \n ] * ' | " [ ^ " \n ] * " | ` [ ^ ` \n ] * ` ) [ \s ; ] * $ / gm, "" )
447448 // Remove named/default imports: import x from '/path'; import { x } from '/path';
448- . replace ( / ^ \s * i m p o r t \s + [ \s \S ] * ? \s + f r o m \s + ( [ ' " ` ] ) . * ?\1 \s * ; ? \s * $ / gm, "" )
449+ . replace ( / ^ \s * i m p o r t \b [ ^ ' " ` \n ] * \b f r o m \s + (?: ' [ ^ ' \n ] * ' | " [ ^ " \n ] * " | ` [ ^ ` \n ] * ` ) [ \s ; ] * $ / gm, "" )
449450 // Remove re-exports: export * from '/path'; export { x } from '/path';
450- . replace ( / ^ \s * e x p o r t \s + [ \s \S ] * ? \s + f r o m \s + ( [ ' " ` ] ) . * ?\1 \s * ; ? \s * $ / gm, "" )
451+ . replace ( / ^ \s * e x p o r t \b [ ^ ' " ` \n ] * \b f r o m \s + (?: ' [ ^ ' \n ] * ' | " [ ^ " \n ] * " | ` [ ^ ` \n ] * ` ) [ \s ; ] * $ / gm, "" )
451452 // Remove block comments
452453 . replace ( / \/ \* [ \s \S ] * ?\* \/ / g, "" )
453454 // Remove line comments
You can’t perform that action at this time.
0 commit comments