Browse Source

include dependencies in bundle.modules (closes #903)

gh-953
Rich-Harris 8 years ago
parent
commit
e8179c2013
  1. 1
      src/Module.js
  2. 37
      test/function/module-tree/_config.js
  3. 1
      test/function/module-tree/bar.js
  4. 1
      test/function/module-tree/foo.js
  5. 2
      test/function/module-tree/main.js
  6. 1
      test/function/module-tree/nested/baz.js
  7. 1
      test/function/module-tree/nested/qux.js

1
src/Module.js

@ -315,6 +315,7 @@ export default class Module {
toJSON () {
return {
id: this.id,
dependencies: this.dependencies.map( module => module.id ),
code: this.code,
originalCode: this.originalCode,
ast: this.astClone,

37
test/function/module-tree/_config.js

@ -0,0 +1,37 @@
const path = require( 'path' );
const assert = require( 'assert' );
module.exports = {
description: 'bundle.modules includes dependencies (#903)',
bundle ( bundle ) {
const modules = bundle.modules.map( module => {
return {
id: path.relative( __dirname, module.id ),
dependencies: module.dependencies.map( id => path.relative( __dirname, id ) )
};
});
assert.deepEqual( modules, [
{
id: 'nested/qux.js',
dependencies: []
},
{
id: 'nested/baz.js',
dependencies: [ 'nested/qux.js' ]
},
{
id: 'bar.js',
dependencies: [ 'nested/baz.js' ]
},
{
id: 'foo.js',
dependencies: [ 'bar.js' ]
},
{
id: 'main.js',
dependencies: [ 'foo.js', 'bar.js' ]
}
]);
}
};

1
test/function/module-tree/bar.js

@ -0,0 +1 @@
import './nested/baz.js';

1
test/function/module-tree/foo.js

@ -0,0 +1 @@
import './bar.js';

2
test/function/module-tree/main.js

@ -0,0 +1,2 @@
import './foo.js';
import './bar.js';

1
test/function/module-tree/nested/baz.js

@ -0,0 +1 @@
import qux from './qux.js';

1
test/function/module-tree/nested/qux.js

@ -0,0 +1 @@
export default 'whatever';
Loading…
Cancel
Save