Files
react-native/packager/react-packager/src/DependencyResolver/AssetModule.js
T
Amjad Masad bc28a35bda [react-packager] Use module objects across the codebase (rid of getPlainObject etc)
Summary:
Instead of using plain objects and having to convert to and from them we just use the `Module` class across the codebase.
This seems cleaner and can enforce the type as opposed to fuzzy objects.
2015-08-13 15:52:31 -08:00

52 lines
908 B
JavaScript

'use strict';
const Module = require('./Module');
const Promise = require('promise');
const getAssetDataFromName = require('../lib/getAssetDataFromName');
class AssetModule extends Module {
constructor(...args) {
super(...args);
const { resolution, name, type } = getAssetDataFromName(this.path);
this.resolution = resolution;
this._name = name;
this._type = type;
}
isHaste() {
return Promise.resolve(false);
}
getDependencies() {
return Promise.resolve([]);
}
getAsyncDependencies() {
return Promise.resolve([]);
}
_read() {
return Promise.resolve({});
}
getName() {
return super.getName().then(
id => id.replace(/\/[^\/]+$/, `/${this._name}.${this._type}`)
);
}
hash() {
return `AssetModule : ${this.path}`;
}
isJSON() {
return false;
}
isAsset() {
return true;
}
}
module.exports = AssetModule;