Skip to content

Commit

Permalink
fix: fix import and export regex to accurately match whitespace, incl…
Browse files Browse the repository at this point in the history
…uding newlines
  • Loading branch information
kotarella1110 committed Sep 27, 2023
1 parent 988a0ac commit 4913caa
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/steps/generateChanges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import { normalizePath } from "~/utils/path";
import type { Alias, Change, ProgramPaths, TextChange } from "~/types";

export const IMPORT_EXPORT_REGEX =
/((?:require\(|require\.resolve\(|import\()|(?:import|export) (?:.*from )?)['"]([^'"]*)['"]\)?/g;
/((?:require\(|require\.resolve\(|import\()|(?:import|export)\s+(?:[\s\S]*?from\s+)?)['"]([^'"]*)['"]\)?/g;

export const ESM_IMPORT_EXPORT_REGEX =
/(?:(?:import\()|(?:import|export)\s+(?:.*from\s+)?)['"]([^'"]*)['"]\)?/g;
/(?:(?:import\()|(?:import|export)\s+(?:[\s\S]*?from\s+)?)['"]([^'"]*)['"]\)?/g

export const COMMONJS_IMPORT_EXPORT_REGEX =
/(?:(?:require\(|require\.resolve\()\s+)['"]([^'"]*)['"]\)/g;
Expand Down

0 comments on commit 4913caa

Please sign in to comment.