Browse Source

add bundle.modules - fixes #128

better-aggressive
Rich-Harris 9 years ago
parent
commit
ac6c2d03db
  1. 3
      src/rollup.js
  2. 13
      test/function/has-modules-array/_config.js
  3. 1
      test/function/has-modules-array/foo.js
  4. 2
      test/function/has-modules-array/main.js
  5. 5
      test/test.js

3
src/rollup.js

@ -17,6 +17,9 @@ export function rollup ( options ) {
return {
imports: bundle.externalModules.map( module => module.id ),
exports: keys( bundle.entryModule.exports ),
modules: bundle.orderedModules.map( module => {
return { id: module.id };
}),
generate: options => bundle.render( options ),
write: options => {

13
test/function/has-modules-array/_config.js

@ -0,0 +1,13 @@
var path = require( 'path' );
var assert = require( 'assert' );
module.exports = {
description: 'user-facing bundle has modules array',
bundle: function ( bundle ) {
assert.ok( bundle.modules );
assert.deepEqual( bundle.modules, [
{ id: path.resolve( __dirname, 'foo.js' ) },
{ id: path.resolve( __dirname, 'main.js' ) }
]);
}
};

1
test/function/has-modules-array/foo.js

@ -0,0 +1 @@
export default 42;

2
test/function/has-modules-array/main.js

@ -0,0 +1,2 @@
import foo from './foo';
assert.equal( foo, 42 );

5
test/test.js

@ -128,9 +128,8 @@ describe( 'rollup', function () {
unintendedError = new Error( 'Expected an error while executing output' );
}
if ( config.exports ) {
config.exports( module.exports );
}
if ( config.exports ) config.exports( module.exports );
if ( config.bundle ) config.bundle( bundle );
} catch ( err ) {
if ( config.error ) {
config.error( err );

Loading…
Cancel
Save