Skip to content

Commit

Permalink
fix(findStaticImports): support special chars in import specifiers (r…
Browse files Browse the repository at this point in the history
…esolves #169)
  • Loading branch information
pi0 committed Jun 20, 2023
1 parent 70a22ad commit c4159e5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/analyze.ts
Expand Up @@ -62,7 +62,7 @@ export interface DefaultExport extends ESMExport {
}

export const ESM_STATIC_IMPORT_RE =
/(?<=\s|^|;)import\s*([\s"']*(?<imports>[\p{L}\p{M}\w\t\n\r $*,/{}]+)from\s*)?["']\s*(?<specifier>(?<="\s*)[^"]*[^\s"](?=\s*")|(?<='\s*)[^']*[^\s'](?=\s*'))\s*["'][\s;]*/gmu;
/(?<=\s|^|;)import\s*([\s"']*(?<imports>[\p{L}\p{M}\w\t\n\r $*,/{}@.]+)from\s*)?["']\s*(?<specifier>(?<="\s*)[^"]*[^\s"](?=\s*")|(?<='\s*)[^']*[^\s'](?=\s*'))\s*["'][\s;]*/gmu;
export const DYNAMIC_IMPORT_RE =
/import\s*\((?<expression>(?:[^()]+|\((?:[^()]+|\([^()]*\))*\))*)\)/gm;
const IMPORT_NAMED_TYPE_RE =
Expand Down
2 changes: 1 addition & 1 deletion test/imports.test.ts
Expand Up @@ -102,7 +102,7 @@ const c = ['.mjs', '.cjs', '.js', '.json']
staticTests[
`import {
member1,
// test
// @hello.123
member2
} from "module-name";`
] = {
Expand Down

0 comments on commit c4159e5

Please sign in to comment.