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. 4
      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' );
let intro = [ options.intro ]

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

@ -1,3 +1,10 @@
const assert = require( 'assert' );
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'
]);
}
};

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

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

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' ]
}
]);
},
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