Skip to content

Commit b4b1101

Browse files
authored
Rename microfrontends.json to microfrontends-custom.jsonc (#5)
1 parent 04d5bfc commit b4b1101

File tree

9 files changed

+98
-68
lines changed

9 files changed

+98
-68
lines changed

.github/workflows/ci.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,27 @@ jobs:
3434
uses: actions/setup-node@v4
3535
with:
3636
node-version: ${{ matrix.node-version }}
37-
cache: 'pnpm'
37+
cache: "pnpm"
3838

3939
- name: Install Dependencies
4040
id: pnpm-install
4141
run: pnpm install --frozen-lockfile
4242

43+
- name: Pull Vercel Environment Variables for nextjs-app example
44+
env:
45+
VERCEL_TOKEN_E2E: ${{ secrets.VERCEL_TOKEN_E2E }}
46+
run: |
47+
pnpm install -g vercel
48+
echo "Fetching env for nextjs-app/docs..."
49+
vercel link --cwd examples/nextjs-app/docs --scope microfrontends-vtest314 --project nextjs-app-docs --yes --token $VERCEL_TOKEN_E2E
50+
cd examples/nextjs-app/docs
51+
vercel env pull .env --token $VERCEL_TOKEN_E2E
52+
cd ../../../
53+
echo "Fetching env for appjs-app/marketing..."
54+
vercel link --cwd examples/nextjs-app/marketing --scope microfrontends-vtest314 --project nextjs-app-marketing --yes --token $VERCEL_TOKEN_E2E
55+
cd examples/nextjs-app/marketing
56+
vercel env pull .env --token $VERCEL_TOKEN_E2E
57+
cd ../../../
58+
4359
- name: Run CI
4460
run: pnpm turbo typecheck lint test test:local-proxy-turbo-integration --continue
Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,68 @@
1-
// TODO: delete this file when the build container support custom microfrontends.json naming
21
{
32
"$schema": "https://openapi.vercel.sh/microfrontends.json",
43
"applications": {
54
"nextjs-app-marketing": {
65
"development": {
76
"local": 3000,
8-
"fallback": "nextjs-app-marketing.vercel.app",
9-
},
7+
"fallback": "nextjs-app-marketing.vercel.app"
8+
}
109
},
1110
"nextjs-app-docs": {
1211
"assetPrefix": "nextjs-app-docs",
1312
"development": {
14-
"local": 3001,
13+
"local": 3001
1514
},
1615
"routing": [
1716
{
1817
"group": "docs",
19-
"paths": ["/docs", "/docs/:path*", "/nextjs-app-docs/:path*"],
18+
"paths": ["/docs", "/docs/:path*", "/nextjs-app-docs/:path*"]
2019
},
2120
{
2221
"group": "flagged-docs-paths",
2322
"flag": "is-flagged-docs-path-enabled",
24-
"paths": ["/flagged/docs"],
23+
"paths": ["/flagged/docs"]
2524
},
2625
{
2726
"group": "mid-path-wildcard",
28-
"paths": ["/some-:hash.js"],
27+
"paths": ["/some-:hash.js"]
2928
},
3029
{
3130
"group": "excluding regex",
32-
"paths": ["/city/:path((?!berlin|amsterdam).*)"],
31+
"paths": ["/city/:path((?!berlin|amsterdam).*)"]
3332
},
3433
{
3534
"group": "special characters",
36-
"paths": ["/foo/hello\\(world\\)"],
35+
"paths": ["/foo/hello\\(world\\)"]
3736
},
3837
{
3938
"group": "dashes",
40-
"paths": ["/foo/hello-world", "/foo/hello~world", "/foo/hello_world"],
39+
"paths": ["/foo/hello-world", "/foo/hello~world", "/foo/hello_world"]
4140
},
4241
{
4342
"group": "regex with numbers",
44-
"paths": ["/foo/:path(hello1|hello2)"],
43+
"paths": ["/foo/:path(hello1|hello2)"]
4544
},
4645
{
4746
"group": "regex with dashes",
48-
"paths": ["/foo/:path(hello-1|hello-2)"],
47+
"paths": ["/foo/:path(hello-1|hello-2)"]
4948
},
5049
{
5150
"group": "regex with escaped characters",
52-
"paths": ["/foo/:path(hello\\(1\\)|1)"],
51+
"paths": ["/foo/:path(hello\\(1\\)|1)"]
5352
},
5453
{
5554
"group": "excluding regex with dashes",
56-
"paths": ["/foo/:path((?!hello\\-3).*)"],
55+
"paths": ["/foo/:path((?!hello\\-3).*)"]
5756
},
5857
{
5958
"group": "path with escaped characters",
60-
"paths": ["/bar/hello\\(3\\)"],
59+
"paths": ["/bar/hello\\(3\\)"]
6160
},
6261
{
6362
"group": "child rate limit",
64-
"paths": ["/api/check-rate-limit"],
65-
},
66-
],
67-
},
68-
},
63+
"paths": ["/api/check-rate-limit"]
64+
}
65+
]
66+
}
67+
}
6968
}

