From 73cd61aa3d847a1a61322eaf7950f01cd0c77a2d Mon Sep 17 00:00:00 2001 From: Gao Yang Date: Sun, 14 Mar 2021 15:46:15 +0800 Subject: [PATCH] fix: serverless app layers (#903) Co-authored-by: Harry Chen --- packages-serverless/serverless-app/package.json | 1 - packages-serverless/serverless-app/src/index.ts | 9 +-------- .../serverless-app/test/intergration-v2.test.ts | 4 +++- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/packages-serverless/serverless-app/package.json b/packages-serverless/serverless-app/package.json index 3f9ecab942dc..67ddb53c58ac 100644 --- a/packages-serverless/serverless-app/package.json +++ b/packages-serverless/serverless-app/package.json @@ -7,7 +7,6 @@ "@midwayjs/bootstrap": "^2.8.11", "@midwayjs/core": "^2.8.11", "@midwayjs/gateway-common-http": "^1.2.41", - "@midwayjs/locate": "^1.4.1", "@midwayjs/serverless-spec-builder": "^1.2.41", "body-parser": "^1.19.0", "express": "^4.17.1" diff --git a/packages-serverless/serverless-app/src/index.ts b/packages-serverless/serverless-app/src/index.ts index c538824b8a46..94cdc959725b 100644 --- a/packages-serverless/serverless-app/src/index.ts +++ b/packages-serverless/serverless-app/src/index.ts @@ -6,7 +6,6 @@ import { IMidwayFramework, MidwayFrameworkType, } from '@midwayjs/core'; -import { isTypeScriptEnvironment } from '@midwayjs/bootstrap'; import { Server } from 'net'; import { start2 } from './start'; import * as express from 'express'; @@ -14,7 +13,6 @@ import * as bodyParser from 'body-parser'; import { getSpecFile, loadSpec } from '@midwayjs/serverless-spec-builder'; import { createExpressGateway } from '@midwayjs/gateway-common-http'; import { findNpmModule, output404 } from './utils'; -import { Locator } from '@midwayjs/locate'; import { StarterMap, TriggerMap } from './platform'; import { IServerlessApp, IServerlessAppOptions } from './interface'; @@ -195,12 +193,7 @@ export class Framework } // 分析项目结构 - let currentBaseDir = baseDir; - if (isTypeScriptEnvironment()) { - const locator = new Locator(appDir); - const midwayLocatorResult = await locator.run({}); - currentBaseDir = midwayLocatorResult.tsCodeRoot; - } + const currentBaseDir = baseDir; const triggerMap = this.getTriggerMap(); const layers = this.getLayers(); diff --git a/packages-serverless/serverless-app/test/intergration-v2.test.ts b/packages-serverless/serverless-app/test/intergration-v2.test.ts index d986f904f376..a5b270516e46 100644 --- a/packages-serverless/serverless-app/test/intergration-v2.test.ts +++ b/packages-serverless/serverless-app/test/intergration-v2.test.ts @@ -11,7 +11,9 @@ describe('test/index.test.ts', () => { } let app; beforeAll(async () => { - app = await createApp(cwd, {}, join(__dirname, '../src')); + app = await createApp(cwd, { + baseDir: join(cwd, 'src/apis'), + }, join(__dirname, '../src')); }); afterAll(async () => { await close(app);