mirror of
https://github.com/status-im/react-native.git
synced 2025-01-14 03:26:07 +00:00
Allow project-specific config for RN CLI using providesModuleNodeModules
Reviewed By: davidaurelio Differential Revision: D4409046 fbshipit-source-id: 5af0d08542935a784f4737653ccac49fd7517aff
This commit is contained in:
parent
09801aac30
commit
09a83f976e
@ -19,6 +19,7 @@ const outputBundle = require('./output/bundle');
|
||||
const path = require('path');
|
||||
const saveAssets = require('./saveAssets');
|
||||
const defaultAssetExts = require('../../packager/defaults').assetExts;
|
||||
const defaultProvidesModuleNodeModules = require('../../packager/defaults').providesModuleNodeModules;
|
||||
|
||||
import type {RequestOptions, OutputOptions} from './types.flow';
|
||||
import type {ConfigT} from '../core';
|
||||
@ -63,16 +64,21 @@ function buildBundle(
|
||||
typeof config.getTransformModulePath === 'function' ? config.getTransformModulePath() :
|
||||
undefined;
|
||||
|
||||
const providesModuleNodeModules =
|
||||
typeof config.getProvidesModuleNodeModules === 'function' ? config.getProvidesModuleNodeModules() :
|
||||
defaultProvidesModuleNodeModules;
|
||||
|
||||
const options = {
|
||||
projectRoots: config.getProjectRoots(),
|
||||
assetExts: defaultAssetExts.concat(assetExts),
|
||||
blacklistRE: config.getBlacklistRE(),
|
||||
getTransformOptions: config.getTransformOptions,
|
||||
transformModulePath: transformModulePath,
|
||||
extraNodeModules: config.extraNodeModules,
|
||||
getTransformOptions: config.getTransformOptions,
|
||||
projectRoots: config.getProjectRoots(),
|
||||
providesModuleNodeModules: providesModuleNodeModules,
|
||||
resetCache: args.resetCache,
|
||||
watch: false,
|
||||
reporter: new TerminalReporter(),
|
||||
transformModulePath: transformModulePath,
|
||||
watch: false,
|
||||
};
|
||||
|
||||
packagerInstance = new Server(options);
|
||||
|
@ -11,6 +11,7 @@
|
||||
'use strict';
|
||||
|
||||
const Config = require('../util/Config');
|
||||
|
||||
const defaultConfig = require('./default.config');
|
||||
const minimist = require('minimist');
|
||||
|
||||
@ -34,6 +35,11 @@ export type ConfigT = {
|
||||
* ending in .custom.js, you would return ['custom'] here.
|
||||
*/
|
||||
getPlatforms: () => Array<string>,
|
||||
/**
|
||||
* Specify any additional node modules that should be processed for
|
||||
* providesModule declarations.
|
||||
*/
|
||||
getProvidesModuleNodeModules?: () => Array<string>,
|
||||
/**
|
||||
* Returns the path to a custom transformer. This can also be overridden
|
||||
* with the --transformer commandline argument.
|
||||
|
@ -18,6 +18,7 @@ const copyToClipBoardMiddleware = require('./middleware/copyToClipBoardMiddlewar
|
||||
const cpuProfilerMiddleware = require('./middleware/cpuProfilerMiddleware');
|
||||
const defaultAssetExts = require('../../packager/defaults').assetExts;
|
||||
const defaultPlatforms = require('../../packager/defaults').platforms;
|
||||
const defaultProvidesModuleNodeModules = require('../../packager/defaults').providesModuleNodeModules;
|
||||
const getDevToolsMiddleware = require('./middleware/getDevToolsMiddleware');
|
||||
const heapCaptureMiddleware = require('./middleware/heapCaptureMiddleware.js');
|
||||
const http = require('http');
|
||||
@ -87,6 +88,9 @@ function getPackagerServer(args, config) {
|
||||
typeof config.getTransformModulePath === 'function' ? config.getTransformModulePath() :
|
||||
undefined;
|
||||
|
||||
const providesModuleNodeModules =
|
||||
args.providesModuleNodeModules || defaultProvidesModuleNodeModules;
|
||||
|
||||
return ReactPackager.createServer({
|
||||
assetExts: defaultAssetExts.concat(args.assetExts),
|
||||
blacklistRE: config.getBlacklistRE(),
|
||||
@ -95,6 +99,7 @@ function getPackagerServer(args, config) {
|
||||
getTransformOptions: config.getTransformOptions,
|
||||
platforms: defaultPlatforms.concat(args.platforms),
|
||||
projectRoots: args.projectRoots,
|
||||
providesModuleNodeModules: providesModuleNodeModules,
|
||||
reporter: new TerminalReporter(),
|
||||
resetCache: args.resetCache,
|
||||
transformModulePath: transformModulePath,
|
||||
|
@ -101,6 +101,16 @@ module.exports = {
|
||||
description: 'Specify any additional platforms to be used by the packager',
|
||||
parse: (val) => val.split(','),
|
||||
default: (config) => config.getPlatforms(),
|
||||
}, {
|
||||
command: '--providesModuleNodeModules [list]',
|
||||
description: 'Specify any npm packages that import dependencies with providesModule',
|
||||
parse: (val) => val.split(','),
|
||||
default: (config) => {
|
||||
if (typeof config.getProvidesModuleNodeModules === 'function') {
|
||||
return config.getProvidesModuleNodeModules();
|
||||
}
|
||||
return null;
|
||||
},
|
||||
}, {
|
||||
command: '--skipflow',
|
||||
description: 'Disable flow checks'
|
||||
|
2
packager/react-packager/src/Bundler/index.js
vendored
2
packager/react-packager/src/Bundler/index.js
vendored
@ -74,6 +74,7 @@ type Options = {
|
||||
platforms: Array<string>,
|
||||
polyfillModuleNames: Array<string>,
|
||||
projectRoots: Array<string>,
|
||||
providesModuleNodeModules?: Array<string>,
|
||||
reporter: Reporter,
|
||||
resetCache: boolean,
|
||||
transformModulePath?: string,
|
||||
@ -154,6 +155,7 @@ class Bundler {
|
||||
platforms: opts.platforms,
|
||||
polyfillModuleNames: opts.polyfillModuleNames,
|
||||
projectRoots: opts.projectRoots,
|
||||
providesModuleNodeModules: opts.providesModuleNodeModules,
|
||||
reporter: opts.reporter,
|
||||
resetCache: opts.resetCache,
|
||||
transformCacheKey,
|
||||
|
@ -36,6 +36,7 @@ type Options = {
|
||||
platforms: Array<string>,
|
||||
polyfillModuleNames?: Array<string>,
|
||||
projectRoots: Array<string>,
|
||||
providesModuleNodeModules?: Array<string>,
|
||||
reporter: Reporter,
|
||||
resetCache: boolean,
|
||||
transformCacheKey: string,
|
||||
@ -65,7 +66,7 @@ class Resolver {
|
||||
},
|
||||
platforms: opts.platforms,
|
||||
preferNativePlatform: true,
|
||||
providesModuleNodeModules: defaults.providesModuleNodeModules,
|
||||
providesModuleNodeModules: opts.providesModuleNodeModules || defaults.providesModuleNodeModules,
|
||||
reporter: opts.reporter,
|
||||
resetCache: opts.resetCache,
|
||||
roots: opts.projectRoots,
|
||||
|
3
packager/react-packager/src/Server/index.js
vendored
3
packager/react-packager/src/Server/index.js
vendored
@ -63,6 +63,7 @@ type Options = {
|
||||
platforms?: Array<string>,
|
||||
polyfillModuleNames?: Array<string>,
|
||||
projectRoots: Array<string>,
|
||||
providesModuleNodeModules?: Array<string>,
|
||||
reporter: Reporter,
|
||||
resetCache?: boolean,
|
||||
silent?: boolean,
|
||||
@ -178,6 +179,7 @@ class Server {
|
||||
platforms: Array<string>,
|
||||
polyfillModuleNames: Array<string>,
|
||||
projectRoots: Array<string>,
|
||||
providesModuleNodeModules?: Array<string>,
|
||||
reporter: Reporter,
|
||||
resetCache: boolean,
|
||||
silent: boolean,
|
||||
@ -209,6 +211,7 @@ class Server {
|
||||
platforms: options.platforms || defaults.platforms,
|
||||
polyfillModuleNames: options.polyfillModuleNames || [],
|
||||
projectRoots: options.projectRoots,
|
||||
providesModuleNodeModules: options.providesModuleNodeModules,
|
||||
reporter: options.reporter,
|
||||
resetCache: options.resetCache || false,
|
||||
silent: options.silent || false,
|
||||
|
Loading…
x
Reference in New Issue
Block a user