Browse Source

Merge branch 'rberner-master'

rollup-init
Rich-Harris 9 years ago
parent
commit
df504b5876
  1. 5
      src/Module.js
  2. 3
      test/form/comment-before-import/_config.js
  3. 12
      test/form/comment-before-import/_expected/amd.js
  4. 10
      test/form/comment-before-import/_expected/cjs.js
  5. 8
      test/form/comment-before-import/_expected/es.js
  6. 13
      test/form/comment-before-import/_expected/iife.js
  7. 16
      test/form/comment-before-import/_expected/umd.js
  8. 2
      test/form/comment-before-import/bar.js
  9. 4
      test/form/comment-before-import/foo.js
  10. 4
      test/form/comment-before-import/main.js

5
src/Module.js

@ -452,6 +452,11 @@ export default class Module {
this.statements.forEach( statement => {
if ( !statement.isIncluded ) {
if ( statement.node.type === 'ImportDeclaration' ) {
magicString.remove( statement.node.start, statement.next );
return;
}
magicString.remove( statement.start, statement.next );
return;
}

3
test/form/comment-before-import/_config.js

@ -0,0 +1,3 @@
module.exports = {
description: 'preserves comments before imports'
};

12
test/form/comment-before-import/_expected/amd.js

@ -0,0 +1,12 @@
define(function () { 'use strict';
// bar.js
var bar = 21;
// foo.js
var foo = bar * 2;
// main.js
console.log( foo );
});

10
test/form/comment-before-import/_expected/cjs.js

@ -0,0 +1,10 @@
'use strict';
// bar.js
var bar = 21;
// foo.js
var foo = bar * 2;
// main.js
console.log( foo );

8
test/form/comment-before-import/_expected/es.js

@ -0,0 +1,8 @@
// bar.js
var bar = 21;
// foo.js
var foo = bar * 2;
// main.js
console.log( foo );

13
test/form/comment-before-import/_expected/iife.js

@ -0,0 +1,13 @@
(function () {
'use strict';
// bar.js
var bar = 21;
// foo.js
var foo = bar * 2;
// main.js
console.log( foo );
}());

16
test/form/comment-before-import/_expected/umd.js

@ -0,0 +1,16 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory() :
typeof define === 'function' && define.amd ? define(factory) :
(factory());
}(this, (function () { 'use strict';
// bar.js
var bar = 21;
// foo.js
var foo = bar * 2;
// main.js
console.log( foo );
})));

2
test/form/comment-before-import/bar.js

@ -0,0 +1,2 @@
// bar.js
export default 21;

4
test/form/comment-before-import/foo.js

@ -0,0 +1,4 @@
// foo.js
import bar from './bar.js';
export default bar * 2;

4
test/form/comment-before-import/main.js

@ -0,0 +1,4 @@
// main.js
import foo from './foo.js';
console.log( foo );
Loading…
Cancel
Save