Browse Source

fix noConflict when used via config file (#846)

rewrite
Rich Harris 8 years ago
parent
commit
3ed945c8e1
  1. 5
      bin/src/runRollup.js
  2. 4
      test/cli/no-conflict/_config.js
  3. 16
      test/cli/no-conflict/_expected.js
  4. 1
      test/cli/no-conflict/main.js
  5. 6
      test/cli/no-conflict/rollup.config.js

5
bin/src/runRollup.js

@ -70,7 +70,7 @@ export default function runRollup ( command ) {
}); });
// temporarily override require // temporarily override require
var defaultLoader = require.extensions[ '.js' ]; const defaultLoader = require.extensions[ '.js' ];
require.extensions[ '.js' ] = ( m, filename ) => { require.extensions[ '.js' ] = ( m, filename ) => {
if ( filename === config ) { if ( filename === config ) {
m._compile( code, filename ); m._compile( code, filename );
@ -147,9 +147,6 @@ function execute ( options, command ) {
options.external = external; options.external = external;
options.noConflict = command.conflict === false;
delete command.conflict;
// Use any options passed through the CLI as overrides. // Use any options passed through the CLI as overrides.
Object.keys( equivalents ).forEach( cliOption => { Object.keys( equivalents ).forEach( cliOption => {
if ( command.hasOwnProperty( cliOption ) ) { if ( command.hasOwnProperty( cliOption ) ) {

4
test/cli/no-conflict/_config.js

@ -0,0 +1,4 @@
module.exports = {
description: 'respects noConflict option',
command: 'rollup --config rollup.config.js'
};

16
test/cli/no-conflict/_expected.js

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

1
test/cli/no-conflict/main.js

@ -0,0 +1 @@
export default {};

6
test/cli/no-conflict/rollup.config.js

@ -0,0 +1,6 @@
module.exports = {
entry: 'main.js',
format: 'umd',
moduleName: 'conflictyName',
noConflict: true
};
Loading…
Cancel
Save