Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 6 additions & 0 deletions packages/react-native/react-native.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,18 @@ const codegenCommand = {
name: '--outputPath <path>',
description: 'Path where generated artifacts will be output to.',
},
{
name: '--source <string>',
description: 'Whether the script is invoked from an `app` or a `library`',
default: 'app',
},
],
func: (argv, config, args) =>
require('./scripts/codegen/generate-artifacts-executor').execute(
args.path,
args.platform,
args.outputPath,
args.source,
),
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -971,11 +971,12 @@ SCRIPT`;
* @parameter projectRoot: the directory with the app source code, where the package.json lives.
* @parameter baseOutputPath: the base output path for the CodeGen.
* @parameter targetPlatform: the target platform. Supported values: 'android', 'ios', 'all'.
* @parameter source: the source that is invoking codegen. Supported values: 'app', 'library'.
* @throws If it can't find a config file for react-native.
* @throws If it can't find a CodeGen configuration in the file.
* @throws If it can't find a cli for the CodeGen.
*/
function execute(projectRoot, targetPlatform, baseOutputPath) {
function execute(projectRoot, targetPlatform, baseOutputPath, source) {
try {
codegenLog(`Analyzing ${path.join(projectRoot, 'package.json')}`);

Expand Down Expand Up @@ -1023,9 +1024,12 @@ function execute(projectRoot, targetPlatform, baseOutputPath) {
platform,
);

generateRCTThirdPartyComponents(libraries, outputPath);
generateCustomURLHandlers(libraries, outputPath);
generateAppDependencyProvider(outputPath);
if (source === 'app') {
// These components are only required by apps, not by libraries
generateRCTThirdPartyComponents(libraries, outputPath);
generateCustomURLHandlers(libraries, outputPath);
generateAppDependencyProvider(outputPath);
}
generateReactCodegenPodspec(
projectRoot,
pkgJson,
Expand Down
7 changes: 6 additions & 1 deletion packages/react-native/scripts/generate-codegen-artifacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ const argv = yargs
alias: 'outputPath',
description: 'Path where generated artifacts will be output to.',
})
.option('s', {
alias: 'source',
description: 'Whether the script is invoked from an `app` or a `library`',
default: 'app',
})
.usage('Usage: $0 -p [path to app] -t [target platform] -o [output path]')
.demandOption(['p', 't']).argv;

executor.execute(argv.path, argv.targetPlatform, argv.outputPath);
executor.execute(argv.path, argv.targetPlatform, argv.outputPath, argv.source);
Loading