Skip to content

Commit

Permalink
fix: allow accents in import names
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed May 11, 2023
1 parent a4d1239 commit f92ed49
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/analyze.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export interface DefaultExport extends ESMExport {
}

export const ESM_STATIC_IMPORT_RE =
/(?<=\s|^|;)import\s*([\s"']*(?<imports>[\w\t\n\r $*,/{}]+)from\s*)?["']\s*(?<specifier>(?<="\s*)[^"]*[^\s"](?=\s*")|(?<='\s*)[^']*[^\s'](?=\s*'))\s*["'][\s;]*/gm;
/(?<=\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;

Expand Down
6 changes: 6 additions & 0 deletions test/imports.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ const staticTests = {
],
// Edge cases
'"import"===node.object.meta.name&&"': [],
'import { SpecialÜ } from "#components"': [
{
namedImports: { SpecialÜ: "SpecialÜ" },
specifier: "#components",
},
],
};

staticTests[
Expand Down

0 comments on commit f92ed49

Please sign in to comment.