Browse Source

Merge pull request #913 from rollup/gh-903

include dependencies in bundle.modules
gh-953
Rich Harris 8 years ago
committed by GitHub
parent
commit
aac47b05cb
  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 () { toJSON () {
return { return {
id: this.id, id: this.id,
dependencies: this.dependencies.map( module => module.id ),
code: this.code, code: this.code,
originalCode: this.originalCode, originalCode: this.originalCode,
ast: this.astClone, 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: path.normalize( 'nested/qux.js' ),
dependencies: []
},
{
id: path.normalize( 'nested/baz.js' ),
dependencies: [ path.normalize( 'nested/qux.js' ) ]
},
{
id: 'bar.js',
dependencies: [ path.normalize( '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