mirror of https://github.com/lukechilds/rollup.git
Browse Source
preserve updates and fixes include readdirSync assignment pattern fix handle side-effects update tests fix double removal bug reinstate sourcemaps update tests add missing break statement handle export * from internal add back tests update all tests skip namespace optimisation tests for now reinstate various fixes reinstate fast/leaner deconflicting, update testscontingency-plan
Rich-Harris
9 years ago
118 changed files with 882 additions and 185 deletions
@ -1,9 +1,8 @@ |
|||
sudo: false |
|||
language: node_js |
|||
node_js: |
|||
- "0.10" |
|||
- "0.12" |
|||
- "iojs" |
|||
- "4" |
|||
env: |
|||
global: |
|||
- BUILD_TIMEOUT=10000 |
|||
|
@ -0,0 +1,33 @@ |
|||
# http://www.appveyor.com/docs/appveyor-yml |
|||
|
|||
version: "{build}" |
|||
|
|||
clone_depth: 10 |
|||
|
|||
init: |
|||
- git config --global core.autocrlf false |
|||
|
|||
environment: |
|||
matrix: |
|||
# node.js |
|||
- nodejs_version: 0.10 |
|||
- nodejs_version: 0.12 |
|||
# io.js |
|||
- nodejs_version: 1 |
|||
|
|||
install: |
|||
- ps: Install-Product node $env:nodejs_version |
|||
- npm install |
|||
|
|||
build: off |
|||
|
|||
test_script: |
|||
- node --version && npm --version |
|||
- npm test |
|||
|
|||
matrix: |
|||
fast_finish: false |
|||
|
|||
# cache: |
|||
# - C:\Users\appveyor\AppData\Roaming\npm-cache -> package.json # npm cache |
|||
# - node_modules -> package.json # local npm modules |
@ -0,0 +1,6 @@ |
|||
// this looks ridiculous, but it prevents sourcemap tooling from mistaking
|
|||
// this for an actual sourceMappingURL
|
|||
let SOURCEMAPPING_URL = 'sourceMa'; |
|||
SOURCEMAPPING_URL += 'ppingURL'; |
|||
|
|||
export default SOURCEMAPPING_URL; |
@ -1,5 +1,5 @@ |
|||
import { relative } from 'path'; |
|||
import { relative, normalize } from 'path'; |
|||
import { format } from 'util'; |
|||
|
|||
assert.equal( format( 'it %s', 'works' ), 'it works' ); |
|||
assert.equal( relative( 'a/b/c', 'a/c/b' ), '../../c/b' ); |
|||
assert.equal( relative( 'a/b/c', 'a/c/b' ), normalize('../../c/b') ); |
|||
|
@ -0,0 +1,6 @@ |
|||
module.exports = { |
|||
description: 'should be able to export * from the bundle', |
|||
options: { |
|||
moduleName: 'exposedInternals' |
|||
} |
|||
}; |
@ -0,0 +1,9 @@ |
|||
define(['exports'], function (exports) { 'use strict'; |
|||
|
|||
const a = 1; |
|||
const b = 2; |
|||
|
|||
exports.a = a; |
|||
exports.b = b; |
|||
|
|||
}); |
@ -0,0 +1,7 @@ |
|||
'use strict'; |
|||
|
|||
const a = 1; |
|||
const b = 2; |
|||
|
|||
exports.a = a; |
|||
exports.b = b; |
@ -0,0 +1,4 @@ |
|||
const a = 1; |
|||
const b = 2; |
|||
|
|||
export { a, b }; |
@ -0,0 +1,9 @@ |
|||
(function (exports) { 'use strict'; |
|||
|
|||
const a = 1; |
|||
const b = 2; |
|||
|
|||
exports.a = a; |
|||
exports.b = b; |
|||
|
|||
})((this.exposedInternals = {})); |
@ -0,0 +1,13 @@ |
|||
(function (global, factory) { |
|||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : |
|||
typeof define === 'function' && define.amd ? define(['exports'], factory) : |
|||
factory((global.exposedInternals = {})); |
|||
}(this, function (exports) { 'use strict'; |
|||
|
|||
const a = 1; |
|||
const b = 2; |
|||
|
|||
exports.a = a; |
|||
exports.b = b; |
|||
|
|||
})); |
@ -0,0 +1,3 @@ |
|||
export const a = 1; |
|||
export const b = 2; |
|||
export default 42; |
@ -0,0 +1 @@ |
|||
export * from './internal.js'; |
@ -0,0 +1,4 @@ |
|||
module.exports = { |
|||
skip: true, |
|||
description: 'it does static lookup optimization of internal namespaces' |
|||
}; |
@ -0,0 +1,7 @@ |
|||
define(function () { 'use strict'; |
|||
|
|||
function a () {} |
|||
|
|||
a(); |
|||
|
|||
}); |
@ -0,0 +1,5 @@ |
|||
'use strict'; |
|||
|
|||
function a () {} |
|||
|
|||
a(); |
@ -0,0 +1,3 @@ |
|||
function a () {} |
|||
|
|||
a(); |
@ -0,0 +1,7 @@ |
|||
(function () { 'use strict'; |
|||
|
|||
function a () {} |
|||
|
|||
a(); |
|||
|
|||
})(); |
@ -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'; |
|||
|
|||
function a () {} |
|||
|
|||
a(); |
|||
|
|||
})); |
@ -0,0 +1,3 @@ |
|||
import * as quux from './quux'; |
|||
|
|||
export { quux }; |
@ -0,0 +1,3 @@ |
|||
import * as bar from './bar'; |
|||
|
|||
export { bar }; |
@ -0,0 +1,3 @@ |
|||
import * as foo from './foo'; |
|||
|
|||
foo.bar.quux.a(); |
@ -0,0 +1 @@ |
|||
export function a () {} |
@ -0,0 +1,3 @@ |
|||
module.exports = { |
|||
description: 'side-effects to non-globals are not blindly included' |
|||
}; |
@ -0,0 +1,7 @@ |
|||
define(function () { 'use strict'; |
|||
|
|||
var foo = 42; |
|||
|
|||
assert.equal( foo, 42 ); |
|||
|
|||
}); |
@ -0,0 +1,5 @@ |
|||
'use strict'; |
|||
|
|||
var foo = 42; |
|||
|
|||
assert.equal( foo, 42 ); |
@ -0,0 +1,3 @@ |
|||
var foo = 42; |
|||
|
|||
assert.equal( foo, 42 ); |
@ -0,0 +1,7 @@ |
|||
(function () { 'use strict'; |
|||
|
|||
var foo = 42; |
|||
|
|||
assert.equal( foo, 42 ); |
|||
|
|||
})(); |
@ -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'; |
|||
|
|||
var foo = 42; |
|||
|
|||
assert.equal( foo, 42 ); |
|||
|
|||
})); |
@ -0,0 +1,13 @@ |
|||
var uid = 0; |
|||
uid = 1; |
|||
uid += 1; |
|||
uid++; |
|||
|
|||
// ensure identifiers aren't treated as globals just because
|
|||
// var declaration hasn't been encountered yet...
|
|||
uid2 = 1; |
|||
uid2 += 1; |
|||
uid2++; |
|||
var uid2; |
|||
|
|||
export var foo = 42; |
@ -0,0 +1,2 @@ |
|||
import { foo } from './foo'; |
|||
assert.equal( foo, 42 ); |
@ -1,8 +1,8 @@ |
|||
import { relative } from 'path'; |
|||
import { relative, normalize } from 'path'; |
|||
import foo from './foo'; |
|||
|
|||
var path = 'foo/bar/baz'; |
|||
var path2 = 'foo/baz/bar'; |
|||
|
|||
assert.equal( relative( path, path2 ), '../../baz/bar' ); |
|||
assert.equal( foo, '../../c/b' ); |
|||
assert.equal( relative( path, path2 ), normalize('../../baz/bar') ); |
|||
assert.equal( foo, normalize('../../c/b') ); |
@ -0,0 +1,4 @@ |
|||
module.exports = { |
|||
description: 'allows reassigments to default parameters that shadow imports', |
|||
babel: true |
|||
}; |
@ -0,0 +1,21 @@ |
|||
import { bar, baz, x, items, p, q, r, s } from './other'; |
|||
|
|||
function foo ( bar = 1, { baz } = { baz: 2 }, [[[,x = 3] = []] = []] = [], ...items ) { |
|||
bar += 1; |
|||
baz += 1; |
|||
x += 1; |
|||
|
|||
let { p, q } = { p: 4, q: 5 }; |
|||
let [ r, s ] = [ 6, 7 ]; |
|||
|
|||
p++; |
|||
q += 1; |
|||
r = 7; |
|||
s = 6; |
|||
|
|||
return bar + baz + x + items.length + p + q + r + s; |
|||
} |
|||
|
|||
assert.equal( foo(), 33 ); |
|||
assert.equal( foo( 2 ), 34 ); |
|||
assert.equal( foo( 2, { baz: 3 }, [[[99,10]]], 'a', 'b', 'c' ), 45 ); |
@ -0,0 +1,8 @@ |
|||
export const bar = 'bar'; |
|||
export const baz = 'baz'; |
|||
export const x = 'x'; |
|||
export const items = 'items'; |
|||
export const p = 'p'; |
|||
export const q = 'q'; |
|||
export const r = 'r'; |
|||
export const s = 's'; |
@ -0,0 +1,8 @@ |
|||
var assert = require( 'assert' ); |
|||
|
|||
module.exports = { |
|||
description: 'prevents a module importing itself', |
|||
error: function ( err ) { |
|||
assert.ok( /A module cannot import itself/.test( err.message ) ); |
|||
} |
|||
}; |
@ -0,0 +1 @@ |
|||
import me from './main'; |
@ -0,0 +1,3 @@ |
|||
module.exports = { |
|||
description: 'does namespace optimization when possible, but not for dynamic lookups' |
|||
}; |
@ -0,0 +1,2 @@ |
|||
export var bar = 'bar'; |
|||
export var baz = 'baz'; |
@ -0,0 +1,8 @@ |
|||
import * as foo from './foo'; |
|||
|
|||
var bar = 'baz'; |
|||
|
|||
assert.equal( foo.bar, 'bar' ); |
|||
assert.equal( foo.baz, 'baz' ); |
|||
|
|||
assert.equal( foo[ bar ], 'baz' ); |
@ -0,0 +1,11 @@ |
|||
var assert = require( 'assert' ); |
|||
|
|||
module.exports = { |
|||
description: 'export type must be auto, default, named or none', |
|||
bundleOptions: { |
|||
exports: 'blah' |
|||
}, |
|||
generateError: function ( err ) { |
|||
assert.ok( /options\.exports must be 'default', 'named', 'none', 'auto', or left unspecified/.test( err.message ) ); |
|||
} |
|||
}; |
@ -0,0 +1 @@ |
|||
export default 42; |
@ -0,0 +1,11 @@ |
|||
var assert = require( 'assert' ); |
|||
|
|||
module.exports = { |
|||
description: 'cannot have named exports if explicit export type is default', |
|||
bundleOptions: { |
|||
exports: 'none' |
|||
}, |
|||
generateError: function ( err ) { |
|||
assert.ok( /'none' was specified for options\.exports/.test( err.message ) ); |
|||
} |
|||
}; |
@ -0,0 +1 @@ |
|||
export default 42; |
@ -0,0 +1,11 @@ |
|||
var assert = require( 'assert' ); |
|||
|
|||
module.exports = { |
|||
description: 'cannot have named exports if explicit export type is default', |
|||
bundleOptions: { |
|||
exports: 'default' |
|||
}, |
|||
generateError: function ( err ) { |
|||
assert.ok( /'default' was specified for options\.exports/.test( err.message ) ); |
|||
} |
|||
}; |
@ -0,0 +1 @@ |
|||
export var foo = 42; |
@ -0,0 +1,3 @@ |
|||
module.exports = { |
|||
description: 'globally called function should be included if it modifies an exported value (#112)' |
|||
}; |
@ -0,0 +1,3 @@ |
|||
import value from './module.js'; |
|||
|
|||
assert.equal( value, 3 ); |
@ -0,0 +1,17 @@ |
|||
var value = 1; |
|||
|
|||
function change () { |
|||
value = 2; |
|||
} |
|||
|
|||
function changeAgain () { |
|||
value += 1; |
|||
} |
|||
|
|||
change(); |
|||
|
|||
if ( true ) { |
|||
changeAgain(); |
|||
} |
|||
|
|||
export default value; |
@ -0,0 +1,3 @@ |
|||
module.exports = { |
|||
description: 'handles multiple declaration blocks with multiple declarations (#105)' |
|||
}; |
@ -0,0 +1,2 @@ |
|||
var a, b; |
|||
var c, d; |
@ -0,0 +1,12 @@ |
|||
var path = require( 'path' ); |
|||
var assert = require( 'assert' ); |
|||
|
|||
module.exports = { |
|||
description: 'user-facing bundle has modules array', |
|||
bundle: function ( bundle ) { |
|||
assert.ok( bundle.modules ); |
|||
assert.equal( bundle.modules.length, 2 ); |
|||
assert.equal( path.relative(bundle.modules[0].id, path.resolve(__dirname, 'foo.js')), '' ); |
|||
assert.equal( path.relative(bundle.modules[1].id, path.resolve(__dirname, 'main.js')), '' ); |
|||
} |
|||
}; |
@ -0,0 +1 @@ |
|||
export default 42; |
@ -0,0 +1,2 @@ |
|||
import foo from './foo'; |
|||
assert.equal( foo, 42 ); |
@ -0,0 +1,4 @@ |
|||
module.exports = { |
|||
description: 'default resolver imports from a subdirectory of an external module', |
|||
babel: true |
|||
}; |
@ -0,0 +1,5 @@ |
|||
// this test is brittle, it relies on this dependency continuing
|
|||
// to be structured in a certain way
|
|||
import btoa from 'magic-string/src/utils/btoa'; |
|||
|
|||
assert.equal( btoa( 'it works' ), new Buffer( 'it works' ).toString( 'base64' ) ); |
@ -1,6 +1,6 @@ |
|||
import { relative } from 'path'; |
|||
import { relative, normalize } from 'path'; |
|||
|
|||
var path = 'foo/bar/baz'; |
|||
var path2 = 'foo/baz/bar'; |
|||
|
|||
assert.equal( relative( path, path2 ), '../../baz/bar' ); |
|||
assert.equal( relative( path, path2 ), normalize('../../baz/bar') ); |
@ -0,0 +1,8 @@ |
|||
var assert = require( 'assert' ); |
|||
|
|||
module.exports = { |
|||
description: 'marking an imported, but unexported, identifier should throw', |
|||
error: function ( err ) { |
|||
assert.ok( /Module .+empty\.js does not export default \(imported by .+main\.js\)/.test( err.message ) ); |
|||
} |
|||
}; |
@ -0,0 +1,3 @@ |
|||
import a from './empty.js'; |
|||
|
|||
a(); |
@ -1,5 +1,6 @@ |
|||
import foo from './foo'; |
|||
import bar from './bar'; |
|||
import { normalize } from 'path'; |
|||
|
|||
assert.equal( foo, 'foo' ); |
|||
assert.equal( bar(), '../../baz/bar' ); |
|||
assert.equal( bar(), normalize('../../baz/bar') ); |
|||
|
@ -1,5 +1,6 @@ |
|||
import foo from './foo'; |
|||
import bar from './bar'; |
|||
import { normalize } from 'path'; |
|||
|
|||
assert.equal( foo, 'foo' ); |
|||
assert.equal( bar(), '../../baz/bar' ); |
|||
assert.equal( bar(), normalize('../../baz/bar') ); |
|||
|
@ -0,0 +1,14 @@ |
|||
var assert = require( 'assert' ); |
|||
|
|||
var Math = {}; |
|||
|
|||
module.exports = { |
|||
description: 'side-effects to assumed globals are included', |
|||
context: { |
|||
Math: Math |
|||
}, |
|||
exports: function ( exports ) { |
|||
assert.equal( Math.square( 3 ), 9 ); |
|||
assert.equal( Math.cube( 3 ), 27 ); |
|||
} |
|||
}; |
@ -0,0 +1,3 @@ |
|||
import { square } from './math'; |
|||
|
|||
assert.equal( square( 2 ), 4 ); |
@ -0,0 +1,15 @@ |
|||
function square ( x ) { |
|||
return x * x; |
|||
} |
|||
|
|||
function cube ( x ) { |
|||
return x * x * x; |
|||
} |
|||
|
|||
Math.square = square; |
|||
|
|||
if ( true ) { |
|||
Math.cube = cube; |
|||
} |
|||
|
|||
export { square }; |
@ -0,0 +1,5 @@ |
|||
module.exports = { |
|||
// solo: true,
|
|||
// show: true,
|
|||
description: 'module sorter is not confused by top-level call expressions' |
|||
}; |
@ -0,0 +1,20 @@ |
|||
import { b } from './b'; |
|||
import z from './z'; |
|||
|
|||
z(); |
|||
|
|||
const p = { |
|||
q: function () { |
|||
b.nope(); |
|||
} |
|||
}; |
|||
|
|||
(function () { |
|||
const p = { |
|||
q: function () { |
|||
b.nope(); |
|||
} |
|||
}; |
|||
})(); |
|||
|
|||
export default 42; |
@ -0,0 +1 @@ |
|||
export const b = function () {}; |
@ -0,0 +1,3 @@ |
|||
import { b } from './b'; |
|||
|
|||
export const c = function () {}; |
@ -0,0 +1,4 @@ |
|||
import a from './a'; |
|||
import z from './z'; |
|||
|
|||
z(); |
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue