mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
fix(cli): compatible with export { default }
This commit is contained in:
parent
8318cfb1e8
commit
85d735e669
@ -26,6 +26,10 @@ export function replaceExt(path: string, ext: string) {
|
|||||||
return path.replace(EXT_REGEXP, ext);
|
return path.replace(EXT_REGEXP, ext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function hasDefaultExport(code: string) {
|
||||||
|
return code.includes('export default') || code.includes('export { default }');
|
||||||
|
}
|
||||||
|
|
||||||
export function getComponents() {
|
export function getComponents() {
|
||||||
const EXCLUDES = ['.DS_Store'];
|
const EXCLUDES = ['.DS_Store'];
|
||||||
const dirs = readdirSync(SRC_DIR);
|
const dirs = readdirSync(SRC_DIR);
|
||||||
@ -35,7 +39,7 @@ export function getComponents() {
|
|||||||
ENTRY_EXTS.some(ext => {
|
ENTRY_EXTS.some(ext => {
|
||||||
const path = join(SRC_DIR, dir, `index.${ext}`);
|
const path = join(SRC_DIR, dir, `index.${ext}`);
|
||||||
if (existsSync(path)) {
|
if (existsSync(path)) {
|
||||||
return readFileSync(path, 'utf-8').indexOf('export default') !== -1;
|
return hasDefaultExport(readFileSync(path, 'utf-8'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user