зеркало из https://github.com/microsoft/rnx-kit.git
Resolve npmPackageName from project root not local paths (#2588)
This commit is contained in:
Родитель
6d05950be6
Коммит
18c757bad9
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
"@rnx-kit/metro-service": patch
|
||||
"@rnx-kit/metro-config": patch
|
||||
---
|
||||
|
||||
Resolve npmPackageName from project root not local paths
|
|
@ -13,17 +13,25 @@ const path = require("path");
|
|||
|
||||
/**
|
||||
* @param {PlatformImplementations} availablePlatforms
|
||||
* @param {string} projectRoot
|
||||
*/
|
||||
function getPreludeModules(availablePlatforms) {
|
||||
function getPreludeModules(availablePlatforms, projectRoot) {
|
||||
// Include all instances of `InitializeCore` here and let Metro exclude
|
||||
// the unused ones.
|
||||
const requireOptions = { paths: [projectRoot] };
|
||||
const mainModules = new Set([
|
||||
require.resolve("react-native/Libraries/Core/InitializeCore"),
|
||||
require.resolve(
|
||||
"react-native/Libraries/Core/InitializeCore",
|
||||
requireOptions
|
||||
),
|
||||
]);
|
||||
for (const moduleName of Object.values(availablePlatforms)) {
|
||||
if (moduleName) {
|
||||
mainModules.add(
|
||||
require.resolve(`${moduleName}/Libraries/Core/InitializeCore`)
|
||||
require.resolve(
|
||||
`${moduleName}/Libraries/Core/InitializeCore`,
|
||||
requireOptions
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -106,7 +114,7 @@ function getDefaultConfig(projectRoot) {
|
|||
defaultConfig.resolver.resolveRequest =
|
||||
outOfTreePlatformResolver(availablePlatforms);
|
||||
|
||||
const preludeModules = getPreludeModules(availablePlatforms);
|
||||
const preludeModules = getPreludeModules(availablePlatforms, projectRoot);
|
||||
defaultConfig.serializer.getModulesRunBeforeMainModule = () => {
|
||||
return preludeModules;
|
||||
};
|
||||
|
|
|
@ -124,7 +124,8 @@ function getDefaultConfigInternal(cliConfig: CLIConfig): InputConfigT {
|
|||
require.resolve(
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
`${cliConfig.platforms[platform]
|
||||
.npmPackageName!}/Libraries/Core/InitializeCore`
|
||||
.npmPackageName!}/Libraries/Core/InitializeCore`,
|
||||
{ paths: [cliConfig.root] }
|
||||
)
|
||||
),
|
||||
],
|
||||
|
|
Загрузка…
Ссылка в новой задаче