examples/nextjs-app/marketing/tests/microfrontends.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { validateRouting } from '@vercel/microfrontends/next/testing';
55
describe('microfrontends', () => {
66
test('routing', () => {
77
expect(() =>
8-
validateRouting('./microfrontends.jsonc', {
8+
validateRouting('./microfrontends-custom.jsonc', {
99
'nextjs-app-marketing': ['/', '/city/amsterdam', '/flagged/docs'],
1010
'nextjs-app-docs': [
1111
'/docs',

examples/nextjs-app/marketing/tests/middleware.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,16 @@ jest.mock('flags/next', () => ({
1313
describe('middleware', () => {
1414
test('matches microfrontends paths', () => {
1515
expect(() =>
16-
validateMiddlewareConfig(config, './microfrontends.jsonc'),
16+
validateMiddlewareConfig(config, './microfrontends-custom.jsonc'),
1717
).not.toThrow();
1818
});
1919

2020
test('rewrites for flagged paths', async () => {
2121
await expect(
22-
validateMiddlewareOnFlaggedPaths('./microfrontends.jsonc', middleware),
22+
validateMiddlewareOnFlaggedPaths(
23+
'./microfrontends-custom.jsonc',
24+
middleware,
25+
),
2326
).resolves.not.toThrow();
2427
});
2528
});

examples/nextjs-app/marketing/tests/next-config.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ describe('next.config.ts', () => {
3434

3535
it('next.config.js redirects and rewrites should not match any microfrontend path', async () => {
3636
const mfeConfig = loadMicrofrontendConfigForEdge(
37-
'./microfrontends.jsonc',
37+
'./microfrontends-custom.jsonc',
3838
);
3939
const allPaths = [...getAllMicrofrontendPaths(mfeConfig)];
4040
const errors = [];

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"build:single-spa-example": "turbo build -F single-spa-root -F single-spa-web -F single-spa-shared",
1717
"changeset": "changeset",
1818
"checks": "turbo run build lint test typecheck --continue",
19-
"dev:nextjs-app": "turbo dev -F nextjs-app-docs -F nextjs-app-marketing",
19+
"dev:nextjs-app": "VC_MICROFRONTENDS_CONFIG_FILE_NAME=microfrontends-custom.jsonc turbo dev -F nextjs-app-docs -F nextjs-app-marketing",
2020
"dev:nextjs-pages": "turbo dev -F nextjs-pages-dashboard -F nextjs-pages-blog",
2121
"dev:react-router": "turbo dev -F react-router-web -F react-router-docs -F react-router-vite-base-path-different-than-vercel-project-name",
2222
"dev:single-spa": "turbo dev -F single-spa-root -F single-spa-web -F single-spa-shared",
@@ -48,7 +48,7 @@
4848
"lint-staged": "^15.4.3",
4949
"prettier": "^3.4.2",
5050
"syncpack": "^13.0.1",
51-
"turbo": "2.5.2-canary.0",
51+
"turbo": "2.6.0",
5252
"typescript": "5.7.3"
5353
},
5454
"packageManager": "[email protected]",

packages/internal-scripts/src/test-local-proxy-start.ts

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,23 @@ import { join } from 'node:path';
44
const WORKSPACE_ROOT = join(process.cwd(), '..', '..');
55

66
const DEV_TASKS = [
7-
'nextjs-app-docs#dev',
8-
'nextjs-app-marketing#dev',
9-
'nextjs-pages-blog#dev',
10-
'nextjs-pages-dashboard#dev',
11-
'react-router-docs#dev',
12-
'react-router-vite-base-path-different-than-vercel-project-name#dev',
13-
'react-router-web#dev',
14-
'sveltekit-docs#dev',
15-
'sveltekit-web#dev',
7+
{
8+
task: 'nextjs-app-docs#dev',
9+
env: { VC_MICROFRONTENDS_CONFIG_FILE_NAME: 'microfrontends-custom.jsonc' },
10+
},
11+
{
12+
task: 'nextjs-app-marketing#dev',
13+
env: { VC_MICROFRONTENDS_CONFIG_FILE_NAME: 'microfrontends-custom.jsonc' },
14+
},
15+
{ task: 'nextjs-pages-blog#dev' },
16+
{ task: 'nextjs-pages-dashboard#dev' },
17+
{ task: 'react-router-docs#dev' },
18+
{
19+
task: 'react-router-vite-base-path-different-than-vercel-project-name#dev',
20+
},
21+
{ task: 'react-router-web#dev' },
22+
{ task: 'sveltekit-docs#dev' },
23+
{ task: 'sveltekit-web#dev' },
1624
];
1725

1826
interface DryRunOutput {
@@ -27,7 +35,7 @@ function main() {
2735
const missingProxyTask = [];
2836
const failed = [];
2937
for (const { devTask, hasProxyTask, errorMessage } of DEV_TASKS.map(
30-
checkDevTask,
38+
({ task, env }) => checkDevTask(task, env),
3139
)) {
3240
if (errorMessage) {
3341
failed.push(`${devTask}: turbo dry run failed: ${errorMessage}`);
@@ -45,7 +53,10 @@ function main() {
4553
}
4654
}
4755

48-
function checkDevTask(devTask: string): {
56+
function checkDevTask(
57+
devTask: string,
58+
env: Record<string, string> | undefined,
59+
): {
4960
devTask: string;
5061
hasProxyTask: boolean;
5162
errorMessage?: string;
@@ -54,6 +65,7 @@ function checkDevTask(devTask: string): {
5465
stdio: 'pipe',
5566
encoding: 'utf8',
5667
cwd: WORKSPACE_ROOT,
68+
env: { ...process.env, ...env },
5769
});
5870
if (result.error) {
5971
return { devTask, hasProxyTask: false, errorMessage: result.error.message };

pnpm-lock.yaml

Lines changed: 29 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

turbo.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"$schema": "https://turborepo.org/schema.json",
3-
"globalPassThroughEnv": ["MFE_DEBUG"],
3+
"globalPassThroughEnv": ["MFE_DEBUG", "VC_MICROFRONTENDS_CONFIG_FILE_NAME"],
44
"tasks": {
55
"build": {
66
"dependsOn": ["^build"],

0 commit comments

Comments
 (0)