Browse Source

treat missing relative imports as error not warning - fixes #321

gh-335
Rich-Harris 9 years ago
parent
commit
6752951d96
  1. 1
      src/Bundle.js
  2. 8
      test/function/no-relative-external/_config.js
  3. 1
      test/function/no-relative-external/main.js

1
src/Bundle.js

@ -161,6 +161,7 @@ export default class Bundle {
return Promise.resolve( this.resolveId( source, module.id ) )
.then( resolvedId => {
if ( !resolvedId ) {
if ( source[0] === '.' ) throw new Error( `Could not resolve ${source} from ${module.id}` );
if ( !~this.external.indexOf( source ) ) this.onwarn( `Treating '${source}' as external dependency` );
module.resolvedIds[ source ] = source;

8
test/function/no-relative-external/_config.js

@ -0,0 +1,8 @@
var assert = require( 'assert' );
module.exports = {
description: 'missing relative imports are an error, not a warning',
error: function ( err ) {
assert.ok( /Could not resolve \.\/missing\.js from/.test( err.message ) );
}
};

1
test/function/no-relative-external/main.js

@ -0,0 +1 @@
import missing from './missing.js';
Loading…
Cancel
Save