Browse Source

Merge pull request #566 from rollup/ghi-565

Rewrite an entire member expression for namespace imports.
gh-669
Brian Donovan 9 years ago
parent
commit
f3aca11a85
  1. 3
      src/Declaration.js
  2. 3
      test/form/whitespace-around-namespace-member-expression/_config.js
  3. 9
      test/form/whitespace-around-namespace-member-expression/_expected/amd.js
  4. 7
      test/form/whitespace-around-namespace-member-expression/_expected/cjs.js
  5. 5
      test/form/whitespace-around-namespace-member-expression/_expected/es6.js
  6. 10
      test/form/whitespace-around-namespace-member-expression/_expected/iife.js
  7. 13
      test/form/whitespace-around-namespace-member-expression/_expected/umd.js
  8. 3
      test/form/whitespace-around-namespace-member-expression/foo.js
  9. 2
      test/form/whitespace-around-namespace-member-expression/main.js

3
src/Declaration.js

@ -196,8 +196,7 @@ export class SyntheticNamespaceDeclaration {
// the reference by pointing directly to `bar` // the reference by pointing directly to `bar`
if ( reference.parts.length ) { if ( reference.parts.length ) {
reference.name = reference.parts.shift(); reference.name = reference.parts.shift();
reference.end = reference.node.end;
reference.end += reference.name.length + 1; // TODO this is brittle
const original = this.originals[ reference.name ]; const original = this.originals[ reference.name ];

3
test/form/whitespace-around-namespace-member-expression/_config.js

@ -0,0 +1,3 @@
module.exports = {
description: 'whitespace around the "." in member expressions does not mess up renaming'
};

9
test/form/whitespace-around-namespace-member-expression/_expected/amd.js

@ -0,0 +1,9 @@
define(function () { 'use strict';
function yar() {
console.log('yar?');
}
yar();
});

7
test/form/whitespace-around-namespace-member-expression/_expected/cjs.js

@ -0,0 +1,7 @@
'use strict';
function yar() {
console.log('yar?');
}
yar();

5
test/form/whitespace-around-namespace-member-expression/_expected/es6.js

@ -0,0 +1,5 @@
function yar() {
console.log('yar?');
}
yar();

10
test/form/whitespace-around-namespace-member-expression/_expected/iife.js

@ -0,0 +1,10 @@
(function () {
'use strict';
function yar() {
console.log('yar?');
}
yar();
}());

13
test/form/whitespace-around-namespace-member-expression/_expected/umd.js

@ -0,0 +1,13 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory() :
typeof define === 'function' && define.amd ? define(factory) :
(factory());
}(this, function () { 'use strict';
function yar() {
console.log('yar?');
}
yar();
}));

3
test/form/whitespace-around-namespace-member-expression/foo.js

@ -0,0 +1,3 @@
export function yar() {
console.log('yar?');
}

2
test/form/whitespace-around-namespace-member-expression/main.js

@ -0,0 +1,2 @@
import * as foo from './foo.js';
foo .yar();
Loading…
Cancel
Save