mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
perf: dynamic import demo file
This commit is contained in:
parent
5ecf7460cf
commit
b4be171028
@ -17,17 +17,17 @@ type DemoItem = {
|
||||
};
|
||||
|
||||
function genInstall() {
|
||||
return `import packageEntry from './package-entry';
|
||||
return `import { defineAsyncComponent } from 'vue';
|
||||
import './package-style.less';
|
||||
`;
|
||||
}
|
||||
|
||||
function genImports(demos: DemoItem[]) {
|
||||
return demos
|
||||
.map(
|
||||
(item) =>
|
||||
`import ${item.name} from '${removeExt(normalizePath(item.path))}';`
|
||||
)
|
||||
.map((item) => {
|
||||
const path = removeExt(normalizePath(item.path));
|
||||
return `const ${item.name} = defineAsyncComponent(() => import('${path}'))`;
|
||||
})
|
||||
.join('\n');
|
||||
}
|
||||
|
||||
@ -82,8 +82,6 @@ function genCode(components: string[]) {
|
||||
return `${genInstall()}
|
||||
${genImports(demos)}
|
||||
|
||||
export { packageEntry };
|
||||
|
||||
${getSetName(demos)}
|
||||
|
||||
${genExports(demos)}
|
||||
|
Loading…
x
Reference in New Issue
Block a user