Skip to content

Commit a3d075c

Browse files
robhoganfacebook-github-bot
authored andcommitted
Remove support for deprecated YAML and .es6 config files (#1752)
Summary: These have been deprecated (with a runtime warning) and removal planned for a year now. I believe they're little used in the wild and inherently very limited. Expo has already dropped support. Removing YAML support lets us drop a dependency also. Changelog: ``` - **[Breaking]**: Remove support for YAML and `.es6` config files ``` Differential Revision: D109987702
1 parent 22fa6dd commit a3d075c

5 files changed

Lines changed: 7 additions & 31 deletions

File tree

packages/metro-config/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@
2525
"metro": "0.85.0",
2626
"metro-cache": "0.85.0",
2727
"metro-core": "0.85.0",
28-
"metro-runtime": "0.85.0",
29-
"yaml": "^2.6.1"
28+
"metro-runtime": "0.85.0"
3029
},
3130
"devDependencies": {
3231
"@types/connect": "^3.4.35",

packages/metro-config/src/__fixtures__/yaml-extensionless

Lines changed: 0 additions & 2 deletions
This file was deleted.

packages/metro-config/src/__tests__/loadConfig-test.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -156,16 +156,6 @@ describe('loadConfig', () => {
156156
);
157157
});
158158

159-
test('supports loading YAML (deprecated)', async () => {
160-
const result = await loadConfig({
161-
config: path.resolve(FIXTURES, 'yaml-extensionless'),
162-
});
163-
expect(console.warn).toHaveBeenCalledWith(
164-
'YAML config is deprecated, please migrate to JavaScript config (e.g. metro.config.js)',
165-
);
166-
expect(result.cacheVersion).toEqual('yaml-extensionless');
167-
});
168-
169159
describe('given a search directory', () => {
170160
const HOME = process.platform === 'win32' ? 'C:\\Home' : '/home';
171161
const mockHomeDir = jest.fn().mockReturnValue(HOME);

packages/metro-config/src/loadConfig.js

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import {homedir} from 'os';
2020
import * as path from 'path';
2121
// eslint-disable-next-line no-restricted-imports
2222
import {pathToFileURL} from 'url';
23-
import {parse as parseYaml} from 'yaml';
2423

2524
type ResolveConfigResult = {
2625
filepath: string,
@@ -57,12 +56,8 @@ const SEARCH_PLACES = [
5756
'package.json',
5857
];
5958

60-
const JS_EXTENSIONS = new Set([
61-
...SEARCH_JS_EXTS,
62-
'.es6', // Deprecated
63-
]);
59+
const JS_EXTENSIONS = new Set(SEARCH_JS_EXTS);
6460
const TS_EXTENSIONS = new Set(SEARCH_TS_EXTS);
65-
const YAML_EXTENSIONS = new Set(['.yml', '.yaml', '']); // Deprecated
6661

6762
const PACKAGE_JSON = path.sep + 'package.json';
6863
const PACKAGE_JSON_PROP_NAME = 'metro';
@@ -394,7 +389,7 @@ async function loadConfig(
394389
export async function loadConfigFile(
395390
absolutePath: string,
396391
): Promise<ResolveConfigResult> {
397-
// Config should be JSON, CommonJS, ESM or YAML (deprecated)
392+
// Config should be JSON, CommonJS, or ESM
398393
let config: unknown;
399394
const extension = path.extname(absolutePath);
400395

@@ -436,15 +431,14 @@ export async function loadConfigFile(
436431
throw error;
437432
}
438433
}
439-
} else if (YAML_EXTENSIONS.has(extension)) {
440-
console.warn(
441-
'YAML config is deprecated, please migrate to JavaScript config (e.g. metro.config.js)',
434+
} else if (extension === '.yaml' || extension === '.yml') {
435+
throw new Error(
436+
'YAML config is no longer supported, please migrate to JavaScript config (e.g. metro.config.js)',
442437
);
443-
config = parseYaml(fs.readFileSync(absolutePath, 'utf8'));
444438
} else {
445439
throw new Error(
446440
`Unsupported config file extension: ${extension}. ` +
447-
`Supported extensions are ${[...JS_EXTENSIONS, ...TS_EXTENSIONS, ...YAML_EXTENSIONS].map(ext => (ext === '' ? 'none' : `${ext}`)).join()})}.`,
441+
`Supported extensions are ${[...JS_EXTENSIONS, ...TS_EXTENSIONS].map(ext => (ext === '' ? 'none' : `${ext}`)).join()})}.`,
448442
);
449443
}
450444

yarn.lock

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5913,11 +5913,6 @@ yallist@^3.0.2:
59135913
resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.1.1.tgz#dbb7daf9bfd8bac9ab45ebf602b8cbad0d5d08fd"
59145914
integrity sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==
59155915

5916-
yaml@^2.6.1:
5917-
version "2.6.1"
5918-
resolved "https://registry.yarnpkg.com/yaml/-/yaml-2.6.1.tgz#42f2b1ba89203f374609572d5349fb8686500773"
5919-
integrity sha512-7r0XPzioN/Q9kXBro/XPnA6kznR73DHq+GXh5ON7ZozRO6aMjbmiBuKste2wslTFkC5d1dw0GooOCepZXJ2SAg==
5920-
59215916
yargs-parser@^21.1.1:
59225917
version "21.1.1"
59235918
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-21.1.1.tgz#9096bceebf990d21bb31fa9516e0ede294a77d35"

0 commit comments

Comments
 (0)