perf(cli): code split documents (#11111)

This commit is contained in:
neverland 2022-10-04 08:47:43 +08:00 committed by chenjiahan
parent a2d1280044
commit a0d07a373b

View File

@ -1,12 +1,7 @@
import glob from 'fast-glob'; import glob from 'fast-glob';
import { join, parse } from 'path'; import { join, parse } from 'path';
import { existsSync, readFileSync, readdirSync } from 'fs'; import { existsSync, readFileSync, readdirSync } from 'fs';
import { import { pascalize, getVantConfig, normalizePath } from '../common/index.js';
isDev,
pascalize,
getVantConfig,
normalizePath,
} from '../common/index.js';
import { import {
SRC_DIR, SRC_DIR,
DOCS_DIR, DOCS_DIR,
@ -80,10 +75,7 @@ function genImportDocuments(items: DocumentItem[]) {
return items return items
.map((item) => { .map((item) => {
const path = normalizePath(item.path); const path = normalizePath(item.path);
if (isDev()) { return `const ${item.name} = () => import('${path}');`;
return `const ${item.name} = () => import('${path}');`;
}
return `import ${item.name} from '${path}';`;
}) })
.join('\n'); .join('\n');
} }