mirror of https://github.com/status-im/metro.git
Add option to bypass AssetRegistry and sending assets to transforms
Reviewed By: rafeca Differential Revision: D6385816 fbshipit-source-id: b94fb125bee0576cfb25170aa86a253c10a3d862
This commit is contained in:
parent
5f58ae0e84
commit
7b5ae96479
|
@ -34,7 +34,8 @@ export type ConfigT = {
|
||||||
* from here and use `require('./fonts/example.ttf')` inside your app.
|
* from here and use `require('./fonts/example.ttf')` inside your app.
|
||||||
*/
|
*/
|
||||||
getAssetExts: () => Array<string>,
|
getAssetExts: () => Array<string>,
|
||||||
|
// TODO: Remove this option below (T23793920)
|
||||||
|
assetTransforms?: boolean,
|
||||||
/**
|
/**
|
||||||
* Returns a regular expression for modules that should be ignored by the
|
* Returns a regular expression for modules that should be ignored by the
|
||||||
* packager on a given platform.
|
* packager on a given platform.
|
||||||
|
@ -140,6 +141,7 @@ export type ConfigT = {
|
||||||
|
|
||||||
const DEFAULT = ({
|
const DEFAULT = ({
|
||||||
extraNodeModules: {},
|
extraNodeModules: {},
|
||||||
|
assetTransforms: false,
|
||||||
getAssetExts: () => [],
|
getAssetExts: () => [],
|
||||||
getBlacklistRE: () => blacklist(),
|
getBlacklistRE: () => blacklist(),
|
||||||
getEnableBabelRCLookup: () => false,
|
getEnableBabelRCLookup: () => false,
|
||||||
|
|
|
@ -113,8 +113,11 @@ class Server {
|
||||||
const reporter =
|
const reporter =
|
||||||
options.reporter || require('../lib/reporting').nullReporter;
|
options.reporter || require('../lib/reporting').nullReporter;
|
||||||
const maxWorkers = getMaxWorkers(options.maxWorkers);
|
const maxWorkers = getMaxWorkers(options.maxWorkers);
|
||||||
|
const assetExts = options.assetExts || defaults.assetExts;
|
||||||
|
const sourceExts = options.sourceExts || defaults.sourceExts;
|
||||||
|
|
||||||
this._opts = {
|
this._opts = {
|
||||||
assetExts: options.assetExts || defaults.assetExts,
|
assetExts: options.assetTransforms ? [] : assetExts,
|
||||||
assetRegistryPath: options.assetRegistryPath,
|
assetRegistryPath: options.assetRegistryPath,
|
||||||
blacklistRE: options.blacklistRE,
|
blacklistRE: options.blacklistRE,
|
||||||
cacheVersion: options.cacheVersion || '1.0',
|
cacheVersion: options.cacheVersion || '1.0',
|
||||||
|
@ -141,7 +144,9 @@ class Server {
|
||||||
reporter,
|
reporter,
|
||||||
resetCache: options.resetCache || false,
|
resetCache: options.resetCache || false,
|
||||||
silent: options.silent || false,
|
silent: options.silent || false,
|
||||||
sourceExts: options.sourceExts || defaults.sourceExts,
|
sourceExts: options.assetTransforms
|
||||||
|
? sourceExts.concat(assetExts)
|
||||||
|
: sourceExts,
|
||||||
transformCache: options.transformCache,
|
transformCache: options.transformCache,
|
||||||
transformModulePath:
|
transformModulePath:
|
||||||
options.transformModulePath || defaults.transformModulePath,
|
options.transformModulePath || defaults.transformModulePath,
|
||||||
|
|
|
@ -174,6 +174,7 @@ function createNonPersistentServer(options: Options): Server {
|
||||||
|
|
||||||
function toServerOptions(options: Options): ServerOptions {
|
function toServerOptions(options: Options): ServerOptions {
|
||||||
return {
|
return {
|
||||||
|
assetTransforms: options.assetTransforms,
|
||||||
assetExts: options.assetExts,
|
assetExts: options.assetExts,
|
||||||
assetRegistryPath: options.assetRegistryPath,
|
assetRegistryPath: options.assetRegistryPath,
|
||||||
blacklistRE: options.blacklistRE,
|
blacklistRE: options.blacklistRE,
|
||||||
|
|
|
@ -18,7 +18,7 @@ const NODE_MODULES = path.sep + 'node_modules' + path.sep;
|
||||||
|
|
||||||
class DependencyGraphHelpers {
|
class DependencyGraphHelpers {
|
||||||
_providesModuleNodeModules: Array<string>;
|
_providesModuleNodeModules: Array<string>;
|
||||||
_assetExts: Array<string>;
|
_assetExts: Set<string>;
|
||||||
|
|
||||||
constructor({
|
constructor({
|
||||||
providesModuleNodeModules,
|
providesModuleNodeModules,
|
||||||
|
@ -28,7 +28,7 @@ class DependencyGraphHelpers {
|
||||||
+assetExts: Array<string>,
|
+assetExts: Array<string>,
|
||||||
}) {
|
}) {
|
||||||
this._providesModuleNodeModules = providesModuleNodeModules;
|
this._providesModuleNodeModules = providesModuleNodeModules;
|
||||||
this._assetExts = assetExts;
|
this._assetExts = new Set(assetExts);
|
||||||
}
|
}
|
||||||
|
|
||||||
isNodeModulesDir(file: string) {
|
isNodeModulesDir(file: string) {
|
||||||
|
@ -49,7 +49,7 @@ class DependencyGraphHelpers {
|
||||||
}
|
}
|
||||||
|
|
||||||
isAssetFile(file: string) {
|
isAssetFile(file: string) {
|
||||||
return this._assetExts.indexOf(this.extname(file)) !== -1;
|
return this._assetExts.has(this.extname(file));
|
||||||
}
|
}
|
||||||
|
|
||||||
extname(name: string) {
|
extname(name: string) {
|
||||||
|
|
|
@ -61,6 +61,8 @@ export type ModuleTransportLike = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Options = {|
|
export type Options = {|
|
||||||
|
// TODO: Remove this option below (T23793920)
|
||||||
|
assetTransforms?: boolean,
|
||||||
assetExts?: Array<string>,
|
assetExts?: Array<string>,
|
||||||
+assetRegistryPath: string,
|
+assetRegistryPath: string,
|
||||||
blacklistRE?: RegExp,
|
blacklistRE?: RegExp,
|
||||||
|
|
Loading…
Reference in New Issue