mirror of
https://github.com/status-im/metro.git
synced 2025-02-10 10:07:12 +00:00
[react-packager] Implement getJSModulePaths API
This commit is contained in:
parent
74e7e70e76
commit
c9c61222cf
9
react-packager/src/Packager/Package.js
vendored
9
react-packager/src/Packager/Package.js
vendored
@ -249,6 +249,15 @@ Package.prototype._getMappings = function() {
|
|||||||
return mappings;
|
return mappings;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Package.prototype.getJSModulePaths = function() {
|
||||||
|
return this._modules.filter(function(module) {
|
||||||
|
// Filter out non-js files. Like images etc.
|
||||||
|
return !module.virtual;
|
||||||
|
}).map(function(module) {
|
||||||
|
return module.sourcePath;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
Package.prototype.getDebugInfo = function() {
|
Package.prototype.getDebugInfo = function() {
|
||||||
return [
|
return [
|
||||||
'<div><h3>Main Module:</h3> ' + this._mainModuleId + '</div>',
|
'<div><h3>Main Module:</h3> ' + this._mainModuleId + '</div>',
|
||||||
|
@ -204,8 +204,28 @@ describe('Package', function() {
|
|||||||
expect(p.getAssets()).toEqual([asset1, asset2]);
|
expect(p.getAssets()).toEqual([asset1, asset2]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('getJSModulePaths()', function() {
|
||||||
|
it('should return module paths', function() {
|
||||||
|
var p = new Package('test_url');
|
||||||
|
p.addModule(new ModuleTransport({
|
||||||
|
code: 'transformed foo;\n',
|
||||||
|
sourceCode: 'source foo',
|
||||||
|
sourcePath: 'foo path'
|
||||||
|
}));
|
||||||
|
p.addModule(new ModuleTransport({
|
||||||
|
code: 'image module;\nimage module;',
|
||||||
|
virtual: true,
|
||||||
|
sourceCode: 'image module;\nimage module;',
|
||||||
|
sourcePath: 'image.png',
|
||||||
|
}));
|
||||||
|
|
||||||
|
expect(p.getJSModulePaths()).toEqual(['foo path']);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
function genSourceMap(modules) {
|
function genSourceMap(modules) {
|
||||||
var sourceMapGen = new SourceMapGenerator({file: 'bundle.js', version: 3});
|
var sourceMapGen = new SourceMapGenerator({file: 'bundle.js', version: 3});
|
||||||
var packageLineNo = 0;
|
var packageLineNo = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user