Skip to content

Commit feeb11e

Browse files
authored
Deprecate configPath as VC_MICROFRONTENDS_CONFIG_FILE_NAME supersedes it (#15)
1 parent 9ca2cd8 commit feeb11e

File tree

5 files changed

+71
-2
lines changed

5 files changed

+71
-2
lines changed

packages/microfrontends/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ Split apart large applications and develop faster with microfrontends. This pack
99

1010
See the [full documentation](https://vercel.com/docs/microfrontends) and [examples](https://vercel.com/templates/microfrontends) to learn more.
1111

12+
## Changelog
13+
14+
See the [changelog](./packages/microfrontends/CHANGELOG.md) for a list of changes.
15+
1216
## Getting Started
1317

1418
Follow the [quickstart](https://vercel.com/docs/microfrontends/quickstart) documentation to get started.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { getPossibleConfigurationFilenames } from './get-config-file-name';
2+
3+
describe('getPossibleConfigurationFilenames', () => {
4+
it.each([
5+
{
6+
customConfigFilename: 'microfrontends.json',
7+
expected: ['microfrontends.json', 'microfrontends.jsonc'],
8+
},
9+
{
10+
customConfigFilename: 'microfrontends-dev.json',
11+
expected: [
12+
'microfrontends-dev.json',
13+
'microfrontends.json',
14+
'microfrontends.jsonc',
15+
],
16+
},
17+
{
18+
customConfigFilename: 'microfrontends-dev.jsonc',
19+
expected: [
20+
'microfrontends-dev.jsonc',
21+
'microfrontends.json',
22+
'microfrontends.jsonc',
23+
],
24+
},
25+
{
26+
customConfigFilename: '/path/to/microfrontends-dev.jsonc',
27+
expected: [
28+
'/path/to/microfrontends-dev.jsonc',
29+
'microfrontends.json',
30+
'microfrontends.jsonc',
31+
],
32+
},
33+
{
34+
customConfigFilename: 'mfe-dev.jsonc',
35+
expected: [
36+
'mfe-dev.jsonc',
37+
'microfrontends.json',
38+
'microfrontends.jsonc',
39+
],
40+
},
41+
])(
42+
'returns the filenames or throws an error if the filename is invalid',
43+
({ customConfigFilename, expected }) => {
44+
const result = getPossibleConfigurationFilenames({
45+
customConfigFilename,
46+
});
47+
expect(result).toEqual(expected);
48+
},
49+
);
50+
});

packages/microfrontends/src/config/microfrontends/utils/get-config-file-name.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
// ordered by most likely to be the correct one
12
const DEFAULT_CONFIGURATION_FILENAMES = [
2-
'microfrontends.jsonc',
33
'microfrontends.json',
4+
'microfrontends.jsonc',
45
] as const;
56

67
export function getPossibleConfigurationFilenames({
@@ -15,7 +16,9 @@ export function getPossibleConfigurationFilenames({
1516
!customConfigFilename.endsWith('.jsonc')
1617
) {
1718
throw new Error(
18-
`The VC_MICROFRONTENDS_CONFIG_FILE_NAME environment variable must end with '.json' or '.jsonc'. Received: ${customConfigFilename}`,
19+
`Found VC_MICROFRONTENDS_CONFIG_FILE_NAME but the name is invalid. Received: ${customConfigFilename}.` +
20+
` The file name must end with '.json' or '.jsonc'.` +
21+
` It's also possible for the env var to include the path, eg microfrontends-dev.json or /path/to/microfrontends-dev.json.`,
1922
);
2023
}
2124
return Array.from(

packages/microfrontends/src/next/config/types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,11 @@ export interface WithMicrofrontendsOptions {
2323
* enabled when necessary.
2424
*/
2525
supportPagesRouter?: boolean;
26+
/**
27+
* @deprecated Use VC_MICROFRONTENDS_CONFIG_FILE_NAME instead. This option is
28+
* deprecated and will be removed in a future release. The env var enables the
29+
* vercel build to also read the custom config file / path.
30+
* @see https://vercel.com/docs/microfrontends/configuration#file-naming
31+
*/
2632
configPath?: string;
2733
}

packages/microfrontends/src/sveltekit/config/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ export interface WithMicrofrontendsOptions {
88
* Explicitly set the name of the application instead of using the name from the package.json.
99
*/
1010
appName?: string;
11+
/**
12+
* @deprecated Use VC_MICROFRONTENDS_CONFIG_FILE_NAME instead. This option is
13+
* deprecated and will be removed in a future release. The env var enables the
14+
* vercel build to also read the custom config file / path.
15+
* @see https://vercel.com/docs/microfrontends/configuration#file-naming
16+
*/
1117
configPath?: string;
1218
}
1319

0 commit comments

Comments
 (0)