Skip to content

Commit

Permalink
Do not fail for circular imports between manual chunks (#3510)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukastaegert committed Apr 22, 2020
1 parent 925d302 commit f65bae1
Show file tree
Hide file tree
Showing 17 changed files with 124 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Chunk.ts
Expand Up @@ -914,6 +914,7 @@ export default class Chunk {

private inlineChunkDependencies(chunk: Chunk) {
for (const dep of chunk.dependencies) {
if (this.dependencies.has(dep)) continue;
if (dep instanceof ExternalModule) {
this.dependencies.add(dep);
} else {
Expand Down
8 changes: 8 additions & 0 deletions test/chunking-form/samples/circular-manual-chunks/_config.js
@@ -0,0 +1,8 @@
module.exports = {
description: 'handles manual chunks with circular dependencies',
expectedWarnings: ['CIRCULAR_DEPENDENCY'],
options: {
input: 'main',
manualChunks: { lib1: ['lib1'], lib2: ['lib2'] }
}
};
@@ -0,0 +1,8 @@
define(['exports', './generated-lib2'], function (exports, lib2) { 'use strict';

const lib1 = 'lib1';
console.log(`${lib1} imports ${lib2.lib2}`);

exports.lib1 = lib1;

});
@@ -0,0 +1,8 @@
define(['exports', './generated-lib1'], function (exports, lib1) { 'use strict';

const lib2 = 'lib2';
console.log(`${lib2} imports ${lib1.lib1}`);

exports.lib2 = lib2;

});
@@ -0,0 +1,9 @@
define(['exports', './generated-lib2', './generated-lib1'], function (exports, lib2, lib1) { 'use strict';



exports.lib1 = lib1.lib1;

Object.defineProperty(exports, '__esModule', { value: true });

});
@@ -0,0 +1,8 @@
'use strict';

var lib2 = require('./generated-lib2.js');

const lib1 = 'lib1';
console.log(`${lib1} imports ${lib2.lib2}`);

exports.lib1 = lib1;
@@ -0,0 +1,8 @@
'use strict';

var lib1 = require('./generated-lib1.js');

const lib2 = 'lib2';
console.log(`${lib2} imports ${lib1.lib1}`);

exports.lib2 = lib2;
@@ -0,0 +1,10 @@
'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

require('./generated-lib2.js');
var lib1 = require('./generated-lib1.js');



exports.lib1 = lib1.lib1;
@@ -0,0 +1,6 @@
import { l as lib2 } from './generated-lib2.js';

const lib1 = 'lib1';
console.log(`${lib1} imports ${lib2}`);

export { lib1 as l };
@@ -0,0 +1,6 @@
import { l as lib1 } from './generated-lib1.js';

const lib2 = 'lib2';
console.log(`${lib2} imports ${lib1}`);

export { lib2 as l };
@@ -0,0 +1,2 @@
import './generated-lib2.js';
export { l as lib1 } from './generated-lib1.js';
@@ -0,0 +1,15 @@
System.register(['./generated-lib2.js'], function (exports) {
'use strict';
var lib2;
return {
setters: [function (module) {
lib2 = module.l;
}],
execute: function () {

const lib1 = exports('l', 'lib1');
console.log(`${lib1} imports ${lib2}`);

}
};
});
@@ -0,0 +1,15 @@
System.register(['./generated-lib1.js'], function (exports) {
'use strict';
var lib1;
return {
setters: [function (module) {
lib1 = module.l;
}],
execute: function () {

const lib2 = exports('l', 'lib2');
console.log(`${lib2} imports ${lib1}`);

}
};
});
@@ -0,0 +1,13 @@
System.register(['./generated-lib2.js', './generated-lib1.js'], function (exports) {
'use strict';
return {
setters: [function () {}, function (module) {
exports('lib1', module.l);
}],
execute: function () {



}
};
});
3 changes: 3 additions & 0 deletions test/chunking-form/samples/circular-manual-chunks/lib1.js
@@ -0,0 +1,3 @@
import { lib2 } from './lib2.js';
export const lib1 = 'lib1';
console.log(`${lib1} imports ${lib2}`);
3 changes: 3 additions & 0 deletions test/chunking-form/samples/circular-manual-chunks/lib2.js
@@ -0,0 +1,3 @@
import { lib1 } from './lib1';
export const lib2 = 'lib2';
console.log(`${lib2} imports ${lib1}`);
1 change: 1 addition & 0 deletions test/chunking-form/samples/circular-manual-chunks/main.js
@@ -0,0 +1 @@
export { lib1 } from './lib1.js';

0 comments on commit f65bae1

Please sign in to comment.