mirror of
https://github.com/status-im/metro.git
synced 2025-01-16 14:14:09 +00:00
packager: ModuleGraph: include all possible asset types
Summary: Afaik. the list of asset types is hardcoded for the Buck worker so far, and I'm not sure how that would be customizable. For now, let's include all the default asset extensions. Reviewed By: davidaurelio Differential Revision: D5002607 fbshipit-source-id: 41069e817d2b73156bca684bc2f73077132928a7
This commit is contained in:
parent
fb2f256dc3
commit
43900f558c
@ -12,8 +12,10 @@
|
|||||||
|
|
||||||
const babel = require('babel-core');
|
const babel = require('babel-core');
|
||||||
const collectDependencies = require('./collect-dependencies');
|
const collectDependencies = require('./collect-dependencies');
|
||||||
|
const defaults = require('../../../defaults');
|
||||||
const docblock = require('../../node-haste/DependencyGraph/docblock');
|
const docblock = require('../../node-haste/DependencyGraph/docblock');
|
||||||
const generate = require('./generate');
|
const generate = require('./generate');
|
||||||
|
const path = require('path');
|
||||||
const series = require('async/series');
|
const series = require('async/series');
|
||||||
|
|
||||||
const {basename} = require('path');
|
const {basename} = require('path');
|
||||||
@ -39,12 +41,14 @@ const defaultVariants = {default: {}};
|
|||||||
const moduleFactoryParameters = ['global', 'require', 'module', 'exports'];
|
const moduleFactoryParameters = ['global', 'require', 'module', 'exports'];
|
||||||
const polyfillFactoryParameters = ['global'];
|
const polyfillFactoryParameters = ['global'];
|
||||||
|
|
||||||
|
const ASSET_EXTENSIONS = new Set(defaults.assetExts);
|
||||||
|
|
||||||
function transformModule(
|
function transformModule(
|
||||||
content: Buffer,
|
content: Buffer,
|
||||||
options: TransformOptions,
|
options: TransformOptions,
|
||||||
callback: Callback<TransformedSourceFile>,
|
callback: Callback<TransformedSourceFile>,
|
||||||
): void {
|
): void {
|
||||||
if (options.filename.endsWith('.png')) {
|
if (ASSET_EXTENSIONS.has(path.extname(options.filename).substr(1))) {
|
||||||
transformAsset(content, options, callback);
|
transformAsset(content, options, callback);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user