diff --git a/src/Bundle.js b/src/Bundle.js index a9885c4..ad81803 100644 --- a/src/Bundle.js +++ b/src/Bundle.js @@ -345,7 +345,7 @@ export default class Bundle { findParent( this.entryModule ); - throw new Error( + this.onwarn( `Module ${a.id} may be unable to evaluate without ${b.id}, but is included first due to a cyclical dependency. Consider swapping the import statements in ${parent} to ensure correct ordering` ); } diff --git a/test/function/cycles-pathological/_config.js b/test/function/cycles-pathological/_config.js index 156a2f3..4e939af 100644 --- a/test/function/cycles-pathological/_config.js +++ b/test/function/cycles-pathological/_config.js @@ -1,18 +1,17 @@ var assert = require( 'assert' ); +var warned; + module.exports = { description: 'resolves pathological cyclical dependencies gracefully', babel: true, - exports: function ( exports ) { - assert.ok( exports.a.isA ); - assert.ok( exports.b1.isA ); - assert.ok( exports.b1.isB ); - assert.ok( exports.b2.isA ); - assert.ok( exports.b2.isB ); - assert.ok( exports.c1.isC ); - assert.ok( exports.c1.isD ); - assert.ok( exports.c2.isC ); - assert.ok( exports.c2.isD ); - assert.ok( exports.d.isD ); + options: { + onwarn: function ( message ) { + assert.ok( /Module .+B\.js may be unable to evaluate without .+A\.js, but is included first due to a cyclical dependency. Consider swapping the import statements in .+main\.js to ensure correct ordering/.test( message ) ); + warned = true; + } + }, + runtimeError: function () { + assert.ok( warned ); } }; diff --git a/test/function/iife-strong-dependencies/_config.js b/test/function/iife-strong-dependencies/_config.js index 10cdaca..f1d7ee1 100644 --- a/test/function/iife-strong-dependencies/_config.js +++ b/test/function/iife-strong-dependencies/_config.js @@ -1,15 +1,16 @@ var assert = require( 'assert' ); +var warned; + module.exports = { description: 'does not treat references inside IIFEs as weak dependencies', // edge case encountered in THREE.js codebase - exports: function ( exports ) { - assert.ok( exports.a1.isA ); - assert.ok( exports.b1.isB ); - assert.ok( exports.c1.isC ); - assert.ok( exports.d1.isD ); - assert.ok( exports.a2.isA ); - assert.ok( exports.b2.isB ); - assert.ok( exports.c2.isC ); - assert.ok( exports.d2.isD ); + options: { + onwarn: function ( message ) { + assert.ok( /Module .+D\.js may be unable to evaluate without .+C\.js, but is included first due to a cyclical dependency. Consider swapping the import statements in .+main\.js to ensure correct ordering/.test( message ) ); + warned = true; + } + }, + runtimeError: function () { + assert.ok( warned ); } };