mirror of https://github.com/status-im/metro.git
[ReactNative] Pipe `platform` option all the way to the asset server
This commit is contained in:
parent
47eec251bc
commit
802578a78e
|
@ -51,14 +51,14 @@ class AssetServer {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getAssetData(assetPath) {
|
getAssetData(assetPath, platform = null) {
|
||||||
const nameData = getAssetDataFromName(assetPath);
|
const nameData = getAssetDataFromName(assetPath);
|
||||||
const data = {
|
const data = {
|
||||||
name: nameData.name,
|
name: nameData.name,
|
||||||
type: nameData.type,
|
type: nameData.type,
|
||||||
};
|
};
|
||||||
|
|
||||||
return this._getAssetRecord(assetPath).then(record => {
|
return this._getAssetRecord(assetPath, platform).then(record => {
|
||||||
data.scales = record.scales;
|
data.scales = record.scales;
|
||||||
|
|
||||||
return Promise.all(
|
return Promise.all(
|
||||||
|
|
|
@ -154,7 +154,7 @@ class Bundler {
|
||||||
bundle.setMainModuleId(result.mainModuleId);
|
bundle.setMainModuleId(result.mainModuleId);
|
||||||
return Promise.all(
|
return Promise.all(
|
||||||
result.dependencies.map(
|
result.dependencies.map(
|
||||||
module => this._transformModule(bundle, module).then(transformed => {
|
module => this._transformModule(bundle, module, platform).then(transformed => {
|
||||||
if (bar) {
|
if (bar) {
|
||||||
bar.tick();
|
bar.tick();
|
||||||
}
|
}
|
||||||
|
@ -182,13 +182,13 @@ class Bundler {
|
||||||
return this._resolver.getDependencies(main, { dev: isDev, platform });
|
return this._resolver.getDependencies(main, { dev: isDev, platform });
|
||||||
}
|
}
|
||||||
|
|
||||||
_transformModule(bundle, module) {
|
_transformModule(bundle, module, platform = null) {
|
||||||
let transform;
|
let transform;
|
||||||
|
|
||||||
if (module.isAsset_DEPRECATED()) {
|
if (module.isAsset_DEPRECATED()) {
|
||||||
transform = this.generateAssetModule_DEPRECATED(bundle, module);
|
transform = this.generateAssetModule_DEPRECATED(bundle, module);
|
||||||
} else if (module.isAsset()) {
|
} else if (module.isAsset()) {
|
||||||
transform = this.generateAssetModule(bundle, module);
|
transform = this.generateAssetModule(bundle, module, platform);
|
||||||
} else if (module.isJSON()) {
|
} else if (module.isJSON()) {
|
||||||
transform = generateJSONModule(module);
|
transform = generateJSONModule(module);
|
||||||
} else {
|
} else {
|
||||||
|
@ -243,12 +243,12 @@ class Bundler {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
generateAssetModule(bundle, module) {
|
generateAssetModule(bundle, module, platform = null) {
|
||||||
const relPath = getPathRelativeToRoot(this._projectRoots, module.path);
|
const relPath = getPathRelativeToRoot(this._projectRoots, module.path);
|
||||||
|
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
sizeOf(module.path),
|
sizeOf(module.path),
|
||||||
this._assetServer.getAssetData(relPath),
|
this._assetServer.getAssetData(relPath, platform),
|
||||||
]).then(function(res) {
|
]).then(function(res) {
|
||||||
const dimensions = res[0];
|
const dimensions = res[0];
|
||||||
const assetData = res[1];
|
const assetData = res[1];
|
||||||
|
|
Loading…
Reference in New Issue