Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

fix: resolve and import metro-config from the project #2048

Merged
merged 2 commits into from
Apr 30, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions packages/metro-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@
"@expo/config": "3.2.0",
"metro-react-native-babel-transformer": "^0.58.0"
},
"peerDependencies": {
"metro": "^0.56.0",
"metro-config": "^0.56.0"
},
"devDependencies": {
"@expo/babel-preset-cli": "0.2.11",
"expo": "37",
Expand Down
4 changes: 3 additions & 1 deletion packages/metro-config/src/ExpoMetroConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import path from 'path';
import { ProjectTarget, getConfig, getDefaultTarget, resolveModule } from '@expo/config';
import { getBareExtensions, getManagedExtensions } from '@expo/config/paths';
import { Reporter } from 'metro';
import { ConfigT, InputConfigT, loadConfig } from 'metro-config';
import { ConfigT, InputConfigT } from 'metro-config';

const INTERNAL_CALLSITES_REGEX = new RegExp(
[
Expand Down Expand Up @@ -96,5 +96,7 @@ export async function loadAsync(
if (reporter) {
defaultConfig = { ...defaultConfig, reporter };
}
const { exp } = getConfig(projectRoot, { skipSDKVersionRequirement: true });
const { loadConfig } = require(resolveModule('metro-config', projectRoot, exp));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be useful to get the path with projectHasModule('metro-config', projectRoot, exp) and if the returned path is nullish then throw an error informing the user how to install the package.

return await loadConfig({ cwd: projectRoot, projectRoot, ...metroOptions }, defaultConfig);
}