Browse Source

warn on empty bundle (#444), and remove some tests that are no longer testing anything

gh-786
Rich-Harris 8 years ago
parent
commit
5f8205e8be
  1. 4
      src/Bundle.js
  2. 9
      test/function/assign-namespace-to-var/_config.js
  3. 6
      test/function/consistent-renaming/main.js
  4. 3
      test/function/cycles-pathological-3/_config.js
  5. 3
      test/function/cycles-pathological-3/a.js
  6. 3
      test/function/cycles-pathological-3/b.js
  7. 3
      test/function/cycles-pathological-3/c.js
  8. 1
      test/function/cycles-pathological-3/main.js
  9. 2
      test/function/cycles-pathological-3/x.a.js
  10. 2
      test/function/cycles-pathological-3/x.b.js
  11. 2
      test/function/cycles-pathological-3/x.c.js
  12. 19
      test/function/empty-exports/_config.js
  13. 3
      test/function/handles-multiple-declarations/_config.js
  14. 2
      test/function/handles-multiple-declarations/main.js
  15. 5
      test/function/module-tree/_config.js
  16. 10
      test/function/warn-on-empty-bundle/_config.js
  17. 2
      test/function/warn-on-empty-bundle/main.js

4
src/Bundle.js

@ -377,6 +377,10 @@ export default class Bundle {
} }
}); });
if ( !magicString.toString().trim() && this.entryModule.getExports().length === 0 ) {
this.onwarn( 'Generated an empty bundle' );
}
timeEnd( 'render modules' ); timeEnd( 'render modules' );
let intro = [ options.intro ] let intro = [ options.intro ]

9
test/function/assign-namespace-to-var/_config.js

@ -1,3 +1,10 @@
const assert = require( 'assert' );
module.exports = { module.exports = {
description: 'allows a namespace to be assigned to a variable' description: 'allows a namespace to be assigned to a variable',
warnings: warnings => {
assert.deepEqual( warnings, [
'Generated an empty bundle'
]);
}
}; };

6
test/function/consistent-renaming/main.js

@ -1,3 +1,7 @@
import { one as oneRenamed } from './one'; import { one as oneRenamed } from './one';
import { two } from './two'; import { two } from './two';
import { three as threeRenamed } from './three'; import { three as threeRenamed } from './three';
assert.equal( oneRenamed, 1 );
assert.equal( two, 2 );
assert.equal( threeRenamed, 3 );

3
test/function/cycles-pathological-3/_config.js

@ -1,3 +0,0 @@
module.exports = {
description: 'resolves more pathological cyclical dependencies gracefully'
};

3
test/function/cycles-pathological-3/a.js

@ -1,3 +0,0 @@
import * as x from "./x.a.js";
x.b();
x.c();

3
test/function/cycles-pathological-3/b.js

@ -1,3 +0,0 @@
import * as x from "./x.b.js";
export function b() {}

3
test/function/cycles-pathological-3/c.js

@ -1,3 +0,0 @@
import * as x from "./x.c.js";
export function c() {}

1
test/function/cycles-pathological-3/main.js

@ -1 +0,0 @@
import './a.js';

2
test/function/cycles-pathological-3/x.a.js

@ -1,2 +0,0 @@
export * from "./b.js";
export * from "./c.js";

2
test/function/cycles-pathological-3/x.b.js

@ -1,2 +0,0 @@
export * from "./a.js";
export * from "./c.js";

2
test/function/cycles-pathological-3/x.c.js

@ -1,2 +0,0 @@
export * from "./a.js";
export * from "./b.js";

19
test/function/empty-exports/_config.js

@ -1,17 +1,12 @@
var assert = require( 'assert' ); const assert = require( 'assert' );
const path = require( 'path' );
var warned = false;
module.exports = { module.exports = {
description: 'warns on export {}, but does not fail', description: 'warns on export {}, but does not fail',
options: { warnings: warnings => {
onwarn: function ( msg ) { assert.deepEqual( warnings, [
warned = true; `Module ${path.resolve( __dirname, 'main.js' )} has an empty export declaration`,
assert.ok( /main\.js has an empty export declaration/.test( msg ) ); 'Generated an empty bundle'
} ]);
},
exports: function ( exports ) {
assert.equal( Object.keys( exports ).length, 0 );
assert.ok( warned, 'did not warn' );
} }
}; };

3
test/function/handles-multiple-declarations/_config.js

@ -1,3 +0,0 @@
module.exports = {
description: 'handles multiple declaration blocks with multiple declarations (#105)'
};

2
test/function/handles-multiple-declarations/main.js

@ -1,2 +0,0 @@
var a, b;
var c, d;

5
test/function/module-tree/_config.js

@ -33,5 +33,10 @@ module.exports = {
dependencies: [ 'foo.js', 'bar.js' ] dependencies: [ 'foo.js', 'bar.js' ]
} }
]); ]);
},
warnings: warnings => {
assert.deepEqual( warnings, [
'Generated an empty bundle'
]);
} }
}; };

10
test/function/warn-on-empty-bundle/_config.js

@ -0,0 +1,10 @@
const assert = require( 'assert' );
module.exports = {
description: 'warns if empty bundle is generated (#444)',
warnings: warnings => {
assert.deepEqual( warnings, [
'Generated an empty bundle'
]);
}
};

2
test/function/warn-on-empty-bundle/main.js

@ -0,0 +1,2 @@
function noop () {}
noop();
Loading…
Cancel
Save