Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ module.exports = {
server: {
entry: '', // 服务端入口
port: 8088, // 服务端口号
contentBase: 'public', // 静态文件地址
options: {
// 服务端回调参数
},
Expand Down Expand Up @@ -253,7 +252,6 @@ npx micro-app show methods
* onServerRunFail ( 服务运行启动失败时事件 )
* beforeServerEntry ( 服务进入业务逻辑前事件 )
* afterServerEntry ( 服务从业务逻辑出来后事件 )
* modifyWebpackConfig ( 对服务启动前对 webpack config 进行修改, 需要返回所有参数 )
* beforeDevServer ( 开发服务创建前事件 )
* afterDevServer ( 开发服务创建后事件 )
* onBuildSuccess ( 构建成功时事件 )
Expand Down
2 changes: 1 addition & 1 deletion config/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ module.exports = {
NODE_MODULES_NAME: 'node_modules',
SCOPE_NAME: '@micro-app', // namespace
CONFIG_NAME: 'micro-app.config.js',
EXTRAL_CONFIG_NAME: 'micro-app.extra.config.js',
TYPES: [], // support types
INJECT_ID: '_MICRO_APP_INJECT_',
NODE_ENV: process.env.NODE_ENV || 'production', // "production" | "development"
PACKAGE_JSON: 'package.json',
};
14 changes: 0 additions & 14 deletions config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ module.exports = {
// },
],

webpack: { // webpack 配置信息 (只有自己为主容器时,才会使用)
},

alias: { // 共享别名
// api: './client/api.js', // 默认为前后端通用
// service: {
Expand All @@ -41,10 +38,6 @@ module.exports = {
micros: [ // 需要注入的子模块
// 'test'
],
// micros$$test: { // 单独配置
// disabled: true, // 禁用入口
// lnk: '‘, // 软链接, 用于本地调试
// },

// 服务端配置
server: {
Expand All @@ -53,7 +46,6 @@ module.exports = {
// host: ‘’, // 服务 IP
// port: 8888, // 服务端口号
// options: { }, // 服务端注入附加参数
// contentBase: '', // 服务端静态文件目录

// proxy: { // 服务代理
// '/api': {
Expand All @@ -64,12 +56,6 @@ module.exports = {
// },
},

// 自动向主容器同步 package.json
deploy: {
// git: 'ssh://git@....git',
// branch: 'develop',
},

// 一些插件配置项 (弃用)
// plugin: {
// ReplaceFileNotExists: {
Expand Down
60 changes: 5 additions & 55 deletions libs/MicroAppConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,8 @@ class MicroAppConfig {
return config[symbols.ORIGINAL_ROOT] || this.root || '';
}

get isOpenSoftLink() {
const MicroAppConfig = this.globalMicroAppConfig;
return MicroAppConfig.OPEN_SOFT_LINK && this.root !== this.originalRoot;
get hasSoftLink() {
return this.root !== this.originalRoot;
}

get path() {
Expand All @@ -96,7 +95,7 @@ class MicroAppConfig {
}

get mode() {
return CONSTANTS.NODE_ENV || 'production';
return process.env.NODE_ENV || 'production'; // "production" | "development"
}

get isDev() {
Expand Down Expand Up @@ -285,38 +284,6 @@ class MicroAppConfig {
return [];
}

get globalMicroAppConfig() {
const MicroAppConfig = global.MicroAppConfig;
if (MicroAppConfig && _.isPlainObject(MicroAppConfig)) {
return _.cloneDeep(MicroAppConfig);
}
return {};
}

// TODO 拆离
get microsExtral() {
const config = this.config;
const result = {};
const MicroAppConfig = this.globalMicroAppConfig;
this.micros.forEach(micro => {
result[micro] = Object.assign({}, config[`micros$$${micro}`] || {
disabled: false, // 禁用入口
disable: false,
link: false,
});

// 附加内容需要参考全局配置
if (!MicroAppConfig.OPEN_SOFT_LINK) { // 强制禁止使用 软链接
result[micro].link = false;
}
if (!MicroAppConfig.OPEN_DISABLED_ENTRY) { // 强制禁止使用 开启禁用指定模块入口, 优化开发速度
result[micro].disabled = false;
result[micro].disable = false;
}
});
return result;
}

// 后端共享
get _shared() {
const config = this.config;
Expand Down Expand Up @@ -431,12 +398,6 @@ class MicroAppConfig {
return alias;
}

// TODO 拆离
get deploy() {
const config = this.config;
return config.deploy;
}

// server
get server() {
const config = this.config;
Expand All @@ -453,16 +414,6 @@ class MicroAppConfig {
return server.port;
}

get contentBase() {
const server = this.server;
if (server.contentBase) {
return path.resolve(this.root, server.contentBase);
} else if (server.staticBase) {
return path.resolve(this.root, server.staticBase);
}
return '.';
}

// 服务代理
get proxy() {
const server = this.server;
Expand Down Expand Up @@ -491,7 +442,7 @@ class MicroAppConfig {
p = p.link;
}
id = id || p;
if (!tryRequire.resolve(p)) {
if (p && !tryRequire.resolve(p)) {
p = path.resolve(this.root, p);
}
return {
Expand All @@ -514,7 +465,7 @@ class MicroAppConfig {
root: this.root,
nodeModules: this.nodeModules,
originalRoot: this.originalRoot,
isOpenSoftLink: this.isOpenSoftLink,
hasSoftLink: this.hasSoftLink,
};
if (notSimple) {
json.micros = this.micros;
Expand Down Expand Up @@ -556,7 +507,6 @@ class MicroAppConfig {
shared: this.shared,
sharedObj: this._shared,
resolveShared: this.resolveShared,
contentBase: this.contentBase,
port: this.port,
host: this.host,
proxy: this.proxy,
Expand Down
132 changes: 0 additions & 132 deletions libs/Service/Base.js

This file was deleted.

18 changes: 0 additions & 18 deletions libs/Service/BaseAPI.js

This file was deleted.

4 changes: 4 additions & 0 deletions libs/Service/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@ const contants = {
};
}),

// service 对 pluginAPI 暴露的所有方法
SharedProps: [
'root',
'mode',
'strictMode',
'env',
'version',
'pkg',
'microsExtraConfig', 'microsExtralConfig',
'applyPluginHooks',
'applyPluginHooksAsync',
'resolvePlugin',
Expand Down
Loading