diff --git a/bin/src/help.md b/bin/src/help.md index a0977e609db..e9d4c5f206f 100644 --- a/bin/src/help.md +++ b/bin/src/help.md @@ -5,30 +5,31 @@ Usage: rollup [options] Basic options: --v, --version Show version number --h, --help Show this help message --c, --config Use this config file (if argument is used but value - is unspecified, defaults to rollup.config.js) --w, --watch Watch files in bundle and rebuild on changes --i, --input Input (alternative to ) --o, --output Output (if absent, prints to stdout) --f, --format [es] Type of output (amd, cjs, es, iife, umd) --e, --external Comma-separate list of module IDs to exclude --g, --globals Comma-separate list of `module ID:Global` pairs - Any module IDs defined here are added to external --n, --name Name for UMD export --u, --id ID for AMD module (default is anonymous) --m, --sourcemap Generate sourcemap (`-m inline` for inline map) ---no-strict Don't emit a `"use strict";` in the generated modules. ---no-indent Don't indent result ---environment Settings passed to config file (see example) ---no-conflict Generate a noConflict method for UMD globals ---silent Don't print warnings ---intro Content to insert at top of bundle (inside wrapper) ---outro Content to insert at end of bundle (inside wrapper) ---banner Content to insert at top of bundle (outside wrapper) ---footer Content to insert at end of bundle (outside wrapper) ---interop Include interop block (true by default) +-v, --version Show version number +-h, --help Show this help message +-c, --config Use this config file (if argument is used but value + is unspecified, defaults to rollup.config.js) +-w, --watch Watch files in bundle and rebuild on changes +-i, --input Input (alternative to ) +-o, --output.file Output (if absent, prints to stdout) +-f, --output.format [es] Type of output (amd, cjs, es, iife, umd) +-e, --external Comma-separate list of module IDs to exclude +-g, --globals Comma-separate list of `module ID:Global` pairs + Any module IDs defined here are added to external +-n, --name Name for UMD export +-m, --sourcemap Generate sourcemap (`-m inline` for inline map) +--amd.id ID for AMD module (default is anonymous) +--amd.define Function to use in place of `define` +--no-strict Don't emit a `"use strict";` in the generated modules. +--no-indent Don't indent result +--environment Settings passed to config file (see example) +--no-conflict Generate a noConflict method for UMD globals +--silent Don't print warnings +--intro Content to insert at top of bundle (inside wrapper) +--outro Content to insert at end of bundle (inside wrapper) +--banner Content to insert at top of bundle (outside wrapper) +--footer Content to insert at end of bundle (outside wrapper) +--interop Include interop block (true by default) Examples: diff --git a/bin/src/index.js b/bin/src/index.js index db432c28ce8..8024961f8cc 100644 --- a/bin/src/index.js +++ b/bin/src/index.js @@ -12,14 +12,14 @@ const command = minimist( process.argv.slice( 2 ), { c: 'config', d: 'indent', e: 'external', - f: 'format', + f: 'output.format', g: 'globals', h: 'help', i: 'input', l: 'legacy', m: 'sourcemap', n: 'name', - o: 'output', + o: 'output.file', u: 'id', v: 'version', w: 'watch' @@ -35,5 +35,11 @@ else if ( command.version ) { } else { + try { + require('source-map-support').install(); + } catch (err) { + // do nothing + } + run( command ); } diff --git a/bin/src/run/batchWarnings.js b/bin/src/run/batchWarnings.js index 032c225f1f8..de769487e97 100644 --- a/bin/src/run/batchWarnings.js +++ b/bin/src/run/batchWarnings.js @@ -74,6 +74,13 @@ export default function batchWarnings () { } const immediateHandlers = { + DEPRECATED_OPTIONS: warning => { + title( `Some options have been renamed` ); + warning.deprecations.forEach(option => { + stderr( `${chalk.bold(option.old)} is now ${option.new}` ); + }); + }, + MISSING_NODE_BUILTINS: warning => { title( `Missing shims for Node.js built-ins` ); diff --git a/bin/src/run/build.js b/bin/src/run/build.js index 0ef94446991..f437a380eb3 100644 --- a/bin/src/run/build.js +++ b/bin/src/run/build.js @@ -6,26 +6,26 @@ import relativeId from '../../../src/utils/relativeId.js'; import { mapSequence } from '../../../src/utils/promise.js'; import SOURCEMAPPING_URL from '../sourceMappingUrl.js'; -export default function build ( options, warnings, silent ) { - const useStdout = !options.targets && !options.dest; - const targets = options.targets ? options.targets : [{ dest: options.dest, format: options.format }]; +export default function build ( inputOptions, outputOptions, warnings, silent ) { + const useStdout = outputOptions.length === 1 && !outputOptions[0].file; const start = Date.now(); - const dests = useStdout ? [ 'stdout' ] : targets.map( t => relativeId( t.dest ) ); - if ( !silent ) stderr( chalk.cyan( `\n${chalk.bold( options.entry )} → ${chalk.bold( dests.join( ', ' ) )}...` ) ); + const files = useStdout ? [ 'stdout' ] : outputOptions.map( t => relativeId( t.file ) ); + if ( !silent ) stderr( chalk.cyan( `\n${chalk.bold( inputOptions.input )} → ${chalk.bold( files.join( ', ' ) )}...` ) ); - return rollup.rollup( options ) + return rollup.rollup( inputOptions ) .then( bundle => { if ( useStdout ) { - if ( options.sourceMap && options.sourceMap !== 'inline' ) { + const output = outputOptions[0]; + if ( output.sourcemap && output.sourcemap !== 'inline' ) { handleError({ code: 'MISSING_OUTPUT_OPTION', message: 'You must specify an --output (-o) option when creating a file with a sourcemap' }); } - return bundle.generate(options).then( ({ code, map }) => { - if ( options.sourceMap === 'inline' ) { + return bundle.generate(output).then( ({ code, map }) => { + if ( output.sourcemap === 'inline' ) { code += `\n//# ${SOURCEMAPPING_URL}=${map.toUrl()}\n`; } @@ -33,24 +33,13 @@ export default function build ( options, warnings, silent ) { }); } - return mapSequence( targets, target => { - return bundle.write( assign( clone( options ), target ) ); + return mapSequence( outputOptions, output => { + return bundle.write( output ); }); }) .then( () => { warnings.flush(); - if ( !silent ) stderr( chalk.green( `created ${chalk.bold( dests.join( ', ' ) )} in ${chalk.bold(ms( Date.now() - start))}` ) ); + if ( !silent ) stderr( chalk.green( `created ${chalk.bold( files.join( ', ' ) )} in ${chalk.bold(ms( Date.now() - start))}` ) ); }) .catch( handleError ); -} - -function clone ( object ) { - return assign( {}, object ); -} - -function assign ( target, source ) { - Object.keys( source ).forEach( key => { - target[ key ] = source[ key ]; - }); - return target; } \ No newline at end of file diff --git a/bin/src/run/index.js b/bin/src/run/index.js index 0b986b505e0..c69bbe2a0aa 100644 --- a/bin/src/run/index.js +++ b/bin/src/run/index.js @@ -79,20 +79,28 @@ function execute ( configFile, configs, command ) { watch( configFile, configs, command, command.silent ); } else { return sequence( configs, config => { - const options = mergeOptions( config, command ); + const { inputOptions, outputOptions, deprecations } = mergeOptions( config, command ); const warnings = batchWarnings(); - const onwarn = options.onwarn; + const onwarn = inputOptions.onwarn; if ( onwarn ) { - options.onwarn = warning => { + inputOptions.onwarn = warning => { onwarn( warning, warnings.add ); }; } else { - options.onwarn = warnings.add; + inputOptions.onwarn = warnings.add; } - return build( options, warnings, command.silent ); + if (deprecations.length) { + inputOptions.onwarn({ + code: 'DEPRECATED_OPTIONS', + message: `The following options have been renamed — please update your config: ${deprecations.map(option => `${option.old} -> ${option.new}`).join(', ')}`, + deprecations + }); + } + + return build( inputOptions, outputOptions, warnings, command.silent ); }); } } \ No newline at end of file diff --git a/bin/src/run/loadConfigFile.js b/bin/src/run/loadConfigFile.js index c1db88c7f21..9c9d0a9f18e 100644 --- a/bin/src/run/loadConfigFile.js +++ b/bin/src/run/loadConfigFile.js @@ -9,7 +9,7 @@ export default function loadConfigFile (configFile, silent) { const warnings = batchWarnings(); return rollup.rollup({ - entry: configFile, + input: configFile, external: id => { return (id[0] !== '.' && !path.isAbsolute(id)) || id.slice(-5,id.length) === '.json'; }, diff --git a/bin/src/run/mergeOptions.js b/bin/src/run/mergeOptions.js index 8e556f265bd..acbc897c67c 100644 --- a/bin/src/run/mergeOptions.js +++ b/bin/src/run/mergeOptions.js @@ -1,31 +1,30 @@ -import batchWarnings from './batchWarnings.js'; - -const equivalents = { - useStrict: 'useStrict', - banner: 'banner', - footer: 'footer', - format: 'format', - globals: 'globals', - id: 'moduleId', - indent: 'indent', - interop: 'interop', - input: 'entry', - intro: 'intro', - legacy: 'legacy', - name: 'moduleName', - output: 'dest', - outro: 'outro', - sourcemap: 'sourceMap', - treeshake: 'treeshake' -}; +import ensureArray from '../../../src/utils/ensureArray.js'; +import deprecateOptions from '../../../src/utils/deprecateOptions.js'; export default function mergeOptions ( config, command ) { - const options = Object.assign( {}, config ); + // deprecations... TODO + const deprecations = deprecate( config, command ); - let external; + function getOption(name) { + return command[name] !== undefined ? command[name] : config[name]; + } + + const inputOptions = { + input: getOption('input'), + legacy: getOption('legacy'), + treeshake: getOption('treeshake'), + acorn: config.acorn, + context: config.context, + moduleContext: config.moduleContext, + plugins: config.plugins, + onwarn: config.onwarn + }; + + // legacy, to ensure e.g. commonjs plugin still works + inputOptions.entry = inputOptions.input; const commandExternal = ( command.external || '' ).split( ',' ); - const optionsExternal = options.external; + const configExternal = config.external; if ( command.globals ) { const globals = Object.create( null ); @@ -43,34 +42,79 @@ export default function mergeOptions ( config, command ) { command.globals = globals; } - if ( typeof optionsExternal === 'function' ) { - external = id => { - return optionsExternal( id ) || ~commandExternal.indexOf( id ); + if ( typeof configExternal === 'function' ) { + inputOptions.external = id => { + return configExternal( id ) || ~commandExternal.indexOf( id ); }; } else { - external = ( optionsExternal || [] ).concat( commandExternal ); - } - - if (typeof command.extend !== 'undefined') { - options.extend = command.extend; + inputOptions.external = ( configExternal || [] ).concat( commandExternal ); } if (command.silent) { - options.onwarn = () => {}; + inputOptions.onwarn = () => {}; } - options.external = external; + const baseOutputOptions = { + extend: command.extend !== undefined ? command.extend : config.extend, + amd: Object.assign({}, config.amd, command.amd), - // Use any options passed through the CLI as overrides. - Object.keys( equivalents ).forEach( cliOption => { - if ( command.hasOwnProperty( cliOption ) ) { - options[ equivalents[ cliOption ] ] = command[ cliOption ]; - } - }); + banner: getOption('banner'), + footer: getOption('footer'), + intro: getOption('intro'), + outro: getOption('outro'), + sourcemap: getOption('sourcemap'), + name: getOption('name'), + globals: getOption('globals'), + interop: getOption('interop'), + legacy: getOption('legacy'), + indent: getOption('indent'), + strict: getOption('strict'), + noConflict: getOption('noConflict') + }; - const targets = options.dest ? [{ dest: options.dest, format: options.format }] : options.targets; - options.targets = targets; - delete options.dest; + const outputOptions = ( + (command.output || config.output) ? + ensureArray(command.output || config.output) : + [{ + file: command.output ? command.output.file : null, + format: command.output ? command.output.format : null + }] + ).map(output => { + return Object.assign({}, baseOutputOptions, output); + }); - return options; + return { inputOptions, outputOptions, deprecations }; } + +function deprecate( config, command ) { + const deprecations = []; + + // CLI + if ( command.id ) { + deprecations.push({ + old: '-u/--id', + new: '--amd.id' + }); + (command.amd || (command.amd = {})).id = command.id; + } + + if ( typeof command.output === 'string' ) { + deprecations.push({ + old: '--output', + new: '--output.file' + }); + command.output = { file: command.output }; + } + + if ( command.format ) { + deprecations.push({ + old: '--format', + new: '--output.format' + }); + (command.output || (command.output = {})).format = command.format; + } + + // config file + deprecations.push(...deprecateOptions(config)); + return deprecations; +} \ No newline at end of file diff --git a/bin/src/run/watch.js b/bin/src/run/watch.js index d86a57c1d03..c29b4c37008 100644 --- a/bin/src/run/watch.js +++ b/bin/src/run/watch.js @@ -15,17 +15,18 @@ export default function watch(configFile, configs, command, silent) { configs = configs.map(options => { const merged = mergeOptions(options, command); - - const onwarn = merged.onwarn; + const onwarn = merged.inputOptions.onwarn; if ( onwarn ) { - merged.onwarn = warning => { + merged.inputOptions.onwarn = warning => { onwarn( warning, warnings.add ); }; } else { - merged.onwarn = warnings.add; + merged.inputOptions.onwarn = warnings.add; } - return merged; + return Object.assign({}, merged.inputOptions, { + output: merged.outputOptions + }); }); let watcher; diff --git a/package-lock.json b/package-lock.json index 7a40e23a0f6..31980e7c411 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "rollup", - "version": "0.47.4", + "version": "0.47.6", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/src/Bundle.js b/src/Bundle.js index 594e2466b8a..aaaa3c3fd70 100644 --- a/src/Bundle.js +++ b/src/Bundle.js @@ -37,11 +37,11 @@ export default class Bundle { return acc; }, options ); - if ( !options.entry ) { - throw new Error( 'You must supply options.entry to rollup' ); + if ( !options.input ) { + throw new Error( 'You must supply options.input to rollup' ); } - this.entry = options.entry; + this.entry = options.input; this.entryId = null; this.entryModule = null; @@ -338,15 +338,15 @@ export default class Bundle { return transform( this, source, id, this.plugins ); } ) .then( source => { - const { code, originalCode, originalSourceMap, ast, sourceMapChain, resolvedIds } = source; + const { code, originalCode, originalSourcemap, ast, sourcemapChain, resolvedIds } = source; const module = new Module( { id, code, originalCode, - originalSourceMap, + originalSourcemap, ast, - sourceMapChain, + sourcemapChain, resolvedIds, bundle: this } ); @@ -545,10 +545,10 @@ export default class Bundle { const bundleSourcemapChain = []; return transformBundle( prevCode, this.plugins, bundleSourcemapChain, options ).then( code => { - if ( options.sourceMap ) { - timeStart( 'sourceMap' ); + if ( options.sourcemap ) { + timeStart( 'sourcemap' ); - let file = options.sourceMapFile || options.dest; + let file = options.sourcemapFile || options.file; if ( file ) file = resolve( typeof process !== 'undefined' ? process.cwd() : '', file ); if ( this.hasLoaders || find( this.plugins, plugin => plugin.transform || plugin.transformBundle ) ) { @@ -563,7 +563,7 @@ export default class Bundle { map.sources = map.sources.map( normalize ); - timeEnd( 'sourceMap' ); + timeEnd( 'sourcemap' ); } if ( code[ code.length - 1 ] !== '\n' ) code += '\n'; diff --git a/src/Module.js b/src/Module.js index f44638c8cba..7ba6a4e80d8 100644 --- a/src/Module.js +++ b/src/Module.js @@ -32,13 +32,13 @@ function tryParse ( module, acornOptions ) { } export default class Module { - constructor ( { id, code, originalCode, originalSourceMap, ast, sourceMapChain, resolvedIds, resolvedExternalIds, bundle } ) { + constructor ( { id, code, originalCode, originalSourcemap, ast, sourcemapChain, resolvedIds, resolvedExternalIds, bundle } ) { this.code = code; this.id = id; this.bundle = bundle; this.originalCode = originalCode; - this.originalSourceMap = originalSourceMap; - this.sourceMapChain = sourceMapChain; + this.originalSourcemap = originalSourcemap; + this.sourcemapChain = sourcemapChain; this.comments = []; @@ -363,9 +363,9 @@ export default class Module { dependencies: this.dependencies.map( module => module.id ), code: this.code, originalCode: this.originalCode, - originalSourceMap: this.originalSourceMap, + originalSourcemap: this.originalSourcemap, ast: this.astClone, - sourceMapChain: this.sourceMapChain, + sourcemapChain: this.sourcemapChain, resolvedIds: this.resolvedIds, resolvedExternalIds: this.resolvedExternalIds }; diff --git a/src/finalisers/amd.js b/src/finalisers/amd.js index 6838b665396..8a9d275af98 100644 --- a/src/finalisers/amd.js +++ b/src/finalisers/amd.js @@ -20,7 +20,7 @@ export default function amd ( bundle, magicString, { exportMode, indentString, i ( amdOptions.id ? `'${amdOptions.id}', ` : `` ) + ( deps.length ? `[${deps.join( ', ' )}], ` : `` ); - const useStrict = options.useStrict !== false ? ` 'use strict';` : ``; + const useStrict = options.strict !== false ? ` 'use strict';` : ``; const define = amdOptions.define || 'define'; const wrapperStart = `${define}(${params}function (${args.join( ', ' )}) {${useStrict}\n\n`; diff --git a/src/finalisers/cjs.js b/src/finalisers/cjs.js index f57f409bf16..c3858b34724 100644 --- a/src/finalisers/cjs.js +++ b/src/finalisers/cjs.js @@ -2,7 +2,7 @@ import getExportBlock from './shared/getExportBlock.js'; import esModuleExport from './shared/esModuleExport.js'; export default function cjs ( bundle, magicString, { exportMode, intro, outro }, options ) { - intro = ( options.useStrict === false ? intro : `'use strict';\n\n${intro}` ) + + intro = ( options.strict === false ? intro : `'use strict';\n\n${intro}` ) + ( exportMode === 'named' && options.legacy !== true ? `${esModuleExport}\n\n` : '' ); let needsInterop = false; diff --git a/src/finalisers/iife.js b/src/finalisers/iife.js index 34ed22e019d..5d4f7242463 100644 --- a/src/finalisers/iife.js +++ b/src/finalisers/iife.js @@ -26,14 +26,14 @@ const thisProp = name => `this${keypath( name )}`; export default function iife ( bundle, magicString, { exportMode, indentString, intro, outro }, options ) { const globalNameMaker = getGlobalNameMaker( options.globals || blank(), bundle, 'null' ); - const { extend, moduleName: name } = options; + const { extend, name } = options; const isNamespaced = name && name.indexOf( '.' ) !== -1; const possibleVariableAssignment = !extend && !isNamespaced; if ( name && possibleVariableAssignment && !isLegal(name) ) { error({ code: 'ILLEGAL_IDENTIFIER_AS_NAME', - message: `Given moduleName (${name}) is not legal JS identifier. If you need this you can try --extend option` + message: `Given name (${name}) is not legal JS identifier. If you need this you can try --extend option` }); } @@ -46,7 +46,7 @@ export default function iife ( bundle, magicString, { exportMode, indentString, if ( exportMode !== 'none' && !name ) { error({ code: 'INVALID_OPTION', - message: `You must supply options.moduleName for IIFE bundles` + message: `You must supply options.name for IIFE bundles` }); } @@ -58,7 +58,7 @@ export default function iife ( bundle, magicString, { exportMode, indentString, args.unshift( 'exports' ); } - const useStrict = options.useStrict !== false ? `${indentString}'use strict';\n\n` : ``; + const useStrict = options.strict !== false ? `${indentString}'use strict';\n\n` : ``; let wrapperIntro = `(function (${args}) {\n${useStrict}`; diff --git a/src/finalisers/umd.js b/src/finalisers/umd.js index 31bd5b9e288..023a30360d4 100644 --- a/src/finalisers/umd.js +++ b/src/finalisers/umd.js @@ -37,10 +37,10 @@ function safeAccess ( name ) { const wrapperOutro = '\n\n})));'; export default function umd ( bundle, magicString, { exportMode, indentString, intro, outro }, options ) { - if ( exportMode !== 'none' && !options.moduleName ) { + if ( exportMode !== 'none' && !options.name ) { error({ code: 'INVALID_OPTION', - message: 'You must supply options.moduleName for UMD bundles' + message: 'You must supply options.name for UMD bundles' }); } @@ -58,7 +58,7 @@ export default function umd ( bundle, magicString, { exportMode, indentString, i if ( exportMode === 'named' ) { amdDeps.unshift( `'exports'` ); cjsDeps.unshift( `exports` ); - globalDeps.unshift( `(${setupNamespace(options.moduleName)} = ${options.extend ? `${globalProp(options.moduleName)} || ` : '' }{})` ); + globalDeps.unshift( `(${setupNamespace(options.name)} = ${options.extend ? `${globalProp(options.name)} || ` : '' }{})` ); args.unshift( 'exports' ); } @@ -72,9 +72,9 @@ export default function umd ( bundle, magicString, { exportMode, indentString, i const define = amdOptions.define || 'define'; const cjsExport = exportMode === 'default' ? `module.exports = ` : ``; - const defaultExport = exportMode === 'default' ? `${setupNamespace(options.moduleName)} = ` : ''; + const defaultExport = exportMode === 'default' ? `${setupNamespace(options.name)} = ` : ''; - const useStrict = options.useStrict !== false ? ` 'use strict';` : ``; + const useStrict = options.strict !== false ? ` 'use strict';` : ``; let globalExport; @@ -89,10 +89,10 @@ export default function umd ( bundle, magicString, { exportMode, indentString, i factory(${['exports'].concat(globalDeps)});`; } globalExport = `(function() { - var current = ${safeAccess(options.moduleName)}; + var current = ${safeAccess(options.name)}; ${factory} - ${globalProp(options.moduleName)} = exports; - exports.noConflict = function() { ${globalProp(options.moduleName)} = current; return exports; }; + ${globalProp(options.name)} = exports; + exports.noConflict = function() { ${globalProp(options.name)} = current; return exports; }; })()`; } else { globalExport = `(${defaultExport}factory(${globalDeps}))`; diff --git a/src/rollup/index.js b/src/rollup/index.js index 797bca0601f..03d50f35b6d 100644 --- a/src/rollup/index.js +++ b/src/rollup/index.js @@ -16,32 +16,34 @@ const ALLOWED_KEYS = [ 'banner', 'cache', 'context', - 'dest', 'entry', 'exports', 'extend', 'external', + 'file', 'footer', 'format', 'globals', 'indent', + 'input', 'interop', 'intro', 'legacy', 'moduleContext', - 'moduleName', + 'name', 'noConflict', 'onwarn', + 'output', 'outro', 'paths', 'plugins', 'preferConst', 'pureExternalModules', - 'sourceMap', - 'sourceMapFile', + 'sourcemap', + 'sourcemapFile', + 'strict', 'targets', 'treeshake', - 'useStrict', 'watch' ]; @@ -52,30 +54,84 @@ function checkAmd ( options ) { options.amd = { id: options.moduleId }; delete options.moduleId; - const msg = `options.moduleId is deprecated in favour of options.amd = { id: moduleId }`; + const message = `options.moduleId is deprecated in favour of options.amd = { id: moduleId }`; if ( options.onwarn ) { - options.onwarn( msg ); + options.onwarn({ message }); } else { - console.warn( msg ); // eslint-disable-line no-console + console.warn( message ); // eslint-disable-line no-console } } } -function checkOptions ( options ) { - if ( !options ) { - throw new Error( 'You must supply an options object to rollup' ); - } - +function checkInputOptions ( options, warn ) { if ( options.transform || options.load || options.resolveId || options.resolveExternal ) { throw new Error( 'The `transform`, `load`, `resolveId` and `resolveExternal` options are deprecated in favour of a unified plugin API. See https://github.com/rollup/rollup/wiki/Plugins for details' ); } - checkAmd (options); + if ( options.entry && !options.input ) { + options.input = options.entry; + warn({ + message: `options.entry is deprecated, use options.input` + }); + } const err = validateKeys( keys(options), ALLOWED_KEYS ); if ( err ) throw err; } +const deprecated = { + dest: 'file', + moduleName: 'name', + sourceMap: 'sourcemap', + sourceMapFile: 'sourcemapFile', + useStrict: 'strict' +}; + +function checkOutputOptions ( options, warn ) { + if ( options.format === 'es6' ) { + error({ + message: 'The `es6` output format is deprecated – use `es` instead', + url: `https://github.com/rollup/rollup/wiki/JavaScript-API#format` + }); + } + + if ( !options.format ) { + error({ + message: `You must specify options.format, which can be one of 'amd', 'cjs', 'es', 'iife' or 'umd'`, + url: `https://github.com/rollup/rollup/wiki/JavaScript-API#format` + }); + } + + if ( options.moduleId ) { + if ( options.amd ) throw new Error( 'Cannot have both options.amd and options.moduleId' ); + + options.amd = { id: options.moduleId }; + delete options.moduleId; + + warn({ + message: `options.moduleId is deprecated in favour of options.amd = { id: moduleId }` + }); + } + + const deprecations = []; + Object.keys( deprecated ).forEach( old => { + if ( old in options ) { + deprecations.push({ old, new: deprecated[ old ] }); + options[ deprecated[ old ] ] = options[ old ]; + delete options[ old ]; + } + }); + + if ( deprecations.length ) { + const message = `The following options have been renamed — please update your config: ${deprecations.map(option => `${option.old} -> ${option.new}`).join(', ')}`; + warn({ + code: 'DEPRECATED_OPTIONS', + message, + deprecations + }); + } +} + const throwAsyncGenerateError = { get () { throw new Error( `bundle.generate(...) now returns a Promise instead of a { code, map } object` ); @@ -84,7 +140,13 @@ const throwAsyncGenerateError = { export default function rollup ( options ) { try { - checkOptions( options ); + if ( !options ) { + throw new Error( 'You must supply an options object to rollup' ); + } + + const warn = options.onwarn || (warning => console.warn( warning.message )); // eslint-disable-line no-console + + checkInputOptions( options, warn ); const bundle = new Bundle( options ); timeStart( '--BUILD--' ); @@ -92,19 +154,11 @@ export default function rollup ( options ) { return bundle.build().then( () => { timeEnd( '--BUILD--' ); - function generate ( options = {} ) { - if ( options.format === 'es6' ) { - throw new Error( 'The `es6` output format is deprecated – use `es` instead' ); + function generate ( options ) { + if ( !options ) { + throw new Error( 'You must supply an options object' ); } - - if ( !options.format ) { - error({ - code: 'MISSING_FORMAT', - message: `You must supply an output format`, - url: `https://github.com/rollup/rollup/wiki/JavaScript-API#format` - }); - } - + checkOutputOptions( options, warn ); checkAmd( options ); timeStart( '--GENERATE--' ); @@ -140,38 +194,38 @@ export default function rollup ( options ) { generate, write: options => { - if ( !options || !options.dest ) { + if ( !options || (!options.file && !options.dest) ) { error({ code: 'MISSING_OPTION', - message: 'You must supply options.dest to bundle.write' + message: 'You must specify options.file' }); } - const dest = options.dest; - return generate( options ).then( output => { - let { code, map } = output; + return generate( options ).then( result => { + const file = options.file; + let { code, map } = result; const promises = []; - if ( options.sourceMap ) { + if ( options.sourcemap ) { let url; - if ( options.sourceMap === 'inline' ) { + if ( options.sourcemap === 'inline' ) { url = map.toUrl(); } else { - url = `${basename( dest )}.map`; - promises.push( writeFile( dest + '.map', map.toString() ) ); + url = `${basename( file )}.map`; + promises.push( writeFile( file + '.map', map.toString() ) ); } code += `//# ${SOURCEMAPPING_URL}=${url}\n`; } - promises.push( writeFile( dest, code ) ); + promises.push( writeFile( file, code ) ); return Promise.all( promises ).then( () => { return mapSequence( bundle.plugins.filter( plugin => plugin.onwrite ), plugin => { return Promise.resolve( plugin.onwrite( assign({ bundle: result - }, options ), output)); + }, options ), result)); }); }); }); diff --git a/src/utils/collapseSourcemaps.js b/src/utils/collapseSourcemaps.js index db4cebb1c06..5bee89ceec1 100644 --- a/src/utils/collapseSourcemaps.js +++ b/src/utils/collapseSourcemaps.js @@ -106,32 +106,32 @@ class Link { export default function collapseSourcemaps ( bundle, file, map, modules, bundleSourcemapChain ) { const moduleSources = modules.filter( module => !module.excludeFromSourcemap ).map( module => { - let sourceMapChain = module.sourceMapChain; + let sourcemapChain = module.sourcemapChain; let source; - if ( module.originalSourceMap == null ) { + if ( module.originalSourcemap == null ) { source = new Source( module.id, module.originalCode ); } else { - const sources = module.originalSourceMap.sources; - const sourcesContent = module.originalSourceMap.sourcesContent || []; + const sources = module.originalSourcemap.sources; + const sourcesContent = module.originalSourcemap.sourcesContent || []; if ( sources == null || ( sources.length <= 1 && sources[0] == null ) ) { source = new Source( module.id, sourcesContent[0] ); - sourceMapChain = [ module.originalSourceMap ].concat( sourceMapChain ); + sourcemapChain = [ module.originalSourcemap ].concat( sourcemapChain ); } else { // TODO indiscriminately treating IDs and sources as normal paths is probably bad. const directory = dirname( module.id ) || '.'; - const sourceRoot = module.originalSourceMap.sourceRoot || '.'; + const sourceRoot = module.originalSourcemap.sourceRoot || '.'; const baseSources = sources.map( (source, i) => { return new Source( resolve( directory, sourceRoot, source ), sourcesContent[i] ); }); - source = new Link( module.originalSourceMap, baseSources ); + source = new Link( module.originalSourcemap, baseSources ); } } - sourceMapChain.forEach( map => { + sourcemapChain.forEach( map => { if ( map.missing ) { bundle.warn({ code: 'SOURCEMAP_BROKEN', diff --git a/src/utils/deprecateOptions.js b/src/utils/deprecateOptions.js new file mode 100644 index 00000000000..50726d64ed5 --- /dev/null +++ b/src/utils/deprecateOptions.js @@ -0,0 +1,65 @@ +export default function deprecateOptions(options) { + const deprecations = []; + + if ( options.entry ) { + deprecations.push({ old: 'options.entry', new: 'options.input' }); + options.input = options.entry; // don't delete, as plugins sometimes depend on this... + } + + if ( options.moduleName ) { + deprecations.push({ old: 'options.moduleName', new: 'options.name' }); + options.name = options.moduleName; + delete options.moduleName; + } + + if ( options.sourceMap ) { + deprecations.push({ old: 'options.sourceMap', new: 'options.sourcemap' }); + options.sourcemap = options.sourceMap; + delete options.sourceMap; + } + + if ( options.sourceMapFile ) { + deprecations.push({ old: 'options.sourceMapFile', new: 'options.sourcemapFile' }); + options.sourcemapFile = options.sourceMapFile; + delete options.sourceMapFile; + } + + if ( options.useStrict ) { + deprecations.push({ old: 'options.useStrict', new: 'options.strict' }); + options.strict = options.useStrict; + delete options.useStrict; + } + + if ( options.targets ) { + deprecations.push({ old: 'options.targets', new: 'options.output' }); + options.output = options.targets; + delete options.targets; + + let deprecatedDest = false; + options.output.forEach(output => { + if (output.dest) { + if (!deprecatedDest) { + deprecations.push({ old: 'output.dest', new: 'output.file' }); + deprecatedDest = true; + } + output.file = output.dest; + delete output.dest; + } + }); + } else if ( options.dest ) { + deprecations.push({ old: 'options.dest', new: 'options.output.file' }); + options.output = { + file: options.dest, + format: options.format + }; + delete options.dest; + } + + if ( options.format ) { + if ( !options.output ) options.output = { format: options.format }; + deprecations.push({ old: 'options.format', new: 'options.output.format' }); + delete options.format; + } + + return deprecations; +} \ No newline at end of file diff --git a/src/utils/getExportMode.js b/src/utils/getExportMode.js index d61b1288464..f9fdd9c8d74 100644 --- a/src/utils/getExportMode.js +++ b/src/utils/getExportMode.js @@ -8,7 +8,7 @@ function badExports ( option, keys ) { }); } -export default function getExportMode ( bundle, {exports: exportMode, moduleName, format} ) { +export default function getExportMode ( bundle, {exports: exportMode, name, format} ) { const exportKeys = keys( bundle.entryModule.exports ) .concat( keys( bundle.entryModule.reexports ) ) .concat( bundle.entryModule.exportAllSources ); // not keys, but makes our job easier this way @@ -30,7 +30,7 @@ export default function getExportMode ( bundle, {exports: exportMode, moduleName if ( bundle.entryModule.exports.default && format !== 'es') { bundle.warn({ code: 'MIXED_EXPORTS', - message: `Using named and default exports together. Consumers of your bundle will have to use ${moduleName || 'bundle'}['default'] to access the default export, which may not be what you want. Use \`exports: 'named'\` to disable this warning`, + message: `Using named and default exports together. Consumers of your bundle will have to use ${name || 'bundle'}['default'] to access the default export, which may not be what you want. Use \`exports: 'named'\` to disable this warning`, url: `https://github.com/rollup/rollup/wiki/JavaScript-API#exports` }); } diff --git a/src/utils/transform.js b/src/utils/transform.js index b22acdec3a8..42930d43015 100644 --- a/src/utils/transform.js +++ b/src/utils/transform.js @@ -4,12 +4,12 @@ import error from './error.js'; import getCodeFrame from './getCodeFrame.js'; export default function transform ( bundle, source, id, plugins ) { - const sourceMapChain = []; + const sourcemapChain = []; - const originalSourceMap = typeof source.map === 'string' ? JSON.parse( source.map ) : source.map; + const originalSourcemap = typeof source.map === 'string' ? JSON.parse( source.map ) : source.map; - if ( originalSourceMap && typeof originalSourceMap.mappings === 'string' ) { - originalSourceMap.mappings = decode( originalSourceMap.mappings ); + if ( originalSourcemap && typeof originalSourcemap.mappings === 'string' ) { + originalSourcemap.mappings = decode( originalSourcemap.mappings ); } const originalCode = source.code; @@ -94,7 +94,7 @@ export default function transform ( bundle, source, id, plugins ) { result.map.mappings = decode( result.map.mappings ); } - sourceMapChain.push( result.map || { missing: true, plugin: plugin.name }); // lil' bit hacky but it works + sourcemapChain.push( result.map || { missing: true, plugin: plugin.name }); // lil' bit hacky but it works ast = result.ast; return result.code; @@ -106,5 +106,5 @@ export default function transform ( bundle, source, id, plugins ) { }); }); - return promise.then( code => ({ code, originalCode, originalSourceMap, ast, sourceMapChain }) ); + return promise.then( code => ({ code, originalCode, originalSourcemap, ast, sourcemapChain }) ); } diff --git a/src/utils/transformBundle.js b/src/utils/transformBundle.js index 9015cd9f2f5..19e77de8430 100644 --- a/src/utils/transformBundle.js +++ b/src/utils/transformBundle.js @@ -1,7 +1,7 @@ import { decode } from 'sourcemap-codec'; import error from './error.js'; -export default function transformBundle ( code, plugins, sourceMapChain, options ) { +export default function transformBundle ( code, plugins, sourcemapChain, options ) { return plugins.reduce( ( promise, plugin ) => { if ( !plugin.transformBundle ) return promise; @@ -23,7 +23,7 @@ export default function transformBundle ( code, plugins, sourceMapChain, options map.mappings = decode( map.mappings ); } - sourceMapChain.push( map ); + sourcemapChain.push( map ); return result.code; }).catch( err => { diff --git a/src/watch/index.js b/src/watch/index.js index f50433fd450..9475e95d01f 100644 --- a/src/watch/index.js +++ b/src/watch/index.js @@ -75,20 +75,54 @@ class Watcher extends EventEmitter { } class Task { - constructor(watcher, options) { + constructor(watcher, config) { this.cache = null; this.watcher = watcher; - this.options = options; this.dirty = true; this.closed = false; this.watched = new Set(); - this.targets = options.targets ? options.targets : [{ dest: options.dest, format: options.format }]; - - this.dests = (this.targets.map(t => t.dest)).map(dest => path.resolve(dest)); + this.inputOptions = { + input: config.input, + entry: config.input, // legacy, for e.g. commonjs plugin + legacy: config.legacy, + treeshake: config.treeshake, + plugins: config.plugins, + external: config.external, + onwarn: config.onwarn, + acorn: config.acorn, + context: config.context, + moduleContext: config.moduleContext + }; + + const baseOutputOptions = { + extend: config.extend, + exports: config.exports, + amd: config.amd, + banner: config.banner, + footer: config.footer, + intro: config.intro, + outro: config.outro, + sourcemap: config.sourcemap, + sourcemapFile: config.sourcemapFile, + name: config.name, + globals: config.globals, + interop: config.interop, + legacy: config.legacy, + indent: config.indent, + strict: config.strict, + noConflict: config.noConflict, + paths: config.paths, + preferConst: config.preferConst + }; + + this.outputs = ensureArray(config.output).map(output => { + return Object.assign({}, baseOutputOptions, output); + }); + this.outputFiles = this.outputs.map(output => path.resolve(output.file)); - const watchOptions = options.watch || {}; + const watchOptions = config.watch || {}; if ('useChokidar' in watchOptions) watchOptions.chokidar = watchOptions.useChokidar; let chokidarOptions = 'chokidar' in watchOptions ? watchOptions.chokidar : !!chokidar; if (chokidarOptions) { @@ -128,7 +162,7 @@ class Task { if (!this.dirty) return; this.dirty = false; - const options = Object.assign(this.options, { + const options = Object.assign(this.inputOptions, { cache: this.cache }); @@ -136,8 +170,8 @@ class Task { this.watcher.emit('event', { code: 'BUNDLE_START', - input: this.options.entry, - output: this.dests + input: this.inputOptions.input, + output: this.outputFiles }); return rollup(options) @@ -160,17 +194,14 @@ class Task { this.watched = watched; return Promise.all( - this.targets.map(target => { - const options = Object.assign({}, this.options, target); - return bundle.write(options); - }) + this.outputs.map(output => bundle.write(output)) ); }) .then(() => { this.watcher.emit('event', { code: 'BUNDLE_END', - input: this.options.entry, - output: this.dests, + input: this.inputOptions.input, + output: this.outputFiles, duration: Date.now() - start }); }) @@ -191,7 +222,7 @@ class Task { watchFile(id) { if (!this.filter(id)) return; - if (~this.dests.indexOf(id)) { + if (this.outputFiles.some(file => file === id)) { throw new Error('Cannot import the generated bundle'); } diff --git a/test/cli/index.js b/test/cli/index.js index 2bffdc5e1b0..57d984ec5bf 100644 --- a/test/cli/index.js +++ b/test/cli/index.js @@ -20,119 +20,117 @@ describe('cli', () => { sander.readdirSync(samples).sort().forEach(dir => { if (dir[0] === '.') return; // .DS_Store... - describe(dir, () => { - const config = loadConfig(samples + '/' + dir + '/_config.js'); + const config = loadConfig(samples + '/' + dir + '/_config.js'); + + (config.skip ? it.skip : config.solo ? it.only : it)(dir, done => { + process.chdir(config.cwd || path.resolve(samples, dir)); + + const command = + 'node ' + + path.resolve(__dirname, '../../bin') + + path.sep + + config.command; + + exec(command, {}, (err, code, stderr) => { + if (err) { + if (config.error) { + const shouldContinue = config.error(err); + if (!shouldContinue) return done(); + } else { + throw err; + } + } + + if ('stderr' in config) { + assert.equal(deindent(config.stderr), stderr.trim()); + } else if (stderr) { + console.error(stderr); + } + + let unintendedError; + + if (config.execute) { + try { + if (config.buble) { + code = buble.transform(code, { + transforms: { modules: false } + }).code; + } - (config.skip ? it.skip : config.solo ? it.only : it)(dir, done => { - process.chdir(config.cwd || path.resolve(samples, dir)); + const fn = new Function( + 'require', + 'module', + 'exports', + 'assert', + code + ); + const module = { + exports: {} + }; + fn(require, module, module.exports, assert); - const command = - 'node ' + - path.resolve(__dirname, '../../bin') + - path.sep + - config.command; + if (config.error) { + unintendedError = new Error( + 'Expected an error while executing output' + ); + } - exec(command, {}, (err, code, stderr) => { - if (err) { + if (config.exports) { + config.exports(module.exports); + } + } catch (err) { if (config.error) { - const shouldContinue = config.error(err); - if (!shouldContinue) return done(); + config.error(err); } else { - throw err; + unintendedError = err; } } - if ('stderr' in config) { - assert.equal(deindent(config.stderr), stderr.trim()); - } else if (stderr) { - console.error(stderr); + if (config.show || unintendedError) { + console.log(code + '\n\n\n'); } - let unintendedError; + if (config.solo) console.groupEnd(); - if (config.execute) { + unintendedError ? done(unintendedError) : done(); + } else if (config.result) { + try { + config.result(code); + done(); + } catch (err) { + done(err); + } + } else if ( + sander.existsSync('_expected') && + sander.statSync('_expected').isDirectory() + ) { + let error = null; + sander.readdirSync('_expected').forEach(child => { + const expected = sander + .readFileSync(path.join('_expected', child)) + .toString(); + const actual = sander + .readFileSync(path.join('_actual', child)) + .toString(); try { - if (config.buble) { - code = buble.transform(code, { - transforms: { modules: false } - }).code; - } - - const fn = new Function( - 'require', - 'module', - 'exports', - 'assert', - code + assert.equal( + normaliseOutput(actual), + normaliseOutput(expected) ); - const module = { - exports: {} - }; - fn(require, module, module.exports, assert); - - if (config.error) { - unintendedError = new Error( - 'Expected an error while executing output' - ); - } - - if (config.exports) { - config.exports(module.exports); - } - } catch (err) { - if (config.error) { - config.error(err); - } else { - unintendedError = err; - } - } - - if (config.show || unintendedError) { - console.log(code + '\n\n\n'); - } - - if (config.solo) console.groupEnd(); - - unintendedError ? done(unintendedError) : done(); - } else if (config.result) { - try { - config.result(code); - done(); - } catch (err) { - done(err); - } - } else if ( - sander.existsSync('_expected') && - sander.statSync('_expected').isDirectory() - ) { - let error = null; - sander.readdirSync('_expected').forEach(child => { - const expected = sander - .readFileSync(path.join('_expected', child)) - .toString(); - const actual = sander - .readFileSync(path.join('_actual', child)) - .toString(); - try { - assert.equal( - normaliseOutput(actual), - normaliseOutput(expected) - ); - } catch (err) { - error = err; - } - }); - done(error); - } else { - const expected = sander.readFileSync('_expected.js').toString(); - try { - assert.equal(normaliseOutput(code), normaliseOutput(expected)); - done(); } catch (err) { - done(err); + error = err; } + }); + done(error); + } else { + const expected = sander.readFileSync('_expected.js').toString(); + try { + assert.equal(normaliseOutput(code), normaliseOutput(expected)); + done(); + } catch (err) { + done(err); } - }); + } }); }); }); diff --git a/test/cli/node_modules/foo/lib/config.js b/test/cli/node_modules/foo/lib/config.js index 3cc995e2f4a..7bed2f9d70a 100644 --- a/test/cli/node_modules/foo/lib/config.js +++ b/test/cli/node_modules/foo/lib/config.js @@ -1,7 +1,7 @@ var replace = require( 'rollup-plugin-replace' ); module.exports = { - entry: 'main.js', + input: 'main.js', format: 'cjs', plugins: [ replace({ 'ANSWER': 42 }) diff --git a/test/cli/node_modules/rollup-config-foo/lib/config.js b/test/cli/node_modules/rollup-config-foo/lib/config.js index 3cc995e2f4a..7bed2f9d70a 100644 --- a/test/cli/node_modules/rollup-config-foo/lib/config.js +++ b/test/cli/node_modules/rollup-config-foo/lib/config.js @@ -1,7 +1,7 @@ var replace = require( 'rollup-plugin-replace' ); module.exports = { - entry: 'main.js', + input: 'main.js', format: 'cjs', plugins: [ replace({ 'ANSWER': 42 }) diff --git a/test/cli/node_modules_rename_me/foo/lib/config.js b/test/cli/node_modules_rename_me/foo/lib/config.js index 3cc995e2f4a..7bed2f9d70a 100644 --- a/test/cli/node_modules_rename_me/foo/lib/config.js +++ b/test/cli/node_modules_rename_me/foo/lib/config.js @@ -1,7 +1,7 @@ var replace = require( 'rollup-plugin-replace' ); module.exports = { - entry: 'main.js', + input: 'main.js', format: 'cjs', plugins: [ replace({ 'ANSWER': 42 }) diff --git a/test/cli/node_modules_rename_me/rollup-config-foo/lib/config.js b/test/cli/node_modules_rename_me/rollup-config-foo/lib/config.js index 3cc995e2f4a..7bed2f9d70a 100644 --- a/test/cli/node_modules_rename_me/rollup-config-foo/lib/config.js +++ b/test/cli/node_modules_rename_me/rollup-config-foo/lib/config.js @@ -1,7 +1,7 @@ var replace = require( 'rollup-plugin-replace' ); module.exports = { - entry: 'main.js', + input: 'main.js', format: 'cjs', plugins: [ replace({ 'ANSWER': 42 }) diff --git a/test/cli/samples/amd/_actual.js b/test/cli/samples/amd/_actual.js new file mode 100644 index 00000000000..f809d651fe1 --- /dev/null +++ b/test/cli/samples/amd/_actual.js @@ -0,0 +1,7 @@ +define(function () { 'use strict'; + +var main = 42; + +return main; + +}); diff --git a/test/cli/samples/amd/_config.js b/test/cli/samples/amd/_config.js new file mode 100644 index 00000000000..3a6ddb0ff66 --- /dev/null +++ b/test/cli/samples/amd/_config.js @@ -0,0 +1,4 @@ +module.exports = { + description: 'sets AMD module ID and define function', + command: 'rollup -i main.js -f amd --amd.id foo --amd.define defn' +}; diff --git a/test/cli/samples/amd/_expected.js b/test/cli/samples/amd/_expected.js new file mode 100644 index 00000000000..0c50a1adfe3 --- /dev/null +++ b/test/cli/samples/amd/_expected.js @@ -0,0 +1,7 @@ +defn('foo', function () { 'use strict'; + +var main = 42; + +return main; + +}); diff --git a/test/cli/samples/amd/main.js b/test/cli/samples/amd/main.js new file mode 100644 index 00000000000..a4012bff06c --- /dev/null +++ b/test/cli/samples/amd/main.js @@ -0,0 +1 @@ +export default 42; \ No newline at end of file diff --git a/test/cli/samples/config-cwd-case-insensitive/rollup.config.js b/test/cli/samples/config-cwd-case-insensitive/rollup.config.js index 3cc995e2f4a..7bed2f9d70a 100644 --- a/test/cli/samples/config-cwd-case-insensitive/rollup.config.js +++ b/test/cli/samples/config-cwd-case-insensitive/rollup.config.js @@ -1,7 +1,7 @@ var replace = require( 'rollup-plugin-replace' ); module.exports = { - entry: 'main.js', + input: 'main.js', format: 'cjs', plugins: [ replace({ 'ANSWER': 42 }) diff --git a/test/cli/samples/config-env/rollup.config.js b/test/cli/samples/config-env/rollup.config.js index 7d4fb0be24c..cc5988b00fb 100644 --- a/test/cli/samples/config-env/rollup.config.js +++ b/test/cli/samples/config-env/rollup.config.js @@ -1,7 +1,7 @@ var replace = require( 'rollup-plugin-replace' ); module.exports = { - entry: 'main.js', + input: 'main.js', format: 'cjs', plugins: [ replace({ diff --git a/test/cli/samples/config-es6/rollup.config.js b/test/cli/samples/config-es6/rollup.config.js index 0cafd0c672c..466e6c3c2dc 100644 --- a/test/cli/samples/config-es6/rollup.config.js +++ b/test/cli/samples/config-es6/rollup.config.js @@ -1,7 +1,7 @@ import replace from 'rollup-plugin-replace'; export default { - entry: 'main.js', + input: 'main.js', format: 'cjs', plugins: [ replace({ 'ANSWER': 42 }) diff --git a/test/cli/samples/config-external-function/rollup.config.js b/test/cli/samples/config-external-function/rollup.config.js index 10362207963..2c456bc095b 100644 --- a/test/cli/samples/config-external-function/rollup.config.js +++ b/test/cli/samples/config-external-function/rollup.config.js @@ -4,7 +4,7 @@ import { resolve } from 'path'; var config = resolve( './_config.js' ); export default { - entry: 'main.js', + input: 'main.js', format: 'cjs', external: function ( id ) { diff --git a/test/cli/samples/config-external/rollup.config.js b/test/cli/samples/config-external/rollup.config.js index 56559d2c93b..0df0322d3b1 100644 --- a/test/cli/samples/config-external/rollup.config.js +++ b/test/cli/samples/config-external/rollup.config.js @@ -4,7 +4,7 @@ import { resolve } from 'path'; var config = resolve( './_config.js' ); export default { - entry: 'main.js', + input: 'main.js', format: 'cjs', external: [ 'assert', config ], diff --git a/test/cli/samples/config-json/rollup.config.js b/test/cli/samples/config-json/rollup.config.js index 5e6b2f5d94d..eb0b1aaf246 100644 --- a/test/cli/samples/config-json/rollup.config.js +++ b/test/cli/samples/config-json/rollup.config.js @@ -2,7 +2,7 @@ import replace from 'rollup-plugin-replace'; import pkg from './package.json'; module.exports = { - entry: 'main.js', + input: 'main.js', format: 'cjs', plugins: [ replace({ '__VERSION__': pkg.version }) diff --git a/test/cli/samples/config-override/rollup.config.js b/test/cli/samples/config-override/rollup.config.js index 02743459241..eb191b30bf9 100644 --- a/test/cli/samples/config-override/rollup.config.js +++ b/test/cli/samples/config-override/rollup.config.js @@ -1,7 +1,7 @@ import replace from 'rollup-plugin-replace'; export default { - entry: 'nope.js', + input: 'nope.js', format: 'amd', plugins: [ replace({ 'ANSWER': 42 }) diff --git a/test/cli/samples/config-plugin-entry/rollup.config.js b/test/cli/samples/config-plugin-entry/rollup.config.js index ef5e381b6f3..603ce962d2b 100644 --- a/test/cli/samples/config-plugin-entry/rollup.config.js +++ b/test/cli/samples/config-plugin-entry/rollup.config.js @@ -3,7 +3,7 @@ export default { plugins: [ { options: opts => { - opts.entry = 'main.js'; + opts.input = 'main.js'; } } ] diff --git a/test/cli/samples/config-true/rollup.config.js b/test/cli/samples/config-true/rollup.config.js index 0cafd0c672c..466e6c3c2dc 100644 --- a/test/cli/samples/config-true/rollup.config.js +++ b/test/cli/samples/config-true/rollup.config.js @@ -1,7 +1,7 @@ import replace from 'rollup-plugin-replace'; export default { - entry: 'main.js', + input: 'main.js', format: 'cjs', plugins: [ replace({ 'ANSWER': 42 }) diff --git a/test/cli/samples/config/rollup.config.js b/test/cli/samples/config/rollup.config.js index 3cc995e2f4a..7bed2f9d70a 100644 --- a/test/cli/samples/config/rollup.config.js +++ b/test/cli/samples/config/rollup.config.js @@ -1,7 +1,7 @@ var replace = require( 'rollup-plugin-replace' ); module.exports = { - entry: 'main.js', + input: 'main.js', format: 'cjs', plugins: [ replace({ 'ANSWER': 42 }) diff --git a/test/cli/samples/module-name/_config.js b/test/cli/samples/module-name/_config.js index ca5d167ab90..8b5f7e892ff 100644 --- a/test/cli/samples/module-name/_config.js +++ b/test/cli/samples/module-name/_config.js @@ -1,4 +1,4 @@ module.exports = { - description: 'generates UMD export with correct moduleName', + description: 'generates UMD export with correct name', command: 'rollup main.js --format umd --name myBundle --indent' }; diff --git a/test/cli/samples/multiple-configs/rollup.config.js b/test/cli/samples/multiple-configs/rollup.config.js index fc54e0bdf34..e8d54e4bf8b 100644 --- a/test/cli/samples/multiple-configs/rollup.config.js +++ b/test/cli/samples/multiple-configs/rollup.config.js @@ -1,14 +1,18 @@ export default [{ - entry: 'main.js', - format: 'cjs', - dest: '_actual/bundle1.js' + input: 'main.js', + output: { + file: '_actual/bundle1.js', + format: 'cjs' + } }, { - entry: 'main.js', - format: 'cjs', - plugins: [{ + input: 'main.js', + plugins: [{ resolveId(id) { throw new Error("Unexpected Exception"); } }], - dest: '_actual/bundle2.js' + output: { + file: '_actual/bundle2.js', + format: 'cjs' + } }]; diff --git a/test/cli/samples/multiple-targets-shared-config/rollup.config.js b/test/cli/samples/multiple-targets-shared-config/rollup.config.js index 1a2d8a19698..02de835fcd8 100644 --- a/test/cli/samples/multiple-targets-shared-config/rollup.config.js +++ b/test/cli/samples/multiple-targets-shared-config/rollup.config.js @@ -1,14 +1,14 @@ export default { - entry: 'main.js', - sourceMap: true, + input: 'main.js', + sourcemap: true, targets: [ { format: 'cjs', - dest: '_actual/cjs.js' + file: '_actual/cjs.js' }, { format: 'es', - dest: '_actual/es.js' + file: '_actual/es.js' } ] }; diff --git a/test/cli/samples/multiple-targets/rollup.config.js b/test/cli/samples/multiple-targets/rollup.config.js index f12e0c778a8..c0093114ddb 100644 --- a/test/cli/samples/multiple-targets/rollup.config.js +++ b/test/cli/samples/multiple-targets/rollup.config.js @@ -1,13 +1,13 @@ export default { - entry: 'main.js', - targets: [ + input: 'main.js', + output: [ { format: 'cjs', - dest: '_actual/cjs.js' + file: '_actual/cjs.js' }, { format: 'es', - dest: '_actual/es.js' + file: '_actual/es.js' } ] }; diff --git a/test/cli/samples/no-conflict/rollup.config.js b/test/cli/samples/no-conflict/rollup.config.js index a1b8d7d86f0..4b66e9a627f 100644 --- a/test/cli/samples/no-conflict/rollup.config.js +++ b/test/cli/samples/no-conflict/rollup.config.js @@ -1,6 +1,6 @@ module.exports = { - entry: 'main.js', + input: 'main.js', format: 'umd', - moduleName: 'conflictyName', + name: 'conflictyName', noConflict: true }; diff --git a/test/form/index.js b/test/form/index.js index 24c5d8aa6a8..0e21fbdd049 100644 --- a/test/form/index.js +++ b/test/form/index.js @@ -25,7 +25,7 @@ describe('form', () => { const options = extend( {}, { - entry: samples + '/' + dir + '/main.js', + input: samples + '/' + dir + '/main.js', onwarn: msg => { if (/No name was provided for/.test(msg)) return; if (/as external dependency/.test(msg)) return; @@ -45,7 +45,7 @@ describe('form', () => { return createBundle().then(bundle => { const options = extend({}, config.options, { - dest: samples + '/' + dir + '/_actual/' + format + '.js', + file: samples + '/' + dir + '/_actual/' + format + '.js', format }); diff --git a/test/form/samples/assignment-to-exports-class-declaration/_config.js b/test/form/samples/assignment-to-exports-class-declaration/_config.js index f7296e0ff7d..b4707eb1c74 100644 --- a/test/form/samples/assignment-to-exports-class-declaration/_config.js +++ b/test/form/samples/assignment-to-exports-class-declaration/_config.js @@ -1,6 +1,6 @@ module.exports = { description: 'does not rewrite class expression IDs', options: { - moduleName: 'myModule' + name: 'myModule' } }; diff --git a/test/form/samples/assignment-to-exports/_config.js b/test/form/samples/assignment-to-exports/_config.js index 3c9f6d4effe..5a533052629 100644 --- a/test/form/samples/assignment-to-exports/_config.js +++ b/test/form/samples/assignment-to-exports/_config.js @@ -1,6 +1,6 @@ module.exports = { description: 'declares updated variable in ES output (#755)', options: { - moduleName: 'bundle' + name: 'bundle' } }; diff --git a/test/form/samples/computed-properties/_config.js b/test/form/samples/computed-properties/_config.js index 34cbc269f02..bb1833bea1e 100644 --- a/test/form/samples/computed-properties/_config.js +++ b/test/form/samples/computed-properties/_config.js @@ -1,6 +1,6 @@ module.exports = { description: 'computed property keys include declarations of referenced identifiers', options: { - moduleName: 'computedProperties' + name: 'computedProperties' } }; diff --git a/test/form/samples/dedupes-external-imports/_config.js b/test/form/samples/dedupes-external-imports/_config.js index 90dbdeccb16..6a4cc520d11 100644 --- a/test/form/samples/dedupes-external-imports/_config.js +++ b/test/form/samples/dedupes-external-imports/_config.js @@ -2,6 +2,6 @@ module.exports = { description: 'dedupes external imports', options: { external: [ 'external' ], - moduleName: 'myBundle' + name: 'myBundle' } }; diff --git a/test/form/samples/export-all-from-internal/_config.js b/test/form/samples/export-all-from-internal/_config.js index 83871cab7e4..59879d2bb63 100644 --- a/test/form/samples/export-all-from-internal/_config.js +++ b/test/form/samples/export-all-from-internal/_config.js @@ -1,6 +1,6 @@ module.exports = { description: 'should be able to export * from the bundle', options: { - moduleName: 'exposedInternals' + name: 'exposedInternals' } }; diff --git a/test/form/samples/export-all-multiple/_config.js b/test/form/samples/export-all-multiple/_config.js index 4199bebcd14..f87f9a91527 100644 --- a/test/form/samples/export-all-multiple/_config.js +++ b/test/form/samples/export-all-multiple/_config.js @@ -3,6 +3,6 @@ module.exports = { options: { external: [ 'foo', 'bar', 'baz' ], globals: { foo: 'foo', bar: 'bar', baz: 'baz' }, - moduleName: 'myBundle' + name: 'myBundle' } }; diff --git a/test/form/samples/export-default-2/_config.js b/test/form/samples/export-default-2/_config.js index 1b3ab50a63e..600eaaf6c1c 100644 --- a/test/form/samples/export-default-2/_config.js +++ b/test/form/samples/export-default-2/_config.js @@ -1,6 +1,6 @@ module.exports = { description: 're-exporting a default export', options: { - moduleName: 'myBundle' + name: 'myBundle' } }; diff --git a/test/form/samples/export-default-3/_config.js b/test/form/samples/export-default-3/_config.js index 1b3ab50a63e..600eaaf6c1c 100644 --- a/test/form/samples/export-default-3/_config.js +++ b/test/form/samples/export-default-3/_config.js @@ -1,6 +1,6 @@ module.exports = { description: 're-exporting a default export', options: { - moduleName: 'myBundle' + name: 'myBundle' } }; diff --git a/test/form/samples/export-default-import/_config.js b/test/form/samples/export-default-import/_config.js index 860f688e832..7ecff014ee1 100644 --- a/test/form/samples/export-default-import/_config.js +++ b/test/form/samples/export-default-import/_config.js @@ -1,6 +1,6 @@ module.exports = { description: 'correctly exports a default import, even in ES mode (#513)', options: { - moduleName: 'myBundle' + name: 'myBundle' } }; diff --git a/test/form/samples/export-default/_config.js b/test/form/samples/export-default/_config.js index 99e779c9833..ffafc1adbbb 100644 --- a/test/form/samples/export-default/_config.js +++ b/test/form/samples/export-default/_config.js @@ -1,6 +1,6 @@ module.exports = { description: 'single (default) exports', options: { - moduleName: 'myBundle' + name: 'myBundle' } }; diff --git a/test/form/samples/exports-at-end-if-possible/_config.js b/test/form/samples/exports-at-end-if-possible/_config.js index 30d375ebce8..d5451acaa94 100644 --- a/test/form/samples/exports-at-end-if-possible/_config.js +++ b/test/form/samples/exports-at-end-if-possible/_config.js @@ -1,6 +1,6 @@ module.exports = { description: 'exports variables at end, if possible', options: { - moduleName: 'myBundle' + name: 'myBundle' } }; diff --git a/test/form/samples/extend-exports/_config.js b/test/form/samples/extend-exports/_config.js index 732195b3125..065653fd349 100644 --- a/test/form/samples/extend-exports/_config.js +++ b/test/form/samples/extend-exports/_config.js @@ -2,6 +2,6 @@ module.exports = { description: 'extends module correctly', options: { extend: true, - moduleName: 'foo' + name: 'foo' } }; diff --git a/test/form/samples/extend-namespaced-exports/_config.js b/test/form/samples/extend-namespaced-exports/_config.js index fbd21b3f636..19fff0d9b2a 100644 --- a/test/form/samples/extend-namespaced-exports/_config.js +++ b/test/form/samples/extend-namespaced-exports/_config.js @@ -2,6 +2,6 @@ module.exports = { description: 'extends namespaced module name', options: { extend: true, - moduleName: 'foo.bar.baz' + name: 'foo.bar.baz' } }; diff --git a/test/form/samples/external-empty-import-no-global-b/_config.js b/test/form/samples/external-empty-import-no-global-b/_config.js index ef5dbea3f3b..0c64feb3b9b 100644 --- a/test/form/samples/external-empty-import-no-global-b/_config.js +++ b/test/form/samples/external-empty-import-no-global-b/_config.js @@ -2,7 +2,7 @@ module.exports = { description: 'does not expect a global to be provided for empty imports (#1217)', options: { external: [ 'babel-polyfill', 'other' ], - moduleName: 'myBundle', + name: 'myBundle', globals: { other: 'other' }, onwarn ( warning ) { throw new Error( warning.message ); diff --git a/test/form/samples/external-empty-import-no-global/_config.js b/test/form/samples/external-empty-import-no-global/_config.js index ad4e22333bf..df4a7064cba 100644 --- a/test/form/samples/external-empty-import-no-global/_config.js +++ b/test/form/samples/external-empty-import-no-global/_config.js @@ -2,7 +2,7 @@ module.exports = { description: 'does not expect a global to be provided for empty imports (#1217)', options: { external: [ 'babel-polyfill' ], - moduleName: 'myBundle', + name: 'myBundle', onwarn ( warning ) { throw new Error( warning.message ); } diff --git a/test/form/samples/import-named-exported-global-with-alias/_config.js b/test/form/samples/import-named-exported-global-with-alias/_config.js index 85b39fe8bf4..399d38fcbbb 100644 --- a/test/form/samples/import-named-exported-global-with-alias/_config.js +++ b/test/form/samples/import-named-exported-global-with-alias/_config.js @@ -1,6 +1,6 @@ module.exports = { description: 'allow globals to be exported and imported', options: { - moduleName: 'doc' + name: 'doc' } }; diff --git a/test/form/samples/indent-false/_config.js b/test/form/samples/indent-false/_config.js index 8db8ffdfaf9..6a1f52905fc 100644 --- a/test/form/samples/indent-false/_config.js +++ b/test/form/samples/indent-false/_config.js @@ -1,7 +1,7 @@ module.exports = { description: 'does not indent with indent: false', options: { - moduleName: 'foo', + name: 'foo', indent: false } }; diff --git a/test/form/samples/indent-spaces/_config.js b/test/form/samples/indent-spaces/_config.js index d68496778f7..af2b80c89d2 100644 --- a/test/form/samples/indent-spaces/_config.js +++ b/test/form/samples/indent-spaces/_config.js @@ -1,7 +1,7 @@ module.exports = { description: 'auto-indents with indent: true', options: { - moduleName: 'foo', + name: 'foo', indent: ' ' } }; diff --git a/test/form/samples/indent-true-spaces/_config.js b/test/form/samples/indent-true-spaces/_config.js index 4777113afae..fe7d606aeed 100644 --- a/test/form/samples/indent-true-spaces/_config.js +++ b/test/form/samples/indent-true-spaces/_config.js @@ -1,7 +1,7 @@ module.exports = { description: 'auto-indents with spaces and indent: true', options: { - moduleName: 'foo', + name: 'foo', indent: true } }; diff --git a/test/form/samples/indent-true/_config.js b/test/form/samples/indent-true/_config.js index ce460540b66..ad00d16b7d0 100644 --- a/test/form/samples/indent-true/_config.js +++ b/test/form/samples/indent-true/_config.js @@ -1,7 +1,7 @@ module.exports = { description: 'auto-indents with indent: true', options: { - moduleName: 'foo', + name: 'foo', indent: true } }; diff --git a/test/form/samples/interop-false/_config.js b/test/form/samples/interop-false/_config.js index 0076e3ab092..878a35b0bd1 100644 --- a/test/form/samples/interop-false/_config.js +++ b/test/form/samples/interop-false/_config.js @@ -1,7 +1,7 @@ module.exports = { description: 'getInterop with interop: false', options: { - moduleName: 'foo', + name: 'foo', interop: false } }; diff --git a/test/form/samples/intro-and-outro/_config.js b/test/form/samples/intro-and-outro/_config.js index 232b008c408..2712a9bc78b 100644 --- a/test/form/samples/intro-and-outro/_config.js +++ b/test/form/samples/intro-and-outro/_config.js @@ -3,7 +3,7 @@ module.exports = { options: { intro: '/* this is an intro */', outro: '/* this is an outro */', - moduleName: 'foo', + name: 'foo', external: [ 'external' ], plugins: [ { diff --git a/test/form/samples/legacy-getter/_config.js b/test/form/samples/legacy-getter/_config.js index 591c08e1954..2fa14ff03f5 100644 --- a/test/form/samples/legacy-getter/_config.js +++ b/test/form/samples/legacy-getter/_config.js @@ -2,6 +2,6 @@ module.exports = { description: 'Does not output getters when in legacy', options: { legacy: true, - moduleName: 'foo' + name: 'foo' } }; diff --git a/test/form/samples/legacy-reified-namespace/_config.js b/test/form/samples/legacy-reified-namespace/_config.js index 1905df38821..d5b754cd382 100644 --- a/test/form/samples/legacy-reified-namespace/_config.js +++ b/test/form/samples/legacy-reified-namespace/_config.js @@ -1,7 +1,7 @@ module.exports = { description: 'quotes reserved words in object literals', options: { - moduleName: 'myBundle', + name: 'myBundle', legacy: true } }; diff --git a/test/form/samples/legacy/_config.js b/test/form/samples/legacy/_config.js index a461d8eb303..057b7fe6c9f 100644 --- a/test/form/samples/legacy/_config.js +++ b/test/form/samples/legacy/_config.js @@ -1,7 +1,7 @@ module.exports = { description: 'supports environments without Object.freeze, Object.defined', options: { - moduleName: 'myBundle', + name: 'myBundle', legacy: true } }; diff --git a/test/form/samples/module-name-scoped-package/_config.js b/test/form/samples/module-name-scoped-package/_config.js index 5d2d240e9d7..1cd1121e89e 100644 --- a/test/form/samples/module-name-scoped-package/_config.js +++ b/test/form/samples/module-name-scoped-package/_config.js @@ -2,6 +2,6 @@ module.exports = { description: 'allows module name with dashes to be added to the global object', options: { extend: true, - moduleName: '@scoped/npm-package' + name: '@scoped/npm-package' } }; diff --git a/test/form/samples/module-name-wat/_config.js b/test/form/samples/module-name-wat/_config.js index 31fe8d44d0b..b09f71bc841 100644 --- a/test/form/samples/module-name-wat/_config.js +++ b/test/form/samples/module-name-wat/_config.js @@ -1,6 +1,6 @@ module.exports = { description: 'properly dereferences properties on the global object regardless of nesting', options: { - moduleName: 'foo.@scoped/npm-package.bar.why-would-you-do-this' + name: 'foo.@scoped/npm-package.bar.why-would-you-do-this' } }; diff --git a/test/form/samples/module-name-with-dashes/_config.js b/test/form/samples/module-name-with-dashes/_config.js index 5a5ec8669fa..51aa5decc4c 100644 --- a/test/form/samples/module-name-with-dashes/_config.js +++ b/test/form/samples/module-name-with-dashes/_config.js @@ -2,6 +2,6 @@ module.exports = { description: 'allows module name with dashes to be added to the global object', options: { extend: true, - moduleName: 'module-name-with-dashes' + name: 'module-name-with-dashes' } }; diff --git a/test/form/samples/multiple-exports/_config.js b/test/form/samples/multiple-exports/_config.js index 10d43edf918..e0ff0b7bcbf 100644 --- a/test/form/samples/multiple-exports/_config.js +++ b/test/form/samples/multiple-exports/_config.js @@ -1,6 +1,6 @@ module.exports = { description: 'multiple named exports', options: { - moduleName: 'myBundle' + name: 'myBundle' } }; diff --git a/test/form/samples/namespaced-default-exports/_config.js b/test/form/samples/namespaced-default-exports/_config.js index e45824d07b3..c1b0dd8631c 100644 --- a/test/form/samples/namespaced-default-exports/_config.js +++ b/test/form/samples/namespaced-default-exports/_config.js @@ -1,6 +1,6 @@ module.exports = { description: 'creates namespaced module names', options: { - moduleName: 'foo.bar.baz' + name: 'foo.bar.baz' } }; diff --git a/test/form/samples/namespaced-named-exports/_config.js b/test/form/samples/namespaced-named-exports/_config.js index e45824d07b3..c1b0dd8631c 100644 --- a/test/form/samples/namespaced-named-exports/_config.js +++ b/test/form/samples/namespaced-named-exports/_config.js @@ -1,6 +1,6 @@ module.exports = { description: 'creates namespaced module names', options: { - moduleName: 'foo.bar.baz' + name: 'foo.bar.baz' } }; diff --git a/test/form/samples/no-treeshake-conflict/_config.js b/test/form/samples/no-treeshake-conflict/_config.js index 12dc26711b4..a20d17004cc 100644 --- a/test/form/samples/no-treeshake-conflict/_config.js +++ b/test/form/samples/no-treeshake-conflict/_config.js @@ -1,7 +1,7 @@ module.exports = { description: 'does not introduce conflicting variables with treeshake: false', options: { - moduleName: /* not shaken, but */ 'stirred', + name: /* not shaken, but */ 'stirred', treeshake: false } }; diff --git a/test/form/samples/no-treeshake/_config.js b/test/form/samples/no-treeshake/_config.js index a99735836a6..90c52fab2a9 100644 --- a/test/form/samples/no-treeshake/_config.js +++ b/test/form/samples/no-treeshake/_config.js @@ -5,7 +5,7 @@ module.exports = { globals: { external: 'external' }, - moduleName: /* not shaken, but */ 'stirred', + name: /* not shaken, but */ 'stirred', treeshake: false } }; diff --git a/test/form/samples/prefer-const/_config.js b/test/form/samples/prefer-const/_config.js index ebb48286776..b663e9c55c2 100644 --- a/test/form/samples/prefer-const/_config.js +++ b/test/form/samples/prefer-const/_config.js @@ -2,6 +2,6 @@ module.exports = { description: 'uses const instead of var if specified (#653)', options: { preferConst: true, - moduleName: 'myBundle' + name: 'myBundle' } }; diff --git a/test/form/samples/preserves-comments-after-imports/_config.js b/test/form/samples/preserves-comments-after-imports/_config.js index 0911205f335..526f40d347c 100644 --- a/test/form/samples/preserves-comments-after-imports/_config.js +++ b/test/form/samples/preserves-comments-after-imports/_config.js @@ -1,7 +1,7 @@ module.exports = { description: 'preserves comments between imports and first statement', options: { - moduleName: 'myBundle' + name: 'myBundle' } }; diff --git a/test/form/samples/reexports-from-external/_config.js b/test/form/samples/reexports-from-external/_config.js index 58c5eff8b74..2a209d25e25 100644 --- a/test/form/samples/reexports-from-external/_config.js +++ b/test/form/samples/reexports-from-external/_config.js @@ -4,6 +4,6 @@ module.exports = { description: 're-exports * from external module (#791)', options: { external: [ 'external' ], - moduleName: 'myBundle' + name: 'myBundle' } }; diff --git a/test/form/samples/reexports-name-from-external/_config.js b/test/form/samples/reexports-name-from-external/_config.js index fd6b8f083d2..1005a3ea743 100644 --- a/test/form/samples/reexports-name-from-external/_config.js +++ b/test/form/samples/reexports-name-from-external/_config.js @@ -4,6 +4,6 @@ module.exports = { description: 're-exports name from external module', options: { external: [ 'external' ], - moduleName: 'myBundle' + name: 'myBundle' } }; diff --git a/test/form/samples/side-effect-b/_config.js b/test/form/samples/side-effect-b/_config.js index 9b0c85214ae..fb6d99b7213 100644 --- a/test/form/samples/side-effect-b/_config.js +++ b/test/form/samples/side-effect-b/_config.js @@ -1,6 +1,6 @@ module.exports = { description: 'discards IIFE with no side-effects', options: { - moduleName: 'myBundle' + name: 'myBundle' } }; diff --git a/test/form/samples/side-effect-c/_config.js b/test/form/samples/side-effect-c/_config.js index 0d692d499f7..d0665e5bc28 100644 --- a/test/form/samples/side-effect-c/_config.js +++ b/test/form/samples/side-effect-c/_config.js @@ -1,6 +1,6 @@ module.exports = { description: 'discards function with no side-effects', options: { - moduleName: 'myBundle' + name: 'myBundle' } }; diff --git a/test/form/samples/side-effect-d/_config.js b/test/form/samples/side-effect-d/_config.js index a8d5bf9e606..b5d42fdbf45 100644 --- a/test/form/samples/side-effect-d/_config.js +++ b/test/form/samples/side-effect-d/_config.js @@ -1,6 +1,6 @@ module.exports = { description: 'excludes functions that are known to be pure', options: { - moduleName: 'myBundle' + name: 'myBundle' } }; diff --git a/test/form/samples/side-effect-e/_config.js b/test/form/samples/side-effect-e/_config.js index 225bacd6418..42bf1aece1a 100644 --- a/test/form/samples/side-effect-e/_config.js +++ b/test/form/samples/side-effect-e/_config.js @@ -1,6 +1,6 @@ module.exports = { description: 'accounts for local scopes when tested function purity', options: { - moduleName: 'myBundle' + name: 'myBundle' } }; diff --git a/test/form/samples/side-effect-f/_config.js b/test/form/samples/side-effect-f/_config.js index 67f9fa4f93d..9d16a2c5603 100644 --- a/test/form/samples/side-effect-f/_config.js +++ b/test/form/samples/side-effect-f/_config.js @@ -1,6 +1,6 @@ module.exports = { description: 'disregards side-effects that are contained within a function', options: { - moduleName: 'myBundle' + name: 'myBundle' } }; diff --git a/test/form/samples/side-effect-g/_config.js b/test/form/samples/side-effect-g/_config.js index c8219956dfe..ab7756d2506 100644 --- a/test/form/samples/side-effect-g/_config.js +++ b/test/form/samples/side-effect-g/_config.js @@ -1,6 +1,6 @@ module.exports = { description: 'excludes constructors that are known to be pure', options: { - moduleName: 'myBundle' + name: 'myBundle' } }; diff --git a/test/form/samples/side-effect-h/_config.js b/test/form/samples/side-effect-h/_config.js index 538fccc5b3d..791263482b5 100644 --- a/test/form/samples/side-effect-h/_config.js +++ b/test/form/samples/side-effect-h/_config.js @@ -1,6 +1,6 @@ module.exports = { description: 'includes throw statements', options: { - moduleName: 'myBundle' + name: 'myBundle' } }; diff --git a/test/form/samples/side-effect-i/_config.js b/test/form/samples/side-effect-i/_config.js index ff58802f63e..3cd15272b76 100644 --- a/test/form/samples/side-effect-i/_config.js +++ b/test/form/samples/side-effect-i/_config.js @@ -1,6 +1,6 @@ module.exports = { description: 'includes top-level throw statements', options: { - moduleName: 'myBundle' + name: 'myBundle' } }; diff --git a/test/form/samples/side-effect-j/_config.js b/test/form/samples/side-effect-j/_config.js index 91550c07bc4..84e351172a4 100644 --- a/test/form/samples/side-effect-j/_config.js +++ b/test/form/samples/side-effect-j/_config.js @@ -1,6 +1,6 @@ module.exports = { description: 'includes late function declarations with side-effects', options: { - moduleName: 'myBundle' + name: 'myBundle' } }; diff --git a/test/form/samples/side-effect-k/_config.js b/test/form/samples/side-effect-k/_config.js index f94d35b605f..b4ea3dd1b5c 100644 --- a/test/form/samples/side-effect-k/_config.js +++ b/test/form/samples/side-effect-k/_config.js @@ -1,6 +1,6 @@ module.exports = { description: 'use of arguments is treated as a side-effect', options: { - moduleName: 'myBundle' + name: 'myBundle' } }; diff --git a/test/form/samples/side-effect-t/_config.js b/test/form/samples/side-effect-t/_config.js index 2e437d75ccc..9b825eadb26 100644 --- a/test/form/samples/side-effect-t/_config.js +++ b/test/form/samples/side-effect-t/_config.js @@ -1,6 +1,6 @@ module.exports = { description: 'throw statement is a side effect', options: { - moduleName: 'myBundle' + name: 'myBundle' } }; diff --git a/test/form/samples/side-effects-in-template-literals/_config.js b/test/form/samples/side-effects-in-template-literals/_config.js index 8be6344ee04..4fa6b8cc77e 100644 --- a/test/form/samples/side-effects-in-template-literals/_config.js +++ b/test/form/samples/side-effects-in-template-literals/_config.js @@ -1,6 +1,6 @@ module.exports = { description: 'detects side-effects in template literals and tagged template expressions', options: { - moduleName: 'myBundle' + name: 'myBundle' } }; diff --git a/test/form/samples/sourcemaps-external/_config.js b/test/form/samples/sourcemaps-external/_config.js index ef616f7656b..f7d42e060f9 100644 --- a/test/form/samples/sourcemaps-external/_config.js +++ b/test/form/samples/sourcemaps-external/_config.js @@ -2,6 +2,6 @@ module.exports = { description: 'correct sourcemaps are written (separate file)', skipIfWindows: true, options: { - sourceMap: true + sourcemap: true } }; diff --git a/test/form/samples/sourcemaps-inline/_config.js b/test/form/samples/sourcemaps-inline/_config.js index 9cf89fc1bbe..e70ef62e8b9 100644 --- a/test/form/samples/sourcemaps-inline/_config.js +++ b/test/form/samples/sourcemaps-inline/_config.js @@ -2,6 +2,6 @@ module.exports = { description: 'correct sourcemaps are written (inline)', skipIfWindows: true, options: { - sourceMap: 'inline' + sourcemap: 'inline' } }; diff --git a/test/form/samples/string-indentation-b/_config.js b/test/form/samples/string-indentation-b/_config.js index 99f2d9cacb7..ae5b18448d1 100644 --- a/test/form/samples/string-indentation-b/_config.js +++ b/test/form/samples/string-indentation-b/_config.js @@ -1,6 +1,6 @@ module.exports = { description: 'handles multiple var declarations inited to strings (#166)', options: { - moduleName: 'myBundle' + name: 'myBundle' } }; diff --git a/test/form/samples/switch-scopes/_config.js b/test/form/samples/switch-scopes/_config.js index 47676bff0d9..797235ebe75 100644 --- a/test/form/samples/switch-scopes/_config.js +++ b/test/form/samples/switch-scopes/_config.js @@ -1,6 +1,6 @@ module.exports = { description: 'correctly handles switch scopes', options: { - moduleName: 'myBundle' + name: 'myBundle' } }; diff --git a/test/form/samples/umd-noconflict-extend/_config.js b/test/form/samples/umd-noconflict-extend/_config.js index 3626a380ffb..208d11ec369 100644 --- a/test/form/samples/umd-noconflict-extend/_config.js +++ b/test/form/samples/umd-noconflict-extend/_config.js @@ -3,7 +3,7 @@ module.exports = { options: { extend: true, noConflict: true, - moduleName: 'FooBar' + name: 'FooBar' } }; diff --git a/test/form/samples/umd-noconflict-namespaced/_config.js b/test/form/samples/umd-noconflict-namespaced/_config.js index 52864e21105..dc14fea919e 100644 --- a/test/form/samples/umd-noconflict-namespaced/_config.js +++ b/test/form/samples/umd-noconflict-namespaced/_config.js @@ -2,7 +2,7 @@ module.exports = { description: 'exports noConflict method for default umd when requested', options: { noConflict: true, - moduleName: 'my.name.spaced.module' + name: 'my.name.spaced.module' } }; diff --git a/test/form/samples/umd-noconflict/_config.js b/test/form/samples/umd-noconflict/_config.js index 9429457a659..45cbddd141b 100644 --- a/test/form/samples/umd-noconflict/_config.js +++ b/test/form/samples/umd-noconflict/_config.js @@ -2,7 +2,7 @@ module.exports = { description: 'exports noConflict method for default umd when requested', options: { noConflict: true, - moduleName: 'FooBar' + name: 'FooBar' } }; diff --git a/test/function/index.js b/test/function/index.js index 9c8d5aa9565..955528906bb 100644 --- a/test/function/index.js +++ b/test/function/index.js @@ -25,7 +25,7 @@ describe('function', () => { const options = extend( { - entry: samples + '/' + dir + '/main.js', + input: samples + '/' + dir + '/main.js', onwarn: captureWarning }, config.options diff --git a/test/function/samples/check-resolve-for-entry/_config.js b/test/function/samples/check-resolve-for-entry/_config.js index cd3da5f69e3..b534eb27321 100644 --- a/test/function/samples/check-resolve-for-entry/_config.js +++ b/test/function/samples/check-resolve-for-entry/_config.js @@ -3,7 +3,7 @@ var assert = require( 'assert' ); module.exports = { description: 'checks that entry is resolved', options: { - entry: '/not/a/path/that/actually/really/exists' + input: '/not/a/path/that/actually/really/exists' }, error: { code: 'UNRESOLVED_ENTRY', diff --git a/test/function/samples/does-not-mangle-entry-point/_config.js b/test/function/samples/does-not-mangle-entry-point/_config.js index ef24d0113f7..a1b22013a20 100644 --- a/test/function/samples/does-not-mangle-entry-point/_config.js +++ b/test/function/samples/does-not-mangle-entry-point/_config.js @@ -6,9 +6,9 @@ var modules = { }; module.exports = { - description: 'does not mangle entry point', + description: 'does not mangle input', options: { - entry: 'x\\y', + input: 'x\\y', plugins: [{ resolveId: function ( importee ) { return importee; diff --git a/test/function/samples/external-alias/_config.js b/test/function/samples/external-alias/_config.js index 3232f3bf342..73a2b1c7ff5 100644 --- a/test/function/samples/external-alias/_config.js +++ b/test/function/samples/external-alias/_config.js @@ -4,7 +4,7 @@ var path = require( 'path' ); module.exports = { description: 'includes an external module included dynamically by an alias', options: { - entry: path.join( __dirname, 'first', 'main.js' ), + input: path.join( __dirname, 'first', 'main.js' ), external: [ 'lodash' ], // Define a simple alias plugin for underscore diff --git a/test/function/samples/handles-stringified-sourcemaps/_config.js b/test/function/samples/handles-stringified-sourcemaps/_config.js index d09a3ce2355..c51f0afc2b0 100644 --- a/test/function/samples/handles-stringified-sourcemaps/_config.js +++ b/test/function/samples/handles-stringified-sourcemaps/_config.js @@ -17,6 +17,6 @@ module.exports = { // ensure source maps are generated bundleOptions: { - sourceMap: true + sourcemap: true } }; diff --git a/test/function/samples/plugins-can-manipulate-options/_config.js b/test/function/samples/plugins-can-manipulate-options/_config.js index 15e95984ddd..afda74e7da0 100644 --- a/test/function/samples/plugins-can-manipulate-options/_config.js +++ b/test/function/samples/plugins-can-manipulate-options/_config.js @@ -7,7 +7,7 @@ module.exports = { plugins: [ { options: function ( options ) { - options.entry = path.resolve( __dirname, 'answer.js' ); + options.input = path.resolve( __dirname, 'answer.js' ); } } ] diff --git a/test/function/samples/relative-external-include-once-up/_config.js b/test/function/samples/relative-external-include-once-up/_config.js index 15821bad1b4..393bd3899d8 100644 --- a/test/function/samples/relative-external-include-once-up/_config.js +++ b/test/function/samples/relative-external-include-once-up/_config.js @@ -4,7 +4,7 @@ var path = require( 'path' ); module.exports = { description: 'includes a relative external module only once (from upper directory too)', options: { - entry: path.join( __dirname, 'first', 'main.js' ), + input: path.join( __dirname, 'first', 'main.js' ), external: path.join( __dirname, './foo.js' ) }, context: { diff --git a/test/hooks/index.js b/test/hooks/index.js index c6404b82145..8a2e3aac01d 100644 --- a/test/hooks/index.js +++ b/test/hooks/index.js @@ -6,13 +6,13 @@ const rollup = require('../../dist/rollup.js'); describe('hooks', () => { it('passes bundle & output object to ongenerate & onwrite hooks', () => { - const dest = path.join(__dirname, 'tmp/bundle.js'); + const file = path.join(__dirname, 'tmp/bundle.js'); return rollup .rollup({ - entry: 'entry', + input: 'input', plugins: [ - loader({ entry: `alert('hello')` }), + loader({ input: `alert('hello')` }), { ongenerate(bundle, out) { out.ongenerate = true; @@ -26,12 +26,12 @@ describe('hooks', () => { }) .then(bundle => { return bundle.write({ - dest, + file, format: 'es' }); }) .then(() => { - return sander.unlink(dest); + return sander.unlink(file); }); }); @@ -40,9 +40,9 @@ describe('hooks', () => { return rollup .rollup({ - entry: 'entry', + input: 'input', plugins: [ - loader({ entry: `alert('hello')` }), + loader({ input: `alert('hello')` }), { ongenerate(info) { result.push({ a: info.format }); @@ -63,41 +63,41 @@ describe('hooks', () => { it('calls onwrite hooks in sequence', () => { const result = []; - const dest = path.join(__dirname, 'tmp/bundle.js'); + const file = path.join(__dirname, 'tmp/bundle.js'); return rollup .rollup({ - entry: 'entry', + input: 'input', plugins: [ - loader({ entry: `alert('hello')` }), + loader({ input: `alert('hello')` }), { onwrite(info) { return new Promise(fulfil => { - result.push({ a: info.dest, format: info.format }); + result.push({ a: info.file, format: info.format }); fulfil(); }); } }, { onwrite(info) { - result.push({ b: info.dest, format: info.format }); + result.push({ b: info.file, format: info.format }); } } ] }) .then(bundle => { return bundle.write({ - dest, + file, format: 'cjs' }); }) .then(() => { assert.deepEqual(result, [ - { a: dest, format: 'cjs' }, - { b: dest, format: 'cjs' } + { a: file, format: 'cjs' }, + { b: file, format: 'cjs' } ]); - return sander.unlink(dest); + return sander.unlink(file); }); }); }); diff --git a/test/incremental/index.js b/test/incremental/index.js index 95fd9f791e9..c35d1bbfbe4 100644 --- a/test/incremental/index.js +++ b/test/incremental/index.js @@ -1,23 +1,9 @@ const assert = require('assert'); const acorn = require('acorn'); +const { executeBundle } = require('../utils.js'); const rollup = require('../../dist/rollup'); describe('incremental', () => { - function executeBundle(bundle) { - return bundle - .generate({ - format: 'cjs' - }) - .then(cjs => { - const m = new Function('module', 'exports', cjs.code); - - const module = { exports: {} }; - m(module, module.exports); - - return module.exports; - }); - } - let resolveIdCalls; let transformCalls; let modules; @@ -52,14 +38,14 @@ describe('incremental', () => { it('does not resolves id and transforms in the second time', () => { return rollup .rollup({ - entry: 'entry', + input: 'entry', plugins: [plugin] }) .then(bundle => { assert.equal(resolveIdCalls, 2); assert.equal(transformCalls, 2); return rollup.rollup({ - entry: 'entry', + input: 'entry', plugins: [plugin], cache: bundle }); @@ -80,7 +66,7 @@ describe('incremental', () => { return rollup .rollup({ - entry: 'entry', + input: 'entry', plugins: [plugin] }) .then(bundle => { @@ -95,7 +81,7 @@ describe('incremental', () => { }) .then(() => { return rollup.rollup({ - entry: 'entry', + input: 'entry', plugins: [plugin], cache }); @@ -115,7 +101,7 @@ describe('incremental', () => { return rollup .rollup({ - entry: 'entry', + input: 'entry', plugins: [plugin] }) .then(bundle => { @@ -130,7 +116,7 @@ describe('incremental', () => { }) .then(() => { return rollup.rollup({ - entry: 'entry', + input: 'entry', plugins: [plugin], cache }); @@ -148,7 +134,7 @@ describe('incremental', () => { it('keeps ASTs between runs', () => { return rollup .rollup({ - entry: 'entry', + input: 'entry', plugins: [plugin] }) .then(bundle => { @@ -173,7 +159,7 @@ describe('incremental', () => { return rollup .rollup({ - entry: 'entry', + input: 'entry', plugins: [plugin] }) .then(cache => { @@ -181,7 +167,7 @@ describe('incremental', () => { return rollup .rollup({ - entry: 'entry', + input: 'entry', plugins: [plugin], cache }) @@ -194,7 +180,7 @@ describe('incremental', () => { return rollup .rollup({ - entry: 'entry', + input: 'entry', plugins: [plugin], cache }) @@ -215,7 +201,7 @@ describe('incremental', () => { return rollup .rollup({ - entry: 'entry', + input: 'entry', external: ['external'], plugins: [plugin] }) diff --git a/test/leak/index.js b/test/leak/index.js index 4a1ada13db8..7d5fb89273d 100644 --- a/test/leak/index.js +++ b/test/leak/index.js @@ -14,7 +14,7 @@ function test() { var cache; function run () { return rollup.rollup({ - entry: path.resolve(__dirname, 'main.js'), + input: path.resolve(__dirname, 'main.js'), cache }).then(bundle => { weak(bundle, onCollect); @@ -42,6 +42,7 @@ try { require.resolve('weak'); test(); } catch (err) { + console.error(err); console.log('installing weak'); require('child_process').exec('npm i --no-save --silent weak@1.0.1', (err, stdout, stderr) => { if (err) { diff --git a/test/misc/index.js b/test/misc/index.js index 1eaab5c143c..fd4ae96aa7f 100644 --- a/test/misc/index.js +++ b/test/misc/index.js @@ -1,6 +1,6 @@ const assert = require('assert'); const rollup = require('../../dist/rollup'); -const { loader } = require('../utils.js'); +const { executeBundle, loader } = require('../utils.js'); describe('sanity checks', () => { it('exists', () => { @@ -25,26 +25,26 @@ describe('sanity checks', () => { }); }); - it('fails without options.entry', () => { + it('fails without options.input', () => { return rollup .rollup({}) .then(() => { throw new Error('Missing expected error'); }) .catch(err => { - assert.equal(err.message, 'You must supply options.entry to rollup'); + assert.equal(err.message, 'You must supply options.input to rollup'); }); }); it('fails with invalid keys', () => { - return rollup.rollup({ entry: 'x', plUgins: [] }).then( + return rollup.rollup({ input: 'x', plUgins: [] }).then( () => { throw new Error('Missing expected error'); }, err => { assert.equal( err.message, - "Unexpected key 'plUgins' found, expected one of: acorn, amd, banner, cache, context, dest, entry, exports, extend, external, footer, format, globals, indent, interop, intro, legacy, moduleContext, moduleName, noConflict, onwarn, outro, paths, plugins, preferConst, pureExternalModules, sourceMap, sourceMapFile, targets, treeshake, useStrict, watch" + "Unexpected key 'plUgins' found, expected one of: acorn, amd, banner, cache, context, entry, exports, extend, external, file, footer, format, globals, indent, input, interop, intro, legacy, moduleContext, name, noConflict, onwarn, output, outro, paths, plugins, preferConst, pureExternalModules, sourcemap, sourcemapFile, strict, targets, treeshake, watch" ); } ); @@ -54,7 +54,7 @@ describe('sanity checks', () => { // this test has to be up here, otherwise the bug doesn't have // an opportunity to present itself return rollup.rollup({ - entry: 'x', + input: 'x', plugins: [loader({ x: `var a = null; a = 'a string';` })] }); }); @@ -62,7 +62,7 @@ describe('sanity checks', () => { it('includes a newline at the end of the bundle', () => { return rollup .rollup({ - entry: 'x', + input: 'x', plugins: [loader({ x: `console.log( 42 );` })] }) .then(bundle => { @@ -73,28 +73,62 @@ describe('sanity checks', () => { }); }); - it('throws on missing format option', () => { + it('throws on missing output options', () => { const warnings = []; return rollup .rollup({ - entry: 'x', + input: 'x', plugins: [loader({ x: `console.log( 42 );` })], onwarn: warning => warnings.push(warning) }) .then(bundle => { assert.throws(() => { bundle.generate(); - }, /You must supply an output format/); + }, /You must supply an options object/); + }); + }); + + it('throws on missing format option', () => { + const warnings = []; + + return rollup + .rollup({ + input: 'x', + plugins: [loader({ x: `console.log( 42 );` })], + onwarn: warning => warnings.push(warning) + }) + .then(bundle => { + assert.throws(() => { + bundle.generate({ file: 'x' }); + }, /You must specify options\.format, which can be one of 'amd', 'cjs', 'es', 'iife' or 'umd'/); }); }); }); describe('deprecations', () => { + it('warns on options.entry, but handles', () => { + const warnings = []; + return rollup.rollup({ + entry: 'x', + plugins: [loader({ x: `export default 42` })], + onwarn: warning => { + warnings.push(warning); + } + }).then(executeBundle).then(result => { + assert.equal(result, 42); + assert.deepEqual(warnings, [ + { + message: `options.entry is deprecated, use options.input` + } + ]); + }); + }); + it('throws a useful error on accessing code/map properties of bundle.generate promise', () => { return rollup .rollup({ - entry: 'x', + input: 'x', plugins: [loader({ x: `console.log( 42 );` })] }) .then(bundle => { @@ -117,10 +151,10 @@ describe('deprecations', () => { }); describe('bundle.write()', () => { - it('fails without options or options.dest', () => { + it('fails without options or options.file', () => { return rollup .rollup({ - entry: 'x', + input: 'x', plugins: [ { resolveId: () => { @@ -135,20 +169,20 @@ describe('bundle.write()', () => { .then(bundle => { assert.throws(() => { bundle.write(); - }, /must supply options\.dest/); + }, /You must specify options\.file/); assert.throws(() => { bundle.write({}); - }, /must supply options\.dest/); + }, /You must specify options\.file/); }); }); - it('expects options.moduleName for IIFE and UMD bundles', () => { + it('expects options.name for IIFE and UMD bundles', () => { let bundle; return rollup .rollup({ - entry: 'x', + input: 'x', plugins: [ { resolveId: () => { @@ -169,7 +203,7 @@ describe('bundle.write()', () => { .catch(err => { assert.throws(() => { throw err; - }, /You must supply options\.moduleName for UMD bundles/); + }, /You must supply options\.name for UMD bundles/); }) .then(() => { return bundle.generate({ @@ -179,14 +213,14 @@ describe('bundle.write()', () => { .catch(err => { assert.throws(() => { throw err; - }, /You must supply options\.moduleName for IIFE bundles/); + }, /You must supply options\.name for IIFE bundles/); }); }); it('throws on es6 format', () => { return rollup .rollup({ - entry: 'x', + input: 'x', plugins: [ { resolveId: () => { @@ -212,10 +246,10 @@ describe('misc', () => { return rollup .rollup({ - entry: 'entry', + input: 'input', plugins: [ loader({ - entry: `import { format } from 'util';\nexport default format( 'this is a %s', 'formatted string' );` + input: `import { format } from 'util';\nexport default format( 'this is a %s', 'formatted string' );` }) ], onwarn: warning => warnings.push(warning) @@ -223,7 +257,7 @@ describe('misc', () => { .then(bundle => bundle.generate({ format: 'iife', - moduleName: 'myBundle' + name: 'myBundle' }) ) .then(() => { diff --git a/test/sourcemaps/index.js b/test/sourcemaps/index.js index 36b380370fe..0212cd0ade5 100644 --- a/test/sourcemaps/index.js +++ b/test/sourcemaps/index.js @@ -14,13 +14,13 @@ describe('sourcemaps', () => { describe(dir, () => { const config = loadConfig(samples + '/' + dir + '/_config.js'); - const entry = path.resolve(samples, dir, 'main.js'); - const dest = path.resolve(samples, dir, '_actual/bundle'); + const input = path.resolve(samples, dir, 'main.js'); + const output = path.resolve(samples, dir, '_actual/bundle'); let warnings; const options = extend({}, config.options, { - entry, + input, onwarn: warning => warnings.push(warning) }); @@ -35,39 +35,41 @@ describe('sourcemaps', () => { {}, { format, - sourceMap: true, - dest: `${dest}.${format}.js` + sourcemap: true, + file: `${output}.${format}.js` }, config.options ); - bundle.write(options); - - bundle.generate(options).then(({ code, map }) => { - if (config.test) { - config.test(code, map, { format }); - } - + return bundle.write(options).then(() => { if (config.warnings) { compareWarnings(warnings, config.warnings); } else if (warnings.length) { throw new Error(`Unexpected warnings`); } + + return bundle.generate(options) + .then(({ code, map }) => { + if (config.test) { + config.test(code, map, { format }); + } + }); }); }; return rollup.rollup(options).then(bundle => { - testBundle(bundle); - // cache rebuild does not reemit warnings. - if (config.warnings) { - return; - } - // test cache noop rebuild - return rollup - .rollup(extend({ cache: bundle }, options)) - .then(bundle => { - testBundle(bundle); - }); + return testBundle(bundle).then(() => { + // cache rebuild does not reemit warnings. + if (config.warnings) { + return; + } + // test cache noop rebuild + return rollup + .rollup(extend({ cache: bundle }, options)) + .then(bundle => { + testBundle(bundle); + }); + }); }); } ); diff --git a/test/sourcemaps/samples/names/_config.js b/test/sourcemaps/samples/names/_config.js index 0c5a44ed9fa..1ecd160cb48 100644 --- a/test/sourcemaps/samples/names/_config.js +++ b/test/sourcemaps/samples/names/_config.js @@ -5,7 +5,7 @@ var SourceMapConsumer = require( 'source-map' ).SourceMapConsumer; module.exports = { description: 'names are recovered (https://github.com/rollup/rollup/issues/101)', options: { - moduleName: 'myModule' + name: 'myModule' }, test: function ( code, map ) { var smc = new SourceMapConsumer( map ); diff --git a/test/sourcemaps/samples/relative-paths/_config.js b/test/sourcemaps/samples/relative-paths/_config.js index 1d72cda225d..58b17303d1d 100644 --- a/test/sourcemaps/samples/relative-paths/_config.js +++ b/test/sourcemaps/samples/relative-paths/_config.js @@ -4,8 +4,8 @@ var assert = require( 'assert' ); module.exports = { description: 'source paths are relative with relative dest (#344)', options: { - moduleName: 'myModule', - dest: path.resolve( '_actual/bundle.js' ) + name: 'myModule', + file: path.resolve( __dirname, '_actual/bundle.js' ) }, test: function ( code, map ) { assert.deepEqual( map.sources, [ '../main.js' ]); diff --git a/test/sourcemaps/samples/single-length-segments/_config.js b/test/sourcemaps/samples/single-length-segments/_config.js index 386d834d793..6f21b9a7a85 100644 --- a/test/sourcemaps/samples/single-length-segments/_config.js +++ b/test/sourcemaps/samples/single-length-segments/_config.js @@ -19,7 +19,7 @@ module.exports = { } } ], - moduleName: 'x' + name: 'x' }, test: function ( code, map ) { var smc = new SourceMapConsumer( map ); diff --git a/test/sourcemaps/samples/transform-without-sourcemap/_config.js b/test/sourcemaps/samples/transform-without-sourcemap/_config.js index 0ce79c03247..b674f7e712f 100644 --- a/test/sourcemaps/samples/transform-without-sourcemap/_config.js +++ b/test/sourcemaps/samples/transform-without-sourcemap/_config.js @@ -13,6 +13,7 @@ module.exports = { warnings: [ { code: `SOURCEMAP_BROKEN`, + plugin: 'fake plugin', message: `Sourcemap is likely to be incorrect: a plugin ('fake plugin') was used to transform files, but didn't generate a sourcemap for the transformation. Consult the plugin documentation for help`, url: `https://github.com/rollup/rollup/wiki/Troubleshooting#sourcemap-is-likely-to-be-incorrect` } diff --git a/test/utils.js b/test/utils.js index cc6f1ce448a..fccbb73fde8 100644 --- a/test/utils.js +++ b/test/utils.js @@ -3,6 +3,7 @@ const assert = require('assert'); exports.compareError = compareError; exports.compareWarnings = compareWarnings; exports.deindent = deindent; +exports.executeBundle = executeBundle; exports.extend = extend; exports.loadConfig = loadConfig; exports.loader = loader; @@ -50,6 +51,21 @@ function deindent(str) { return str.slice(1).replace(/^\t+/gm, '').replace(/\s+$/gm, '').trim(); } +function executeBundle(bundle) { + return bundle + .generate({ + format: 'cjs' + }) + .then(cjs => { + const m = new Function('module', 'exports', cjs.code); + + const module = { exports: {} }; + m(module, module.exports); + + return module.exports; + }); +} + function extend(target) { [].slice.call(arguments, 1).forEach(source => { source && diff --git a/test/watch/index.js b/test/watch/index.js index e048d2256b9..a485bc1aafd 100644 --- a/test/watch/index.js +++ b/test/watch/index.js @@ -32,6 +32,9 @@ describe('rollup.watch', () => { } else if (typeof next === 'string') { watcher.once('event', event => { if (event.code !== next) { + if (event.code === 'FATAL') { + console.error(event.error); + } reject(new Error(`Expected ${next} event, got ${event.code}`)); } else { go(event); @@ -67,9 +70,11 @@ describe('rollup.watch', () => { .to('test/_tmp/input') .then(() => { const watcher = rollup.watch({ - entry: 'test/_tmp/input/main.js', - dest: 'test/_tmp/output/bundle.js', - format: 'cjs', + input: 'test/_tmp/input/main.js', + output: { + file: 'test/_tmp/output/bundle.js', + format: 'cjs' + }, watch: { chokidar } }); @@ -103,9 +108,11 @@ describe('rollup.watch', () => { .to('test/_tmp/input') .then(() => { const watcher = rollup.watch({ - entry: 'test/_tmp/input/main.js', - dest: 'test/_tmp/output/bundle.js', - format: 'cjs', + input: 'test/_tmp/input/main.js', + output: { + file: 'test/_tmp/output/bundle.js', + format: 'cjs' + }, watch: { chokidar } }); @@ -145,9 +152,11 @@ describe('rollup.watch', () => { .to('test/_tmp/input') .then(() => { const watcher = rollup.watch({ - entry: 'test/_tmp/input/main.js', - dest: 'test/_tmp/output/bundle.js', - format: 'cjs', + input: 'test/_tmp/input/main.js', + output: { + file: 'test/_tmp/output/bundle.js', + format: 'cjs' + }, watch: { chokidar } }); @@ -189,9 +198,11 @@ describe('rollup.watch', () => { .to('test/_tmp/input') .then(() => { const watcher = rollup.watch({ - entry: 'test/_tmp/input/main.js', - dest: 'test/_tmp/output/bundle.js', - format: 'cjs', + input: 'test/_tmp/input/main.js', + output: { + file: 'test/_tmp/output/bundle.js', + format: 'cjs' + }, watch: { chokidar } }); @@ -238,9 +249,11 @@ describe('rollup.watch', () => { .to('test/_tmp/input') .then(() => { const watcher = rollup.watch({ - entry: 'test/_tmp/input/main.js', - dest: 'test/_tmp/output/bundle.js', - format: 'cjs', + input: 'test/_tmp/input/main.js', + output: { + file: 'test/_tmp/output/bundle.js', + format: 'cjs' + }, watch: { chokidar, include: ['test/_tmp/input/+(main|foo).js'] @@ -293,9 +306,11 @@ describe('rollup.watch', () => { .to('test/_tmp/input') .then(() => { const watcher = rollup.watch({ - entry: 'test/_tmp/input/main.js', - dest: 'test/_tmp/output/bundle.js', - format: 'cjs', + input: 'test/_tmp/input/main.js', + output: { + file: 'test/_tmp/output/bundle.js', + format: 'cjs' + }, watch: { chokidar, exclude: ['test/_tmp/input/bar.js'] @@ -348,9 +363,11 @@ describe('rollup.watch', () => { .to('test/_tmp/input') .then(() => { const watcher = rollup.watch({ - entry: 'test/_tmp/input/main.js', - dest: 'test/_tmp/output/bundle.js', - format: 'iife', + input: 'test/_tmp/input/main.js', + output: { + file: 'test/_tmp/output/bundle.js', + format: 'iife' + }, watch: { chokidar }, external: ['jquery'], globals: {