mirror of https://github.com/status-im/metro.git
packager: buck: transform-module: add support for assets
Reviewed By: davidaurelio Differential Revision: D4868312 fbshipit-source-id: 44d20a5ed73637a9b3f43a99b5c82931f3e15dc6
This commit is contained in:
parent
781b3b9bb7
commit
e18d213116
|
@ -30,7 +30,7 @@ export type File = {|
|
|||
type: FileTypes,
|
||||
|};
|
||||
|
||||
type FileTypes = 'module' | 'script';
|
||||
type FileTypes = 'module' | 'script' | 'asset';
|
||||
|
||||
export type GraphFn = (
|
||||
entryPoints: Iterable<string>,
|
||||
|
|
|
@ -48,6 +48,11 @@ function transformModule(
|
|||
return;
|
||||
}
|
||||
|
||||
if (options.filename.endsWith('.png')) {
|
||||
transformAsset(code, options, callback);
|
||||
return;
|
||||
}
|
||||
|
||||
const {filename, transformer, variants = defaultVariants} = options;
|
||||
const tasks = {};
|
||||
Object.keys(variants).forEach(name => {
|
||||
|
@ -114,7 +119,7 @@ function transformJSON(json, options, callback) {
|
|||
file: filename,
|
||||
hasteID: value.name,
|
||||
transformed,
|
||||
type: 'module',
|
||||
type: 'asset',
|
||||
};
|
||||
|
||||
if (basename(filename) === 'package.json') {
|
||||
|
@ -128,6 +133,16 @@ function transformJSON(json, options, callback) {
|
|||
callback(null, result);
|
||||
}
|
||||
|
||||
function transformAsset(data, options, callback) {
|
||||
callback(null, {
|
||||
code: data,
|
||||
file: options.filename,
|
||||
hasteID: null,
|
||||
transformed: {},
|
||||
type: 'module',
|
||||
});
|
||||
}
|
||||
|
||||
function makeResult(ast, filename, sourceCode, isPolyfill = false) {
|
||||
let dependencies, dependencyMapName, file;
|
||||
if (isPolyfill) {
|
||||
|
|
Loading…
Reference in New Issue