mirror of https://github.com/lukechilds/rollup.git
Rich-Harris
9 years ago
99 changed files with 592 additions and 52 deletions
@ -0,0 +1 @@ |
|||
export default `Object.defineProperty(exports, '__esModule', { value: true });`; |
@ -1,4 +1,6 @@ |
|||
'use strict'; |
|||
|
|||
Object.defineProperty(exports, '__esModule', { value: true }); |
|||
|
|||
exports.Foo = class Foo {} |
|||
exports.Foo = lol( exports.Foo ); |
|||
|
@ -0,0 +1,3 @@ |
|||
module.exports = { |
|||
description: 'ensures bundle imports are deconflicted (#659)' |
|||
}; |
@ -0,0 +1,7 @@ |
|||
define(['foo', 'bar'], function (foo, bar) { 'use strict'; |
|||
|
|||
console.log( bar.a ); |
|||
|
|||
console.log( foo.a ); |
|||
|
|||
}); |
@ -0,0 +1,8 @@ |
|||
'use strict'; |
|||
|
|||
var foo = require('foo'); |
|||
var bar = require('bar'); |
|||
|
|||
console.log( bar.a ); |
|||
|
|||
console.log( foo.a ); |
@ -0,0 +1,6 @@ |
|||
import { a } from 'foo'; |
|||
import { a as a$1 } from 'bar'; |
|||
|
|||
console.log( a$1 ); |
|||
|
|||
console.log( a ); |
@ -0,0 +1,8 @@ |
|||
(function (foo,bar) { |
|||
'use strict'; |
|||
|
|||
console.log( bar.a ); |
|||
|
|||
console.log( foo.a ); |
|||
|
|||
}(foo,bar)); |
@ -0,0 +1,11 @@ |
|||
(function (global, factory) { |
|||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('foo'), require('bar')) : |
|||
typeof define === 'function' && define.amd ? define(['foo', 'bar'], factory) : |
|||
(factory(global.foo,global.bar)); |
|||
}(this, function (foo,bar) { 'use strict'; |
|||
|
|||
console.log( bar.a ); |
|||
|
|||
console.log( foo.a ); |
|||
|
|||
})); |
@ -0,0 +1,4 @@ |
|||
import { a } from 'foo'; |
|||
import './other.js'; |
|||
|
|||
console.log( a ); |
@ -0,0 +1,3 @@ |
|||
import { a } from 'bar'; |
|||
|
|||
console.log( a ); |
@ -1,9 +1,11 @@ |
|||
'use strict'; |
|||
|
|||
Object.defineProperty(exports, '__esModule', { value: true }); |
|||
|
|||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } |
|||
|
|||
var x = _interopDefault(require('x')); |
|||
|
|||
|
|||
|
|||
exports.x = x; |
|||
exports.x = x; |
|||
|
@ -0,0 +1,3 @@ |
|||
module.exports = { |
|||
description: 'disinguishes between external default and namespace (#637)' |
|||
}; |
@ -0,0 +1,9 @@ |
|||
define(['foo'], function (foo) { 'use strict'; |
|||
|
|||
var foo__default = foo['default']; |
|||
|
|||
console.log( foo.bar ); |
|||
|
|||
console.log( foo__default ); |
|||
|
|||
}); |
@ -0,0 +1,8 @@ |
|||
'use strict'; |
|||
|
|||
var foo = require('foo'); |
|||
var foo__default = foo['default']; |
|||
|
|||
console.log( foo.bar ); |
|||
|
|||
console.log( foo__default ); |
@ -0,0 +1,6 @@ |
|||
import * as foo from 'foo'; |
|||
import foo__default from 'foo'; |
|||
|
|||
console.log( foo.bar ); |
|||
|
|||
console.log( foo__default ); |
@ -0,0 +1,10 @@ |
|||
(function (foo) { |
|||
'use strict'; |
|||
|
|||
var foo__default = foo['default']; |
|||
|
|||
console.log( foo.bar ); |
|||
|
|||
console.log( foo__default ); |
|||
|
|||
}(foo)); |
@ -0,0 +1,13 @@ |
|||
(function (global, factory) { |
|||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('foo')) : |
|||
typeof define === 'function' && define.amd ? define(['foo'], factory) : |
|||
(factory(global.foo)); |
|||
}(this, function (foo) { 'use strict'; |
|||
|
|||
var foo__default = foo['default']; |
|||
|
|||
console.log( foo.bar ); |
|||
|
|||
console.log( foo__default ); |
|||
|
|||
})); |
@ -0,0 +1,4 @@ |
|||
import foo from 'foo'; |
|||
import './other.js'; |
|||
|
|||
console.log( foo ); |
@ -0,0 +1,3 @@ |
|||
import * as foo from 'foo'; |
|||
|
|||
console.log( foo.bar ); |
@ -1,5 +1,7 @@ |
|||
'use strict'; |
|||
|
|||
Object.defineProperty(exports, '__esModule', { value: true }); |
|||
|
|||
var answer = 42; |
|||
|
|||
exports.answer = answer; |
|||
exports.answer = answer; |
|||
|
@ -0,0 +1,7 @@ |
|||
module.exports = { |
|||
description: 'uses const instead of var if specified (#653)', |
|||
options: { |
|||
preferConst: true, |
|||
moduleName: 'myBundle' |
|||
} |
|||
}; |
@ -0,0 +1,18 @@ |
|||
define(['external', 'other', 'another'], function (external, other, another) { 'use strict'; |
|||
|
|||
const a = 1; |
|||
const b = 2; |
|||
|
|||
|
|||
const namespace = Object.freeze({ |
|||
a: a, |
|||
b: b |
|||
}); |
|||
|
|||
console.log( Object.keys( namespace ) ); |
|||
|
|||
const main = 42; |
|||
|
|||
return main; |
|||
|
|||
}); |
@ -0,0 +1,20 @@ |
|||
'use strict'; |
|||
|
|||
const external = require('external'); |
|||
const other = require('other'); |
|||
const another = require('another'); |
|||
|
|||
const a = 1; |
|||
const b = 2; |
|||
|
|||
|
|||
const namespace = Object.freeze({ |
|||
a: a, |
|||
b: b |
|||
}); |
|||
|
|||
console.log( Object.keys( namespace ) ); |
|||
|
|||
const main = 42; |
|||
|
|||
module.exports = main; |
@ -0,0 +1,18 @@ |
|||
import 'external'; |
|||
import 'other'; |
|||
import 'another'; |
|||
|
|||
const a = 1; |
|||
const b = 2; |
|||
|
|||
|
|||
const namespace = Object.freeze({ |
|||
a: a, |
|||
b: b |
|||
}); |
|||
|
|||
console.log( Object.keys( namespace ) ); |
|||
|
|||
const main = 42; |
|||
|
|||
export default main; |
@ -0,0 +1,19 @@ |
|||
const myBundle = (function (external,other,another) { |
|||
'use strict'; |
|||
|
|||
const a = 1; |
|||
const b = 2; |
|||
|
|||
|
|||
const namespace = Object.freeze({ |
|||
a: a, |
|||
b: b |
|||
}); |
|||
|
|||
console.log( Object.keys( namespace ) ); |
|||
|
|||
const main = 42; |
|||
|
|||
return main; |
|||
|
|||
}(external,other,another)); |
@ -0,0 +1,22 @@ |
|||
(function (global, factory) { |
|||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('external'), require('other'), require('another')) : |
|||
typeof define === 'function' && define.amd ? define(['external', 'other', 'another'], factory) : |
|||
(global.myBundle = factory(global.external,global.other,global.another)); |
|||
}(this, function (external,other,another) { 'use strict'; |
|||
|
|||
const a = 1; |
|||
const b = 2; |
|||
|
|||
|
|||
const namespace = Object.freeze({ |
|||
a: a, |
|||
b: b |
|||
}); |
|||
|
|||
console.log( Object.keys( namespace ) ); |
|||
|
|||
const main = 42; |
|||
|
|||
return main; |
|||
|
|||
})); |
@ -0,0 +1,9 @@ |
|||
import external from 'external'; |
|||
import a from 'other'; |
|||
import { b } from 'other'; |
|||
import { another } from 'another'; |
|||
import * as namespace from './namespace.js'; |
|||
|
|||
console.log( Object.keys( namespace ) ); |
|||
|
|||
export default 42; |
@ -0,0 +1,2 @@ |
|||
export const a = 1; |
|||
export const b = 2; |
@ -0,0 +1,3 @@ |
|||
module.exports = { |
|||
description: 'debugger statements are preserved (#664)' |
|||
}; |
@ -0,0 +1,7 @@ |
|||
define(function () { 'use strict'; |
|||
|
|||
before(); |
|||
debugger; |
|||
after(); |
|||
|
|||
}); |
@ -0,0 +1,5 @@ |
|||
'use strict'; |
|||
|
|||
before(); |
|||
debugger; |
|||
after(); |
@ -0,0 +1,3 @@ |
|||
before(); |
|||
debugger; |
|||
after(); |
@ -0,0 +1,8 @@ |
|||
(function () { |
|||
'use strict'; |
|||
|
|||
before(); |
|||
debugger; |
|||
after(); |
|||
|
|||
}()); |
@ -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'; |
|||
|
|||
before(); |
|||
debugger; |
|||
after(); |
|||
|
|||
})); |
@ -0,0 +1,3 @@ |
|||
before(); |
|||
debugger; |
|||
after(); |
@ -0,0 +1,8 @@ |
|||
const assert = require( 'assert' ); |
|||
|
|||
module.exports = { |
|||
description: 'throws on double default exports', |
|||
error: err => { |
|||
assert.equal( err.message, 'A module can only have one default export' ); |
|||
} |
|||
}; |
@ -0,0 +1,2 @@ |
|||
export default 1; |
|||
export default 2; |
@ -0,0 +1,2 @@ |
|||
import foo from './foo.js'; |
|||
console.log( foo ); |
@ -0,0 +1,8 @@ |
|||
const assert = require( 'assert' ); |
|||
|
|||
module.exports = { |
|||
description: 'throws on duplicate named exports', |
|||
error: err => { |
|||
assert.equal( err.message, `A module cannot have multiple exports with the same name ('foo')` ); |
|||
} |
|||
}; |
@ -0,0 +1,3 @@ |
|||
var foo = 1; |
|||
export { foo }; |
|||
export { foo }; |
@ -0,0 +1,2 @@ |
|||
import { foo } from './foo.js'; |
|||
console.log( foo ); |
@ -0,0 +1,8 @@ |
|||
const assert = require( 'assert' ); |
|||
|
|||
module.exports = { |
|||
description: 'throws on duplicate named exports', |
|||
error: err => { |
|||
assert.equal( err.message, `A module cannot have multiple exports with the same name ('foo')` ); |
|||
} |
|||
}; |
@ -0,0 +1 @@ |
|||
export var foo = 2; |
@ -0,0 +1,3 @@ |
|||
var foo = 1; |
|||
export { foo }; |
|||
export { foo } from './bar.js'; |
@ -0,0 +1,2 @@ |
|||
import { foo } from './foo.js'; |
|||
console.log( foo ); |
@ -0,0 +1,28 @@ |
|||
var assert = require( 'assert' ); |
|||
var path = require( 'path' ); |
|||
|
|||
module.exports = { |
|||
description: 'includes an external module included dynamically by an alias', |
|||
options: { |
|||
entry: path.join( __dirname, 'first', 'main.js' ), |
|||
external: [ 'lodash' ], |
|||
|
|||
// Define a simple alias plugin for underscore
|
|||
plugins: [ |
|||
{ |
|||
resolveId: function ( id ) { |
|||
if ( id === 'underscore' ) { |
|||
return 'lodash'; |
|||
} |
|||
} |
|||
} |
|||
] |
|||
}, |
|||
|
|||
context: { |
|||
require: function ( required ) { |
|||
assert.equal( required, 'lodash' ); |
|||
return 1; |
|||
} |
|||
} |
|||
}; |
@ -0,0 +1,10 @@ |
|||
import _ from 'underscore'; |
|||
import first from './module'; |
|||
|
|||
export default function ( inputs ) { |
|||
if ( !_.isArray( inputs ) ) { |
|||
return inputs; |
|||
} |
|||
|
|||
return first.square( inputs ); |
|||
}; |
@ -0,0 +1,7 @@ |
|||
import _ from 'underscore'; |
|||
|
|||
export default function square ( inputs ) { |
|||
return _.map( inputs, function ( x ) { |
|||
return x * x; |
|||
}); |
|||
}; |
@ -0,0 +1,14 @@ |
|||
module.exports = { |
|||
description: 'allows external option to be a function (#522)', |
|||
options: { |
|||
external: id => { |
|||
return id === 'external'; |
|||
} |
|||
}, |
|||
context: { |
|||
require: id => { |
|||
if ( id === 'external' ) return 42; |
|||
return require( id ); |
|||
} |
|||
} |
|||
}; |
@ -0,0 +1,2 @@ |
|||
import ext from 'external'; |
|||
assert.equal( ext, 42 ); |
@ -0,0 +1,18 @@ |
|||
var path = require( 'path' ); |
|||
var assert = require( 'assert' ); |
|||
|
|||
module.exports = { |
|||
description: 'external paths from custom resolver remain external (#633)', |
|||
options: { |
|||
external: [ 'path' ], |
|||
plugins: [{ |
|||
resolveId: ( id ) => { |
|||
if ( id == './dep.js' ) return 'path'; |
|||
return id; |
|||
} |
|||
}] |
|||
}, |
|||
exports: exports => { |
|||
assert.equal( exports, path.resolve ); |
|||
} |
|||
}; |
@ -0,0 +1,2 @@ |
|||
import { resolve } from './dep.js'; |
|||
export default resolve; |
Loading…
Reference in new issue