Skip to content

Commit

Permalink
fix: load custom framework in midwayjs/web (#883)
Browse files Browse the repository at this point in the history
  • Loading branch information
czy88840616 authored Mar 3, 2021
1 parent 1201d6f commit 7a11cac
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions packages-serverless/egg-layer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ module.exports = engine => {
// 从 package.json 中获取 egg 框架
const packageJSON = require(resolve(baseDir, 'package.json'));
framework = packageJSON.egg && packageJSON.egg.framework;
// 支持自定义框架
if (
packageJSON['dependencies'] &&
packageJSON['dependencies']['@midwayjs/web'] &&
framework !== '@midwayjs/web'
) {
framework = '@midwayjs/web';
}
const localFrameWorkPath = resolve(__dirname, 'framework');
require(localFrameWorkPath).getFramework(
process.env.EGG_FRAMEWORK_DIR ||
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/util/webRouterCollector.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LightFramework } from './emptyFramework';
import { EmptyFramework } from './emptyFramework';
import {
CONTROLLER_KEY,
ControllerOption,
Expand Down Expand Up @@ -90,7 +90,7 @@ export class WebRouterCollector {

protected async analyze() {
if (!MidwayContainer.parentDefinitionMetadata) {
const framework = new LightFramework();
const framework = new EmptyFramework();
await framework.initialize({
baseDir: this.baseDir,
});
Expand Down

0 comments on commit 7a11cac

Please sign in to comment.