fix: window下vuex插件路径

This commit is contained in:
aringlai 2021-03-04 14:19:37 +08:00
parent c65e1c089c
commit adfc7651f9
2 changed files with 1335 additions and 576 deletions

View File

@ -1,6 +1,6 @@
import { parser } from '@umijs/utils'; import { parser } from '@umijs/utils';
import { readdirSync, readFileSync, statSync } from 'fs'; import { readdirSync, readFileSync, statSync } from 'fs';
import { join } from 'path'; import { join, sep } from 'path';
/** /**
* 获取文件夹所有JS文件路径 * 获取文件夹所有JS文件路径
@ -28,7 +28,7 @@ function getDirFilePaths(dir) {
function pathToHump(path, root) { function pathToHump(path, root) {
return path.replace(root, '') return path.replace(root, '')
.replace('.js', '') .replace('.js', '')
.replace(/(\/|\.|-|_)\S/g, text => text[1].toUpperCase()) .replace(RegExp(`(${sep}|\\.|-|_)\\S`, 'g'), text => text[1].toUpperCase())
.replace(/\S/, text => text.toLowerCase()); .replace(/\S/, text => text.toLowerCase());
} }
@ -102,7 +102,7 @@ function parseModel(paths = [], root) {
let GETTER_TYPES = {}; let GETTER_TYPES = {};
paths.forEach((path) => { paths.forEach((path) => {
const moduleName = pathToHump(path, root); const moduleName = pathToHump(path, root);
importModules.push(`import ${moduleName} from '${path}'`); importModules.push(`import ${moduleName} from '${path.replace(/\\/g, '\\\\')}'`);
modules.push(moduleName); modules.push(moduleName);
const content = readFileSync(path).toString('utf-8'); const content = readFileSync(path).toString('utf-8');
let ast = parser.parse(content, { let ast = parser.parse(content, {

1905
yarn.lock

File diff suppressed because it is too large Load Diff