Skip to content

Commit

Permalink
feat(get-deps): 对应正则的优化之前的太宽泛了
Browse files Browse the repository at this point in the history
  • Loading branch information
sunguohui committed Jul 11, 2023
1 parent 9da1f20 commit 7ab80e5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/vant-cli/src/compiler/get-deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ let existsCache: Record<string, boolean> = {};
// https://regexr.com/47jlq
const IMPORT_RE =
/import\s+?(?:(?:(?:[\w*\s{},]*)\s+from(\s+)?)|)(?:(?:".*?")|(?:'.*?'))[\s]*?(?:;|$|)/g;
const IMPORT_NOF_RE = /import\s*\(\s*?['"].+?['"]\)/g;
const IMPORT_NOF_RE =
/import\s*\(\s*?\S*?(\/\*)?\s*?\S*?.+?\s*?\S*?(\*\/)?['"].+?['"]\s*?\S*?\)/g;
const EXPORT_FROM_RE =
/@?export\s+?(?:(?:(?:[\w*\s{},]*)\s+from(\s+)?)|)(?:(?:".*?")|(?:'.*?'))[\s]*?(?:;|$|)/g;

Expand Down Expand Up @@ -103,7 +104,7 @@ export function getDeps(filePath: string) {
/**
* 1. Replace .vue extension
* @example "import App from 'App.vue';" => "import App from 'App.xxx';"
* @example "defineAsyncComponent(() => import('../xx.vue'))" => "defineAsyncComponent(() => import('../xxx.xxx'));"
* @example "defineAsyncComponent(() => import('../xxx.vue'))" => "defineAsyncComponent(() => import('../xxx.xxx'));"
*
* 2. if using .mjs or .cjs, complete the import path
* @example import './foo' -> import './foo.mjs'
Expand Down

0 comments on commit 7ab80e5

Please sign in to comment.