-
Notifications
You must be signed in to change notification settings - Fork 24.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for out-of-tree platform plugins #20825
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,11 +47,37 @@ const findPlatformsInPackage = pjson => { | |
return path.join(pjson.name, pjson.rnpm.platform); | ||
}; | ||
|
||
const getEmptyPluginConfig = () => ({ | ||
commands: [], | ||
platforms: [], | ||
haste: { | ||
platforms: [], | ||
providesModuleNodeModules: [] | ||
} | ||
}); | ||
|
||
const findHasteConfigInPackageAndConcat = (pjson, haste) => { | ||
if (!pjson.rnpm || !pjson.rnpm.haste) { | ||
return; | ||
} | ||
let pkgHaste = pjson.rnpm.haste; | ||
|
||
if (pkgHaste.platforms) { | ||
haste.platforms = haste.platforms.concat(pkgHaste.platforms); | ||
} | ||
|
||
if (pkgHaste.providesModuleNodeModules) { | ||
haste.providesModuleNodeModules = | ||
haste.providesModuleNodeModules.concat(pkgHaste.providesModuleNodeModules); | ||
} | ||
}; | ||
|
||
|
||
const findPluginInFolder = folder => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. prettier/prettier: Replace |
||
const pjson = readPackage(folder); | ||
|
||
if (!pjson) { | ||
return {commands: [], platforms: []}; | ||
return getEmptyPluginConfig(); | ||
} | ||
|
||
const deps = union( | ||
|
@@ -63,6 +89,7 @@ const findPluginInFolder = folder => { | |
(acc, pkg) => { | ||
let commands = acc.commands; | ||
let platforms = acc.platforms; | ||
let haste = acc.haste; | ||
if (isRNPMPlugin(pkg)) { | ||
commands = commands.concat(pkg); | ||
} | ||
|
@@ -71,11 +98,12 @@ const findPluginInFolder = folder => { | |
if (pkgJson) { | ||
commands = commands.concat(findPluginsInReactNativePackage(pkgJson)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. prettier/prettier: Delete There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not entirely sure what this means |
||
platforms = platforms.concat(findPlatformsInPackage(pkgJson)); | ||
findHasteConfigInPackageAndConcat(pkgJson, haste); | ||
} | ||
} | ||
return {commands: commands, platforms: platforms}; | ||
return {commands: commands, platforms: platforms, haste: haste}; | ||
}, | ||
{commands: [], platforms: []}, | ||
getEmptyPluginConfig(), | ||
); | ||
}; | ||
|
||
|
@@ -89,5 +117,9 @@ module.exports = function findPlugins(folders) { | |
return { | ||
commands: uniq(flatten(plugins.map(p => p.commands))), | ||
platforms: uniq(flatten(plugins.map(p => p.platforms))), | ||
haste: { | ||
platforms: uniq(flatten(plugins.map(p => p.haste.platforms))), | ||
providesModuleNodeModules: uniq(flatten(plugins.map(p => p.haste.providesModuleNodeModules))) | ||
} | ||
}; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,11 +70,11 @@ const defaultConfig = { | |
hasteImplModulePath: require.resolve('../../jest/hasteImpl'), | ||
|
||
getPlatforms(): Array<string> { | ||
return ['ios', 'android', 'windows', 'web', 'dom']; | ||
return ['ios', 'android', 'native', ...plugins.haste.platforms]; | ||
}, | ||
|
||
getProvidesModuleNodeModules(): Array<string> { | ||
return ['react-native', 'react-native-windows', 'react-native-dom']; | ||
return ['react-native', ...plugins.haste.providesModuleNodeModules]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. prettier/prettier: Insert |
||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. prettier/prettier: Replace There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. prettier/prettier: Replace |
||
}; | ||
|
||
|
@@ -133,8 +133,10 @@ async function getCliConfig(): Promise<RNConfig> { | |
|
||
config.transformer.assetRegistryPath = ASSET_REGISTRY_PATH; | ||
config.resolver.hasteImplModulePath = config.resolver.hasteImplModulePath || defaultConfig.hasteImplModulePath; | ||
config.resolver.platforms = config.resolver.platforms || defaultConfig.getPlatforms(); | ||
config.resolver.providesModuleNodeModules = config.resolver.providesModuleNodeModules || defaultConfig.getProvidesModuleNodeModules(); | ||
config.resolver.platforms = config.resolver.platforms ? | ||
config.resolver.platforms.concat(defaultConfig.getPlatforms()) : defaultConfig.getPlatforms(); | ||
config.resolver.providesModuleNodeModules = config.resolver.providesModuleNodeModules ? | ||
config.resolver.providesModuleNodeModules.concat(defaultConfig.getProvidesModuleNodeModules()) : defaultConfig.getProvidesModuleNodeModules(); | ||
|
||
return {...defaultRNConfig, ...config}; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prettier/prettier: Insert
,