From 3ed945c8e1cd40d65f9092b72be7127c69ba8676 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Tue, 16 Aug 2016 18:16:31 -0400 Subject: [PATCH] fix noConflict when used via config file (#846) --- bin/src/runRollup.js | 5 +---- test/cli/no-conflict/_config.js | 4 ++++ test/cli/no-conflict/_expected.js | 16 ++++++++++++++++ test/cli/no-conflict/main.js | 1 + test/cli/no-conflict/rollup.config.js | 6 ++++++ 5 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 test/cli/no-conflict/_config.js create mode 100644 test/cli/no-conflict/_expected.js create mode 100644 test/cli/no-conflict/main.js create mode 100644 test/cli/no-conflict/rollup.config.js diff --git a/bin/src/runRollup.js b/bin/src/runRollup.js index cbfa064..270654f 100644 --- a/bin/src/runRollup.js +++ b/bin/src/runRollup.js @@ -70,7 +70,7 @@ export default function runRollup ( command ) { }); // temporarily override require - var defaultLoader = require.extensions[ '.js' ]; + const defaultLoader = require.extensions[ '.js' ]; require.extensions[ '.js' ] = ( m, filename ) => { if ( filename === config ) { m._compile( code, filename ); @@ -147,9 +147,6 @@ function execute ( options, command ) { options.external = external; - options.noConflict = command.conflict === false; - delete command.conflict; - // Use any options passed through the CLI as overrides. Object.keys( equivalents ).forEach( cliOption => { if ( command.hasOwnProperty( cliOption ) ) { diff --git a/test/cli/no-conflict/_config.js b/test/cli/no-conflict/_config.js new file mode 100644 index 0000000..cc870f8 --- /dev/null +++ b/test/cli/no-conflict/_config.js @@ -0,0 +1,4 @@ +module.exports = { + description: 'respects noConflict option', + command: 'rollup --config rollup.config.js' +}; diff --git a/test/cli/no-conflict/_expected.js b/test/cli/no-conflict/_expected.js new file mode 100644 index 0000000..1b363c9 --- /dev/null +++ b/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; + +}))); diff --git a/test/cli/no-conflict/main.js b/test/cli/no-conflict/main.js new file mode 100644 index 0000000..ff8b4c5 --- /dev/null +++ b/test/cli/no-conflict/main.js @@ -0,0 +1 @@ +export default {}; diff --git a/test/cli/no-conflict/rollup.config.js b/test/cli/no-conflict/rollup.config.js new file mode 100644 index 0000000..a1b8d7d --- /dev/null +++ b/test/cli/no-conflict/rollup.config.js @@ -0,0 +1,6 @@ +module.exports = { + entry: 'main.js', + format: 'umd', + moduleName: 'conflictyName', + noConflict: true +};