mirror of https://github.com/lukechilds/rollup.git
Rich-Harris
8 years ago
102 changed files with 1344 additions and 571 deletions
@ -1,65 +0,0 @@ |
|||||
import * as chalk from 'chalk'; |
|
||||
|
|
||||
function stderr ( msg ) { |
|
||||
console.error( msg ); // eslint-disable-line no-console
|
|
||||
} |
|
||||
|
|
||||
const handlers = { |
|
||||
MISSING_CONFIG: () => { |
|
||||
stderr( chalk.red( 'Config file must export an options object. See https://github.com/rollup/rollup/wiki/Command-Line-Interface#using-a-config-file' ) ); |
|
||||
}, |
|
||||
|
|
||||
MISSING_EXTERNAL_CONFIG: err => { |
|
||||
stderr( chalk.red( `Could not resolve config file ${err.config}` ) ); |
|
||||
}, |
|
||||
|
|
||||
MISSING_INPUT_OPTION: () => { |
|
||||
stderr( chalk.red( 'You must specify an --input (-i) option' ) ); |
|
||||
}, |
|
||||
|
|
||||
MISSING_OUTPUT_OPTION: () => { |
|
||||
stderr( chalk.red( 'You must specify an --output (-o) option when creating a file with a sourcemap' ) ); |
|
||||
}, |
|
||||
|
|
||||
MISSING_NAME: () => { |
|
||||
stderr( chalk.red( 'You must supply a name for UMD exports (e.g. `--name myModule`)' ) ); |
|
||||
}, |
|
||||
|
|
||||
PARSE_ERROR: err => { |
|
||||
stderr( chalk.red( `Error parsing ${err.file}: ${err.message}` ) ); |
|
||||
}, |
|
||||
|
|
||||
ONE_AT_A_TIME: () => { |
|
||||
stderr( chalk.red( 'rollup can only bundle one file at a time' ) ); |
|
||||
}, |
|
||||
|
|
||||
DUPLICATE_IMPORT_OPTIONS: () => { |
|
||||
stderr( chalk.red( 'use --input, or pass input path as argument' ) ); |
|
||||
}, |
|
||||
|
|
||||
ROLLUP_WATCH_NOT_INSTALLED: () => { |
|
||||
stderr( chalk.red( 'rollup --watch depends on the rollup-watch package, which could not be found. You can install it globally (recommended) with ' ) + chalk.cyan( 'npm install -g rollup-watch' ) ); |
|
||||
}, |
|
||||
|
|
||||
WATCHER_MISSING_INPUT_OR_OUTPUT: () => { |
|
||||
stderr( chalk.red( 'must specify --input and --output when using rollup --watch' ) ); |
|
||||
} |
|
||||
}; |
|
||||
|
|
||||
export default function handleError ( err, recover ) { |
|
||||
const handler = handlers[ err && err.code ]; |
|
||||
|
|
||||
if ( handler ) { |
|
||||
handler( err ); |
|
||||
} else { |
|
||||
stderr( chalk.red( err.message || err ) ); |
|
||||
|
|
||||
if ( err.stack ) { |
|
||||
stderr( chalk.grey( err.stack ) ); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
stderr( `Type ${chalk.cyan( 'rollup --help' )} for help, or visit https://github.com/rollup/rollup/wiki` ); |
|
||||
|
|
||||
if ( !recover ) process.exit( 1 ); |
|
||||
} |
|
@ -0,0 +1,47 @@ |
|||||
|
import chalk from 'chalk'; |
||||
|
import relativeId from '../../src/utils/relativeId.js'; |
||||
|
|
||||
|
if ( !process.stderr.isTTY ) chalk.enabled = false; |
||||
|
const warnSymbol = process.stderr.isTTY ? `⚠️ ` : `Warning: `; |
||||
|
const errorSymbol = process.stderr.isTTY ? `🚨 ` : `Error: `; |
||||
|
|
||||
|
// log to stderr to keep `rollup main.js > bundle.js` from breaking
|
||||
|
export const stderr = console.error.bind( console ); // eslint-disable-line no-console
|
||||
|
|
||||
|
export function handleWarning ( warning ) { |
||||
|
stderr( `${warnSymbol}${chalk.bold( warning.message )}` ); |
||||
|
|
||||
|
if ( warning.url ) { |
||||
|
stderr( chalk.cyan( warning.url ) ); |
||||
|
} |
||||
|
|
||||
|
if ( warning.loc ) { |
||||
|
stderr( `${relativeId( warning.loc.file )} (${warning.loc.line}:${warning.loc.column})` ); |
||||
|
} |
||||
|
|
||||
|
if ( warning.frame ) { |
||||
|
stderr( chalk.dim( warning.frame ) ); |
||||
|
} |
||||
|
|
||||
|
stderr( '' ); |
||||
|
} |
||||
|
|
||||
|
export function handleError ( err, recover ) { |
||||
|
stderr( `${errorSymbol}${chalk.bold( err.message )}` ); |
||||
|
|
||||
|
if ( err.url ) { |
||||
|
stderr( chalk.cyan( err.url ) ); |
||||
|
} |
||||
|
|
||||
|
if ( err.loc ) { |
||||
|
stderr( `${relativeId( err.loc.file )} (${err.loc.line}:${err.loc.column})` ); |
||||
|
} |
||||
|
|
||||
|
if ( err.frame ) { |
||||
|
stderr( chalk.dim( err.frame ) ); |
||||
|
} |
||||
|
|
||||
|
stderr( '' ); |
||||
|
|
||||
|
if ( !recover ) process.exit( 1 ); |
||||
|
} |
@ -0,0 +1,17 @@ |
|||||
|
export default function clone ( node ) { |
||||
|
if ( !node ) return node; |
||||
|
if ( typeof node !== 'object' ) return node; |
||||
|
|
||||
|
if ( Array.isArray( node ) ) { |
||||
|
const cloned = new Array( node.length ); |
||||
|
for ( let i = 0; i < node.length; i += 1 ) cloned[i] = clone( node[i] ); |
||||
|
return cloned; |
||||
|
} |
||||
|
|
||||
|
const cloned = {}; |
||||
|
for ( const key in node ) { |
||||
|
cloned[ key ] = clone( node[ key ] ); |
||||
|
} |
||||
|
|
||||
|
return cloned; |
||||
|
} |
@ -0,0 +1,19 @@ |
|||||
|
import Node from '../Node.js'; |
||||
|
import { UNKNOWN } from '../values.js'; |
||||
|
|
||||
|
const operators = { |
||||
|
'&&': ( left, right ) => left && right, |
||||
|
'||': ( left, right ) => left || right |
||||
|
}; |
||||
|
|
||||
|
export default class LogicalExpression extends Node { |
||||
|
getValue () { |
||||
|
const leftValue = this.left.getValue(); |
||||
|
if ( leftValue === UNKNOWN ) return UNKNOWN; |
||||
|
|
||||
|
const rightValue = this.right.getValue(); |
||||
|
if ( rightValue === UNKNOWN ) return UNKNOWN; |
||||
|
|
||||
|
return operators[ this.operator ]( leftValue, rightValue ); |
||||
|
} |
||||
|
} |
@ -1,28 +1,21 @@ |
|||||
import getLocation from '../../../utils/getLocation.js'; |
|
||||
import error from '../../../utils/error.js'; |
|
||||
|
|
||||
// TODO tidy this up a bit (e.g. they can both use node.module.imports)
|
// TODO tidy this up a bit (e.g. they can both use node.module.imports)
|
||||
export default function disallowIllegalReassignment ( scope, node ) { |
export default function disallowIllegalReassignment ( scope, node ) { |
||||
if ( node.type === 'MemberExpression' && node.object.type === 'Identifier' ) { |
if ( node.type === 'MemberExpression' && node.object.type === 'Identifier' ) { |
||||
const declaration = scope.findDeclaration( node.object.name ); |
const declaration = scope.findDeclaration( node.object.name ); |
||||
if ( declaration.isNamespace ) { |
if ( declaration.isNamespace ) { |
||||
error({ |
node.module.error({ |
||||
message: `Illegal reassignment to import '${node.object.name}'`, |
code: 'ILLEGAL_NAMESPACE_REASSIGNMENT', |
||||
file: node.module.id, |
message: `Illegal reassignment to import '${node.object.name}'` |
||||
pos: node.start, |
}, node.start ); |
||||
loc: getLocation( node.module.code, node.start ) |
|
||||
}); |
|
||||
} |
} |
||||
} |
} |
||||
|
|
||||
else if ( node.type === 'Identifier' ) { |
else if ( node.type === 'Identifier' ) { |
||||
if ( node.module.imports[ node.name ] && !scope.contains( node.name ) ) { |
if ( node.module.imports[ node.name ] && !scope.contains( node.name ) ) { |
||||
error({ |
node.module.error({ |
||||
message: `Illegal reassignment to import '${node.name}'`, |
code: 'ILLEGAL_REASSIGNMENT', |
||||
file: node.module.id, |
message: `Illegal reassignment to import '${node.name}'` |
||||
pos: node.start, |
}, node.start ); |
||||
loc: getLocation( node.module.code, node.start ) |
|
||||
}); |
|
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
|
@ -1,11 +1,15 @@ |
|||||
export default function getGlobalNameMaker ( globals, onwarn ) { |
export default function getGlobalNameMaker ( globals, bundle ) { |
||||
const fn = typeof globals === 'function' ? globals : id => globals[ id ]; |
const fn = typeof globals === 'function' ? globals : id => globals[ id ]; |
||||
|
|
||||
return function ( module ) { |
return function ( module ) { |
||||
const name = fn( module.id ); |
const name = fn( module.id ); |
||||
if ( name ) return name; |
if ( name ) return name; |
||||
|
|
||||
onwarn( `No name was provided for external module '${module.id}' in options.globals – guessing '${module.name}'` ); |
bundle.warn({ |
||||
|
code: 'MISSING_GLOBAL_NAME', |
||||
|
message: `No name was provided for external module '${module.id}' in options.globals – guessing '${module.name}'` |
||||
|
}); |
||||
|
|
||||
return module.name; |
return module.name; |
||||
}; |
}; |
||||
} |
} |
||||
|
@ -0,0 +1,42 @@ |
|||||
|
const builtins = { |
||||
|
process: true, |
||||
|
events: true, |
||||
|
stream: true, |
||||
|
util: true, |
||||
|
path: true, |
||||
|
buffer: true, |
||||
|
querystring: true, |
||||
|
url: true, |
||||
|
string_decoder: true, |
||||
|
punycode: true, |
||||
|
http: true, |
||||
|
https: true, |
||||
|
os: true, |
||||
|
assert: true, |
||||
|
constants: true, |
||||
|
timers: true, |
||||
|
console: true, |
||||
|
vm: true, |
||||
|
zlib: true, |
||||
|
tty: true, |
||||
|
domain: true |
||||
|
}; |
||||
|
|
||||
|
// Creating a browser bundle that depends on Node.js built-in modules ('util'). You might need to include https://www.npmjs.com/package/rollup-plugin-node-builtins
|
||||
|
|
||||
|
export default function warnOnBuiltins ( bundle ) { |
||||
|
const externalBuiltins = bundle.externalModules |
||||
|
.filter( mod => mod.id in builtins ) |
||||
|
.map( mod => mod.id ); |
||||
|
|
||||
|
if ( !externalBuiltins.length ) return; |
||||
|
|
||||
|
const detail = externalBuiltins.length === 1 ? |
||||
|
`module ('${externalBuiltins[0]}')` : |
||||
|
`modules (${externalBuiltins.slice( 0, -1 ).map( name => `'${name}'` ).join( ', ' )} and '${externalBuiltins.pop()}')`; |
||||
|
|
||||
|
bundle.warn({ |
||||
|
code: 'MISSING_NODE_BUILTINS', |
||||
|
message: `Creating a browser bundle that depends on Node.js built-in ${detail}. You might need to include https://www.npmjs.com/package/rollup-plugin-node-builtins` |
||||
|
}); |
||||
|
} |
@ -0,0 +1,41 @@ |
|||||
|
function spaces ( i ) { |
||||
|
let result = ''; |
||||
|
while ( i-- ) result += ' '; |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
function tabsToSpaces ( str ) { |
||||
|
return str.replace( /^\t+/, match => match.split( '\t' ).join( ' ' ) ); |
||||
|
} |
||||
|
|
||||
|
export default function getCodeFrame ( source, line, column ) { |
||||
|
let lines = source.split( '\n' ); |
||||
|
|
||||
|
const frameStart = Math.max( 0, line - 3 ); |
||||
|
let frameEnd = Math.min( line + 2, lines.length ); |
||||
|
|
||||
|
lines = lines.slice( frameStart, frameEnd ); |
||||
|
while ( !/\S/.test( lines[ lines.length - 1 ] ) ) { |
||||
|
lines.pop(); |
||||
|
frameEnd -= 1; |
||||
|
} |
||||
|
|
||||
|
const digits = String( frameEnd ).length; |
||||
|
|
||||
|
return lines |
||||
|
.map( ( str, i ) => { |
||||
|
const isErrorLine = frameStart + i + 1 === line; |
||||
|
|
||||
|
let lineNum = String( i + frameStart + 1 ); |
||||
|
while ( lineNum.length < digits ) lineNum = ` ${lineNum}`; |
||||
|
|
||||
|
if ( isErrorLine ) { |
||||
|
const indicator = spaces( digits + 2 + tabsToSpaces( str.slice( 0, column ) ).length ) + '^'; |
||||
|
return `${lineNum}: ${tabsToSpaces( str )}\n${indicator}`; |
||||
|
} |
||||
|
|
||||
|
return `${lineNum}: ${tabsToSpaces( str )}`; |
||||
|
}) |
||||
|
.join( '\n' ); |
||||
|
} |
@ -1,20 +0,0 @@ |
|||||
export default function getLocation ( source, charIndex ) { |
|
||||
const lines = source.split( '\n' ); |
|
||||
const len = lines.length; |
|
||||
|
|
||||
let lineStart = 0; |
|
||||
let i; |
|
||||
|
|
||||
for ( i = 0; i < len; i += 1 ) { |
|
||||
const line = lines[i]; |
|
||||
const lineEnd = lineStart + line.length + 1; // +1 for newline
|
|
||||
|
|
||||
if ( lineEnd > charIndex ) { |
|
||||
return { line: i + 1, column: charIndex - lineStart }; |
|
||||
} |
|
||||
|
|
||||
lineStart = lineEnd; |
|
||||
} |
|
||||
|
|
||||
throw new Error( 'Could not determine location of character' ); |
|
||||
} |
|
@ -1,3 +1,3 @@ |
|||||
module.exports = { |
module.exports = { |
||||
description: 'skips a dead branch (h)' |
description: 'skips a dead branch (i)' |
||||
}; |
}; |
||||
|
@ -0,0 +1,3 @@ |
|||||
|
module.exports = { |
||||
|
description: 'skips a dead branch (j)' |
||||
|
}; |
@ -0,0 +1,7 @@ |
|||||
|
define(function () { 'use strict'; |
||||
|
|
||||
|
{ |
||||
|
console.log( 'true' ); |
||||
|
} |
||||
|
|
||||
|
}); |
@ -0,0 +1,5 @@ |
|||||
|
'use strict'; |
||||
|
|
||||
|
{ |
||||
|
console.log( 'true' ); |
||||
|
} |
@ -0,0 +1,3 @@ |
|||||
|
{ |
||||
|
console.log( 'true' ); |
||||
|
} |
@ -0,0 +1,8 @@ |
|||||
|
(function () { |
||||
|
'use strict'; |
||||
|
|
||||
|
{ |
||||
|
console.log( 'true' ); |
||||
|
} |
||||
|
|
||||
|
}()); |
@ -0,0 +1,11 @@ |
|||||
|
(function (global, factory) { |
||||
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory() : |
||||
|
typeof define === 'function' && define.amd ? define(factory) : |
||||
|
(factory()); |
||||
|
}(this, (function () { 'use strict'; |
||||
|
|
||||
|
{ |
||||
|
console.log( 'true' ); |
||||
|
} |
||||
|
|
||||
|
}))); |
@ -0,0 +1,5 @@ |
|||||
|
if ( true && true ) { |
||||
|
console.log( 'true' ); |
||||
|
} else { |
||||
|
console.log( 'false' ); |
||||
|
} |
@ -1,8 +1,20 @@ |
|||||
|
var path = require( 'path' ); |
||||
var assert = require( 'assert' ); |
var assert = require( 'assert' ); |
||||
|
|
||||
module.exports = { |
module.exports = { |
||||
description: 'prevents a module importing itself', |
description: 'prevents a module importing itself', |
||||
error: function ( err ) { |
error: { |
||||
assert.ok( /A module cannot import itself/.test( err.message ) ); |
code: 'CANNOT_IMPORT_SELF', |
||||
|
message: `A module cannot import itself`, |
||||
|
pos: 0, |
||||
|
loc: { |
||||
|
file: path.resolve( __dirname, 'main.js' ), |
||||
|
line: 1, |
||||
|
column: 0 |
||||
|
}, |
||||
|
frame: ` |
||||
|
1: import me from './main'; |
||||
|
^ |
||||
|
` |
||||
} |
} |
||||
}; |
}; |
||||
|
@ -1,8 +1,23 @@ |
|||||
|
const path = require( 'path' ); |
||||
const assert = require( 'assert' ); |
const assert = require( 'assert' ); |
||||
|
|
||||
module.exports = { |
module.exports = { |
||||
description: 'default export is not re-exported with export *', |
description: 'default export is not re-exported with export *', |
||||
error ( error ) { |
error: { |
||||
assert.equal( error.message, `'default' is not exported by foo.js (imported by main.js). For help fixing this error see https://github.com/rollup/rollup/wiki/Troubleshooting#name-is-not-exported-by-module` ); |
code: 'MISSING_EXPORT', |
||||
|
message: `'default' is not exported by foo.js`, |
||||
|
pos: 7, |
||||
|
loc: { |
||||
|
file: path.resolve( __dirname, 'main.js' ), |
||||
|
line: 1, |
||||
|
column: 7 |
||||
|
}, |
||||
|
frame: ` |
||||
|
1: import def from './foo.js'; |
||||
|
^ |
||||
|
2: |
||||
|
3: console.log( def ); |
||||
|
`,
|
||||
|
url: `https://github.com/rollup/rollup/wiki/Troubleshooting#name-is-not-exported-by-module` |
||||
} |
} |
||||
}; |
}; |
||||
|
@ -1,13 +0,0 @@ |
|||||
const { resolve } = require('path'); |
|
||||
const assert = require( 'assert' ); |
|
||||
|
|
||||
const r = path => resolve( __dirname, path ); |
|
||||
|
|
||||
module.exports = { |
|
||||
description: 'throws on duplicate export * from', |
|
||||
warnings ( warnings ) { |
|
||||
assert.deepEqual( warnings, [ |
|
||||
`Conflicting namespaces: ${r('main.js')} re-exports 'foo' from both ${r('foo.js')} (will be ignored) and ${r('deep.js')}.` |
|
||||
]); |
|
||||
} |
|
||||
}; |
|
@ -1,12 +1,23 @@ |
|||||
const assert = require( 'assert' ); |
|
||||
const path = require( 'path' ); |
|
||||
|
|
||||
module.exports = { |
module.exports = { |
||||
description: 'warns on export {}, but does not fail', |
description: 'warns on export {}, but does not fail', |
||||
warnings: warnings => { |
warnings: [ |
||||
assert.deepEqual( warnings, [ |
{ |
||||
`Module ${path.resolve( __dirname, 'main.js' )} has an empty export declaration`, |
code: 'EMPTY_EXPORT', |
||||
'Generated an empty bundle' |
message: 'Empty export declaration', |
||||
]); |
pos: 0, |
||||
} |
loc: { |
||||
|
file: require( 'path' ).resolve( __dirname, 'main.js' ), |
||||
|
line: 1, |
||||
|
column: 0 |
||||
|
}, |
||||
|
frame: ` |
||||
|
1: export {}; |
||||
|
^ |
||||
|
` |
||||
|
}, |
||||
|
{ |
||||
|
code: 'EMPTY_BUNDLE', |
||||
|
message: 'Generated an empty bundle' |
||||
|
} |
||||
|
] |
||||
}; |
}; |
||||
|
@ -0,0 +1,8 @@ |
|||||
|
const assert = require( 'assert' ); |
||||
|
|
||||
|
module.exports = { |
||||
|
description: 'handles default exports with no space before declaration', |
||||
|
exports: exports => { |
||||
|
assert.deepEqual( exports, {} ); |
||||
|
} |
||||
|
}; |
@ -0,0 +1 @@ |
|||||
|
export default{}; |
@ -1,3 +1,3 @@ |
|||||
function foo() { |
function foo() { |
||||
import foo from './foo'; |
import foo from './foo.js'; |
||||
} |
} |
||||
|
@ -1,8 +1,23 @@ |
|||||
|
var path = require( 'path' ); |
||||
var assert = require( 'assert' ); |
var assert = require( 'assert' ); |
||||
|
|
||||
module.exports = { |
module.exports = { |
||||
description: 'marking an imported, but unexported, identifier should throw', |
description: 'marking an imported, but unexported, identifier should throw', |
||||
error: function ( err ) { |
error: { |
||||
assert.equal( err.message, `'default' is not exported by empty.js (imported by main.js). For help fixing this error see https://github.com/rollup/rollup/wiki/Troubleshooting#name-is-not-exported-by-module` ); |
code: 'MISSING_EXPORT', |
||||
|
message: `'default' is not exported by empty.js`, |
||||
|
pos: 7, |
||||
|
loc: { |
||||
|
file: path.resolve( __dirname, 'main.js' ), |
||||
|
line: 1, |
||||
|
column: 7 |
||||
|
}, |
||||
|
frame: ` |
||||
|
1: import a from './empty.js'; |
||||
|
^ |
||||
|
2: |
||||
|
3: a(); |
||||
|
`,
|
||||
|
url: `https://github.com/rollup/rollup/wiki/Troubleshooting#name-is-not-exported-by-module` |
||||
} |
} |
||||
}; |
}; |
||||
|
@ -1,9 +1,21 @@ |
|||||
var assert = require( 'assert' ); |
|
||||
|
|
||||
module.exports = { |
module.exports = { |
||||
options: { |
warnings: [ |
||||
onwarn: function ( msg ) { |
{ |
||||
assert.equal( msg, `main.js (3:21) 'foo' is not exported by 'empty.js'. See https://github.com/rollup/rollup/wiki/Troubleshooting#name-is-not-exported-by-module` ); |
code: 'MISSING_EXPORT', |
||||
|
message: `'foo' is not exported by 'empty.js'`, |
||||
|
pos: 61, |
||||
|
loc: { |
||||
|
file: require( 'path' ).resolve( __dirname, 'main.js' ), |
||||
|
line: 3, |
||||
|
column: 25 |
||||
|
}, |
||||
|
frame: ` |
||||
|
1: import * as mod from './empty.js'; |
||||
|
2: |
||||
|
3: assert.equal( typeof mod.foo, 'undefined' ); |
||||
|
^ |
||||
|
`,
|
||||
|
url: `https://github.com/rollup/rollup/wiki/Troubleshooting#name-is-not-exported-by-module` |
||||
} |
} |
||||
} |
] |
||||
}; |
}; |
||||
|
@ -1,8 +1,21 @@ |
|||||
|
var path = require( 'path' ); |
||||
var assert = require( 'assert' ); |
var assert = require( 'assert' ); |
||||
|
|
||||
module.exports = { |
module.exports = { |
||||
description: 'reexporting a missing identifier should print an error', |
description: 'reexporting a missing identifier should print an error', |
||||
error: function ( error ) { |
error: { |
||||
assert.ok( /^'foo' is not exported/.test( error.message ) ); |
code: 'MISSING_EXPORT', |
||||
|
message: `'foo' is not exported by empty.js`, |
||||
|
pos: 9, |
||||
|
loc: { |
||||
|
file: path.resolve( __dirname, 'main.js' ), |
||||
|
line: 1, |
||||
|
column: 9 |
||||
|
}, |
||||
|
frame: ` |
||||
|
1: export { foo as bar } from './empty.js'; |
||||
|
^ |
||||
|
`,
|
||||
|
url: 'https://github.com/rollup/rollup/wiki/Troubleshooting#name-is-not-exported-by-module' |
||||
} |
} |
||||
}; |
}; |
||||
|
@ -1,8 +0,0 @@ |
|||||
var assert = require( 'assert' ); |
|
||||
|
|
||||
module.exports = { |
|
||||
description: 'reports syntax error filename', |
|
||||
error: function ( err ) { |
|
||||
assert.ok( /in .+main\.js/.test( err.message ) ); |
|
||||
} |
|
||||
}; |
|
@ -1 +0,0 @@ |
|||||
var 42 = answer; |
|
@ -0,0 +1,9 @@ |
|||||
|
module.exports = { |
||||
|
description: 'handles vars with init in dead branch (#1198)', |
||||
|
warnings: [ |
||||
|
{ |
||||
|
code: 'EMPTY_BUNDLE', |
||||
|
message: 'Generated an empty bundle' |
||||
|
} |
||||
|
] |
||||
|
}; |
@ -0,0 +1,4 @@ |
|||||
|
if ( false ) { |
||||
|
var foo = []; |
||||
|
var bar = foo.concat( 'x' ); |
||||
|
} |
@ -1,10 +1,10 @@ |
|||||
var assert = require( 'assert' ); |
|
||||
|
|
||||
module.exports = { |
module.exports = { |
||||
description: 'warns if default and named exports are used in auto mode', |
description: 'warns if default and named exports are used in auto mode', |
||||
warnings: function ( warnings ) { |
warnings: [ |
||||
assert.deepEqual( warnings, [ |
{ |
||||
'Using named and default exports together. Consumers of your bundle will have to use bundle[\'default\'] to access the default export, which may not be what you want. Use `exports: \'named\'` to disable this warning. See https://github.com/rollup/rollup/wiki/JavaScript-API#exports for more information' |
code: 'MIXED_EXPORTS', |
||||
]); |
message: `Using named and default exports together. Consumers of your bundle will have to use 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` |
||||
|
} |
||||
|
] |
||||
}; |
}; |
||||
|
@ -1,10 +1,9 @@ |
|||||
const assert = require( 'assert' ); |
|
||||
|
|
||||
module.exports = { |
module.exports = { |
||||
description: 'warns if empty bundle is generated (#444)', |
description: 'warns if empty bundle is generated (#444)', |
||||
warnings: warnings => { |
warnings: [ |
||||
assert.deepEqual( warnings, [ |
{ |
||||
'Generated an empty bundle' |
code: 'EMPTY_BUNDLE', |
||||
]); |
message: 'Generated an empty bundle' |
||||
} |
} |
||||
|
] |
||||
}; |
}; |
||||
|
@ -1,16 +1,20 @@ |
|||||
var assert = require( 'assert' ); |
|
||||
|
|
||||
var warned = false; |
|
||||
|
|
||||
module.exports = { |
module.exports = { |
||||
description: 'warns about use of eval', |
description: 'warns about use of eval', |
||||
options: { |
warnings: [ |
||||
onwarn: function ( message ) { |
{ |
||||
warned = true; |
code: 'EVAL', |
||||
assert.ok( /Use of `eval` \(in .+?main\.js\) is strongly discouraged, as it poses security risks and may cause issues with minification\. See https:\/\/github.com\/rollup\/rollup\/wiki\/Troubleshooting#avoiding-eval for more details/.test( message ) ); |
message: `Use of eval is strongly discouraged, as it poses security risks and may cause issues with minification`, |
||||
|
pos: 13, |
||||
|
loc: { |
||||
|
column: 13, |
||||
|
file: require( 'path' ).resolve( __dirname, 'main.js' ), |
||||
|
line: 1 |
||||
|
}, |
||||
|
frame: ` |
||||
|
1: var result = eval( '1 + 1' ); |
||||
|
^ |
||||
|
`,
|
||||
|
url: 'https://github.com/rollup/rollup/wiki/Troubleshooting#avoiding-eval' |
||||
} |
} |
||||
}, |
] |
||||
exports: function () { |
|
||||
assert.ok( warned, 'did not warn' ); |
|
||||
} |
|
||||
}; |
}; |
||||
|
@ -0,0 +1,9 @@ |
|||||
|
module.exports = { |
||||
|
description: 'warns on duplicate export * from', |
||||
|
warnings: [ |
||||
|
{ |
||||
|
code: 'NAMESPACE_CONFLICT', |
||||
|
message: `Conflicting namespaces: main.js re-exports 'foo' from both foo.js (will be ignored) and deep.js` |
||||
|
} |
||||
|
] |
||||
|
}; |
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue