Skip to content

Commit 5424051

Browse files
authored
fix: the proxy should not recreated when exists (#3749)
* fix: the proxy should not recreated when exists & fix some minor problems * fix: the proxy should not recreated when exists
1 parent d6aed02 commit 5424051

File tree

5 files changed

+20
-3
lines changed

5 files changed

+20
-3
lines changed

.changeset/big-penguins-count.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'@modern-js/plugin-testing': patch
3+
'@modern-js/app-tools': patch
4+
'@modern-js/plugin-proxy': patch
5+
---
6+
7+
fix: the proxy should not recreated when exists
8+
fix: proxy server 不应该被重新创建当存在时

packages/cli/plugin-proxy/src/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ export default (): CliPlugin => {
2323
}
2424

2525
const rule = createProxyRule(internalDirectory, dev.proxy);
26-
proxyServer = new WhistleProxy({ port: 8899, rule });
27-
await proxyServer.start();
26+
if (!proxyServer) {
27+
proxyServer = new WhistleProxy({ port: 8899, rule });
28+
await proxyServer.start();
29+
}
2830
},
2931

3032
beforeExit() {

packages/runtime/plugin-testing/src/cli/bff/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export const setJestConfigForBFF = async ({
3030
setupFilesAfterEnv: [require.resolve('./setup')],
3131
testEnvironment: 'node',
3232
testMatch: [`**/api/**/*.test.[jt]s`],
33+
modulePathIgnorePatterns: ['config.test.ts'],
3334
globals: {
3435
[bff_info_key]: {
3536
appDir: pwd,

packages/runtime/plugin-testing/tests/bff/__snapshots__/index.test.ts.snap

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ exports[`testing-plugin-bff setJestConfigForBFF 1`] = `
1313
},
1414
},
1515
"moduleNameMapper": {},
16+
"modulePathIgnorePatterns": [
17+
"config.test.ts",
18+
],
1619
"resolver": "/packages/runtime/plugin-testing/src/base/config/resolver.ts",
1720
"rootDir": "/packages/runtime/plugin-testing/tests/bff/fixtures/bff1/api",
1821
"setupFilesAfterEnv": [
@@ -50,6 +53,9 @@ exports[`testing-plugin-bff testTimeout should not set in projects 1`] = `
5053
},
5154
},
5255
"moduleNameMapper": {},
56+
"modulePathIgnorePatterns": [
57+
"config.test.ts",
58+
],
5359
"resolver": "/packages/runtime/plugin-testing/src/base/config/resolver.ts",
5460
"rootDir": "/packages/runtime/plugin-testing/tests/bff/fixtures/bff1/api",
5561
"setupFilesAfterEnv": [

packages/solutions/app-tools/src/analyze/getBundleEntry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export const getBundleEntry = (
9292
: undefined,
9393
};
9494

95-
if (entrypoint.fileSystemRoutes && isRouterV5(config)) {
95+
if (entrypoint.fileSystemRoutes && !isRouterV5(config)) {
9696
entrypoint.nestedRoutesEntry = entrypoint.entry;
9797
}
9898
if (!ifAlreadyExists(defaults, entrypoint)) {

0 commit comments

Comments
 (0)