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.
|
||||
*/
|
||||
getAssetExts: () => Array<string>,
|
||||
|
||||
// TODO: Remove this option below (T23793920)
|
||||
assetTransforms?: boolean,
|
||||
/**
|
||||
* Returns a regular expression for modules that should be ignored by the
|
||||
* packager on a given platform.
|
||||
|
@ -140,6 +141,7 @@ export type ConfigT = {
|
|||
|
||||
const DEFAULT = ({
|
||||
extraNodeModules: {},
|
||||
assetTransforms: false,
|
||||
getAssetExts: () => [],
|
||||
getBlacklistRE: () => blacklist(),
|
||||
getEnableBabelRCLookup: () => false,
|
||||
|
|
|
@ -113,8 +113,11 @@ class Server {
|
|||
const reporter =
|
||||
options.reporter || require('../lib/reporting').nullReporter;
|
||||
const maxWorkers = getMaxWorkers(options.maxWorkers);
|
||||
const assetExts = options.assetExts || defaults.assetExts;
|
||||
const sourceExts = options.sourceExts || defaults.sourceExts;
|
||||
|
||||
this._opts = {
|
||||
assetExts: options.assetExts || defaults.assetExts,
|
||||
assetExts: options.assetTransforms ? [] : assetExts,
|
||||
assetRegistryPath: options.assetRegistryPath,
|
||||
blacklistRE: options.blacklistRE,
|
||||
cacheVersion: options.cacheVersion || '1.0',
|
||||
|
@ -141,7 +144,9 @@ class Server {
|
|||
reporter,
|
||||
resetCache: options.resetCache || false,
|
||||
silent: options.silent || false,
|
||||
sourceExts: options.sourceExts || defaults.sourceExts,
|
||||
sourceExts: options.assetTransforms
|
||||
? sourceExts.concat(assetExts)
|
||||
: sourceExts,
|
||||
transformCache: options.transformCache,
|
||||
transformModulePath:
|
||||
options.transformModulePath || defaults.transformModulePath,
|
||||
|
|
|
@ -174,6 +174,7 @@ function createNonPersistentServer(options: Options): Server {
|
|||
|
||||
function toServerOptions(options: Options): ServerOptions {
|
||||
return {
|
||||
assetTransforms: options.assetTransforms,
|
||||
assetExts: options.assetExts,
|
||||
assetRegistryPath: options.assetRegistryPath,
|
||||
blacklistRE: options.blacklistRE,
|
||||
|
|
|
@ -18,7 +18,7 @@ const NODE_MODULES = path.sep + 'node_modules' + path.sep;
|
|||
|
||||
class DependencyGraphHelpers {
|
||||
_providesModuleNodeModules: Array<string>;
|
||||
_assetExts: Array<string>;
|
||||
_assetExts: Set<string>;
|
||||
|
||||
constructor({
|
||||
providesModuleNodeModules,
|
||||
|
@ -28,7 +28,7 @@ class DependencyGraphHelpers {
|
|||
+assetExts: Array<string>,
|
||||
}) {
|
||||
this._providesModuleNodeModules = providesModuleNodeModules;
|
||||
this._assetExts = assetExts;
|
||||
this._assetExts = new Set(assetExts);
|
||||
}
|
||||
|
||||
isNodeModulesDir(file: string) {
|
||||
|
@ -49,7 +49,7 @@ class DependencyGraphHelpers {
|
|||
}
|
||||
|
||||
isAssetFile(file: string) {
|
||||
return this._assetExts.indexOf(this.extname(file)) !== -1;
|
||||
return this._assetExts.has(this.extname(file));
|
||||
}
|
||||
|
||||
extname(name: string) {
|
||||
|
|
|
@ -61,6 +61,8 @@ export type ModuleTransportLike = {
|
|||
};
|
||||
|
||||
export type Options = {|
|
||||
// TODO: Remove this option below (T23793920)
|
||||
assetTransforms?: boolean,
|
||||
assetExts?: Array<string>,
|
||||
+assetRegistryPath: string,
|
||||
blacklistRE?: RegExp,
|
||||
|
|
Loading…
Reference in New Issue