mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
chore(@vant/cli): fix vue-router async component warning
This commit is contained in:
parent
e20b05e10b
commit
0dfb594bd5
@ -83,7 +83,7 @@ function genImportDocuments(items: DocumentItem[]) {
|
|||||||
.map((item) => {
|
.map((item) => {
|
||||||
const path = normalizePath(item.path);
|
const path = normalizePath(item.path);
|
||||||
if (isDev()) {
|
if (isDev()) {
|
||||||
return `const ${item.name} = defineAsyncComponent(() => import('${path}'));`;
|
return `const ${item.name} = () => import('${path}');`;
|
||||||
}
|
}
|
||||||
return `import ${item.name} from '${path}';`;
|
return `import ${item.name} from '${path}';`;
|
||||||
})
|
})
|
||||||
@ -113,8 +113,7 @@ export function genSiteDesktopShared() {
|
|||||||
const dirs = readdirSync(SRC_DIR);
|
const dirs = readdirSync(SRC_DIR);
|
||||||
const documents = resolveDocuments(dirs);
|
const documents = resolveDocuments(dirs);
|
||||||
|
|
||||||
const code = `import { defineAsyncComponent } from 'vue';
|
const code = `${genImportDocuments(documents)}
|
||||||
${genImportDocuments(documents)}
|
|
||||||
|
|
||||||
${genVantConfigContent()}
|
${genVantConfigContent()}
|
||||||
|
|
||||||
|
@ -16,17 +16,11 @@ type DemoItem = {
|
|||||||
component: string;
|
component: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
function genInstall() {
|
|
||||||
return `import { defineAsyncComponent } from 'vue';
|
|
||||||
import './package-style.less';
|
|
||||||
`;
|
|
||||||
}
|
|
||||||
|
|
||||||
function genImports(demos: DemoItem[]) {
|
function genImports(demos: DemoItem[]) {
|
||||||
return demos
|
return demos
|
||||||
.map((item) => {
|
.map((item) => {
|
||||||
const path = removeExt(normalizePath(item.path));
|
const path = removeExt(normalizePath(item.path));
|
||||||
return `const ${item.name} = defineAsyncComponent(() => import('${path}'))`;
|
return `const ${item.name} = () => import('${path}')`;
|
||||||
})
|
})
|
||||||
.join('\n');
|
.join('\n');
|
||||||
}
|
}
|
||||||
@ -37,12 +31,6 @@ function genExports(demos: DemoItem[]) {
|
|||||||
.join(',\n ')}\n};`;
|
.join(',\n ')}\n};`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSetName(demos: DemoItem[]) {
|
|
||||||
return demos
|
|
||||||
.map((item) => `${item.name}.name = 'demo-${item.component}';`)
|
|
||||||
.join('\n');
|
|
||||||
}
|
|
||||||
|
|
||||||
function genConfig(demos: DemoItem[]) {
|
function genConfig(demos: DemoItem[]) {
|
||||||
const vantConfig = getVantConfig();
|
const vantConfig = getVantConfig();
|
||||||
const demoNames = demos.map((item) => decamelize(item.name));
|
const demoNames = demos.map((item) => decamelize(item.name));
|
||||||
@ -79,11 +67,9 @@ function genCode(components: string[]) {
|
|||||||
}))
|
}))
|
||||||
.filter((item) => existsSync(item.path));
|
.filter((item) => existsSync(item.path));
|
||||||
|
|
||||||
return `${genInstall()}
|
return `import './package-style.less';
|
||||||
${genImports(demos)}
|
${genImports(demos)}
|
||||||
|
|
||||||
${getSetName(demos)}
|
|
||||||
|
|
||||||
${genExports(demos)}
|
${genExports(demos)}
|
||||||
${genConfig(demos)}
|
${genConfig(demos)}
|
||||||
`;
|
`;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user