mirror of
https://github.com/WeBankFinTech/fes.js.git
synced 2025-04-06 03:59:53 +08:00
feat: 重命令某些命令,符合规范
This commit is contained in:
parent
7ea206707b
commit
b3a73ab6c5
@ -3,7 +3,7 @@ import { chokidar, winPath, lodash } from '@umijs/utils';
|
||||
import { existsSync, readFileSync } from 'fs';
|
||||
import { isPlugin, PluginType } from '@webank/fes-core';
|
||||
|
||||
function getFesPlugins(opts) {
|
||||
function getPlugins(opts) {
|
||||
return Object.keys({
|
||||
...opts.pkg.dependencies,
|
||||
...opts.pkg.devDependencies
|
||||
@ -12,7 +12,7 @@ function getFesPlugins(opts) {
|
||||
));
|
||||
}
|
||||
|
||||
function getFesPluginsFromPkgPath(opts) {
|
||||
function getPluginsFromPkgPath(opts) {
|
||||
let pkg = {};
|
||||
if (existsSync(opts.pkgPath)) {
|
||||
try {
|
||||
@ -21,17 +21,17 @@ function getFesPluginsFromPkgPath(opts) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
return getFesPlugins({ pkg });
|
||||
return getPlugins({ pkg });
|
||||
}
|
||||
|
||||
export function watchPkg(opts) {
|
||||
const pkgPath = join(opts.cwd, 'package.json');
|
||||
const plugins = getFesPluginsFromPkgPath({ pkgPath });
|
||||
const plugins = getPluginsFromPkgPath({ pkgPath });
|
||||
const watcher = chokidar.watch(pkgPath, {
|
||||
ignoreInitial: true
|
||||
});
|
||||
watcher.on('all', () => {
|
||||
const newPlugins = getFesPluginsFromPkgPath({ pkgPath });
|
||||
const newPlugins = getPluginsFromPkgPath({ pkgPath });
|
||||
if (!lodash.isEqual(plugins, newPlugins)) {
|
||||
// 已经重启了,只处理一次就够了
|
||||
opts.onChange();
|
||||
|
@ -21,7 +21,6 @@ export default (api) => {
|
||||
]);
|
||||
webpackConfig.module
|
||||
.rule('js-in-node_modules').use('babel-loader').tap((options) => {
|
||||
console.log(options);
|
||||
options.cacheDirectory = winPath(`${prefix}/.fes/.cache/babel-loader`);
|
||||
return options;
|
||||
});
|
||||
|
@ -2,12 +2,12 @@ import { lodash, winPath } from '@umijs/utils';
|
||||
import assert from 'assert';
|
||||
|
||||
const reserveLibrarys = ['fes']; // reserve library
|
||||
// todo 插件导出内容冲突问题待解决
|
||||
const reserveExportsNames = [
|
||||
'Link',
|
||||
'NavLink',
|
||||
'Redirect',
|
||||
'dynamic',
|
||||
'router',
|
||||
'withRouter',
|
||||
'Route'
|
||||
];
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { createRouter, createWebHashHistory } from '{{{ runtimePath }}}';
|
||||
import { createRouter as createVueRouter, createWebHashHistory } from '{{{ runtimePath }}}';
|
||||
|
||||
export function getRoutes() {
|
||||
const routes = {{{ routes }}};
|
||||
@ -7,11 +7,11 @@ export function getRoutes() {
|
||||
}
|
||||
|
||||
let router = null;
|
||||
export const createHistory = () => {
|
||||
export const createRouter = () => {
|
||||
if (router) {
|
||||
return router;
|
||||
}
|
||||
router = createRouter({
|
||||
router = createVueRouter({
|
||||
history: createWebHashHistory(),
|
||||
routes: getRoutes()
|
||||
});
|
||||
|
@ -7,7 +7,7 @@ import {
|
||||
import { plugin } from './core/plugin';
|
||||
import './core/pluginRegister';
|
||||
import { ApplyPluginsType } from '{{{ runtimePath }}}';
|
||||
import { createRouter } from './core/routes';
|
||||
import { createRouter, getRoutes } from './core/routes';
|
||||
{{{ imports }}}
|
||||
|
||||
{{{ entryCodeAhead }}}
|
||||
|
Loading…
x
Reference in New Issue
Block a user