Skip to content

Commit 5f98f55

Browse files
committed
chore(rewrite-imports): update regex lastIndex
1 parent 0a6222a commit 5f98f55

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

Sources/Interaction/Manipulators/MouseRangeManipulator/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { vtkObject } from '../../../interfaces';
21
import vtkCompositeMouseManipulator, {
32
ICompositeMouseManipulatorInitialValues,
43
} from '../../../Interaction/Manipulators/CompositeMouseManipulator';
4+
import { vtkObject } from '../../../interfaces';
55

66
export interface IMouseRangeManipulatorInitialValues
77
extends ICompositeMouseManipulatorInitialValues {}

Utilities/build/rewrite-imports.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
module.exports = (code, replaceFunc) => {
2-
const importRegex = /(?:import|from) ['"]([^'"]*)['"]/g;
2+
const importRegex = /(?:import|from)\s+['"]([^'"]*)['"]/g;
33
let m;
4-
while ((m = importRegex.exec(code)) !== null) {
4+
while ((m = importRegex.exec(code)) != null) {
55
// This is necessary to avoid infinite loops with zero-width matches
66
if (m.index === importRegex.lastIndex) {
77
importRegex.lastIndex++;
88
}
99

1010
if (m[1].startsWith('../') || m[1].startsWith('./')) {
1111
const importPath = replaceFunc(m[1]);
12+
const origLen = code.length;
1213
code = code.replace(m[0], `from '${importPath}'`);
14+
const lenDiff = code.length - origLen;
15+
importRegex.lastIndex += lenDiff;
1316
}
1417
}
1518
return code;

0 commit comments

Comments
 (0)