Browse Source

support moduleId and moduleName via CLI (fixes #24)

contingency-plan
Rich-Harris 10 years ago
parent
commit
1111e144a8
  1. 4
      bin/runRollup.js
  2. 4
      test/cli/module-name/_config.js
  3. 11
      test/cli/module-name/_expected.js
  4. 1
      test/cli/module-name/main.js
  5. 14
      test/test.js

4
bin/runRollup.js

@ -39,7 +39,9 @@ function bundle ( options, method ) {
}).then( function ( bundle ) {
var generateOptions = {
dest: options.output,
format: options.format
format: options.format,
moduleId: options.id,
moduleName: options.name
};
if ( options.output ) {

4
test/cli/module-name/_config.js

@ -0,0 +1,4 @@
module.exports = {
description: 'generates UMD export with correct moduleName',
command: 'rollup main.js --format umd --name myBundle'
}

11
test/cli/module-name/_expected.js

@ -0,0 +1,11 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
global.myBundle = factory();
}(this, function () { 'use strict';
var main = 42;
return main;
}));

1
test/cli/module-name/main.js

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

14
test/test.js

@ -295,6 +295,20 @@ describe( 'rollup', function () {
unintendedError ? done( unintendedError ) : done();
}
else if ( config.result ) {
try {
config.result( code );
} catch ( err ) {
done( err );
}
}
else {
var expected = sander.readFileSync( '_expected.js' ).toString();
assert.equal( code.trim(), expected.trim() );
done();
}
});
});
});

Loading…
Cancel
Save