Browse Source

Merge branch 'master' into value-tracking

value-tracking
Rich-Harris 8 years ago
parent
commit
3bd04068c5
  1. 13
      CHANGELOG.md
  2. 2
      package.json
  3. 6
      src/Module.js
  4. 2
      src/ast/nodes/MemberExpression.js
  5. 10
      src/ast/nodes/shared/callHasEffects.js
  6. 8
      test/form/export-all-multiple/_config.js
  7. 11
      test/form/export-all-multiple/_expected/amd.js
  8. 13
      test/form/export-all-multiple/_expected/cjs.js
  9. 3
      test/form/export-all-multiple/_expected/es.js
  10. 10
      test/form/export-all-multiple/_expected/iife.js
  11. 13
      test/form/export-all-multiple/_expected/umd.js
  12. 3
      test/form/export-all-multiple/main.js
  13. 3
      test/function/handle-calling-uncallable/_config.js
  14. 3
      test/function/handle-calling-uncallable/foo.js
  15. 5
      test/function/handle-calling-uncallable/main.js
  16. 8
      test/function/this-not-namespace/_config.js
  17. 5
      test/function/this-not-namespace/main.js

13
CHANGELOG.md

@ -1,5 +1,18 @@
# rollup changelog
## 0.41.4
* Fix cases of multiple `export * from 'external'` declarations ([#1252](https://github.com/rollup/rollup/issues/1252))
* Fix 'TODO' error message ([#1257](https://github.com/rollup/rollup/issues/1257))
## 0.41.3
* Don't treat `this.foo` as possible namespace ([#1258](https://github.com/rollup/rollup/issues/1258))
## 0.41.2
* Optimize `namespace['foo']` references ([#1240](https://github.com/rollup/rollup/pull/1240))
## 0.41.1
* Include `new` expressions where callee is a class with side-effects ([#980](https://github.com/rollup/rollup/issues/980) [#1233](https://github.com/rollup/rollup/issues/1233))

2
package.json

@ -1,6 +1,6 @@
{
"name": "rollup",
"version": "0.41.1",
"version": "0.41.4",
"description": "Next-generation ES6 module bundler",
"main": "dist/rollup.js",
"module": "dist/rollup.es.js",

6
src/Module.js

@ -412,6 +412,12 @@ export default class Module {
}
traceExport ( name ) {
// export * from 'external'
if ( name[0] === '*' ) {
const module = this.bundle.moduleById.get( name.slice( 1 ) );
return module.traceExport( '*' );
}
// export { foo } from './other.js'
const reexportDeclaration = this.reexports[ name ];
if ( reexportDeclaration ) {

2
src/ast/nodes/MemberExpression.js

@ -33,7 +33,7 @@ export default class MemberExpression extends Node {
// TODO this code is a bit inefficient
const keypath = new Keypath( this );
if ( !keypath.computed ) {
if ( !keypath.computed && keypath.root.type === 'Identifier' ) {
let declaration = scope.findDeclaration( keypath.root.name );
while ( declaration.isNamespace && keypath.parts.length ) {

10
src/ast/nodes/shared/callHasEffects.js

@ -96,12 +96,14 @@ export default function callHasEffects ( scope, callee, isNew ) {
}
}
else {
if ( !node.gatherPossibleValues ) {
throw new Error( 'TODO' );
}
else if ( node.gatherPossibleValues ) {
node.gatherPossibleValues( values );
}
else {
// probably an error in the user's code — err on side of caution
return true;
}
}
return false;

8
test/form/export-all-multiple/_config.js

@ -0,0 +1,8 @@
module.exports = {
description: 'correctly handles multiple export * declarations (#1252)',
options: {
external: [ 'foo', 'bar', 'baz' ],
globals: { foo: 'foo', bar: 'bar', baz: 'baz' },
moduleName: 'myBundle'
}
};

11
test/form/export-all-multiple/_expected/amd.js

@ -0,0 +1,11 @@
define(['exports', 'foo', 'bar', 'baz'], function (exports, foo, bar, baz) { 'use strict';
Object.keys(foo).forEach(function (key) { exports[key] = foo[key]; });
Object.keys(bar).forEach(function (key) { exports[key] = bar[key]; });
Object.keys(baz).forEach(function (key) { exports[key] = baz[key]; });
Object.defineProperty(exports, '__esModule', { value: true });
});

13
test/form/export-all-multiple/_expected/cjs.js

@ -0,0 +1,13 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var foo = require('foo');
var bar = require('bar');
var baz = require('baz');
Object.keys(foo).forEach(function (key) { exports[key] = foo[key]; });
Object.keys(bar).forEach(function (key) { exports[key] = bar[key]; });
Object.keys(baz).forEach(function (key) { exports[key] = baz[key]; });

3
test/form/export-all-multiple/_expected/es.js

@ -0,0 +1,3 @@
export * from 'foo';
export * from 'bar';
export * from 'baz';

10
test/form/export-all-multiple/_expected/iife.js

@ -0,0 +1,10 @@
(function (exports,foo,bar,baz) {
'use strict';
Object.keys(foo).forEach(function (key) { exports[key] = foo[key]; });
Object.keys(bar).forEach(function (key) { exports[key] = bar[key]; });
Object.keys(baz).forEach(function (key) { exports[key] = baz[key]; });
}((this.myBundle = this.myBundle || {}),foo,bar,baz));

13
test/form/export-all-multiple/_expected/umd.js

@ -0,0 +1,13 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('foo'), require('bar'), require('baz')) :
typeof define === 'function' && define.amd ? define(['exports', 'foo', 'bar', 'baz'], factory) :
(factory((global.myBundle = global.myBundle || {}),global.foo,global.bar,global.baz));
}(this, (function (exports,foo,bar,baz) { 'use strict';
Object.keys(foo).forEach(function (key) { exports[key] = foo[key]; });
Object.keys(bar).forEach(function (key) { exports[key] = bar[key]; });
Object.keys(baz).forEach(function (key) { exports[key] = baz[key]; });
Object.defineProperty(exports, '__esModule', { value: true });
})));

3
test/form/export-all-multiple/main.js

@ -0,0 +1,3 @@
export * from 'foo';
export * from 'bar';
export * from 'baz';

3
test/function/handle-calling-uncallable/_config.js

@ -0,0 +1,3 @@
module.exports = {
description: 'does not give cryptic error when calling uncallable things (#1257)'
};

3
test/function/handle-calling-uncallable/foo.js

@ -0,0 +1,3 @@
function foo() {}
export default { foo };

5
test/function/handle-calling-uncallable/main.js

@ -0,0 +1,5 @@
import foo from './foo.js';
assert.throws( function () {
foo();
}, /is not a function/ );

8
test/function/this-not-namespace/_config.js

@ -0,0 +1,8 @@
const assert = require( 'assert' );
module.exports = {
description: 'does not treat this.foo as a possible namespace (#1258)',
exports: exports => {
assert.equal( typeof exports.Foo, 'function' );
}
};

5
test/function/this-not-namespace/main.js

@ -0,0 +1,5 @@
export class Foo {
constructor ( name ) {
this.name = undefined;
}
}
Loading…
Cancel
Save