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:
Jean Lauliac 2017-05-08 04:28:26 -07:00 committed by Facebook Github Bot
parent fb2f256dc3
commit 43900f558c
1 changed files with 5 additions and 1 deletions

View File

@ -12,8 +12,10 @@
const babel = require('babel-core');
const collectDependencies = require('./collect-dependencies');
const defaults = require('../../../defaults');
const docblock = require('../../node-haste/DependencyGraph/docblock');
const generate = require('./generate');
const path = require('path');
const series = require('async/series');
const {basename} = require('path');
@ -39,12 +41,14 @@ const defaultVariants = {default: {}};
const moduleFactoryParameters = ['global', 'require', 'module', 'exports'];
const polyfillFactoryParameters = ['global'];
const ASSET_EXTENSIONS = new Set(defaults.assetExts);
function transformModule(
content: Buffer,
options: TransformOptions,
callback: Callback<TransformedSourceFile>,
): void {
if (options.filename.endsWith('.png')) {
if (ASSET_EXTENSIONS.has(path.extname(options.filename).substr(1))) {
transformAsset(content, options, callback);
return;
}