Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not fail for circular imports between manual chunks #3510

Merged
merged 1 commit into from
Apr 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Chunk.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
description: 'handles manual chunks with circular dependencies',
expectedWarnings: ['CIRCULAR_DEPENDENCY'],
options: {
input: 'main',
manualChunks: { lib1: ['lib1'], lib2: ['lib2'] }
}
};
Original file line number Diff line number Diff line change
@@ -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;

});
Original file line number Diff line number Diff line change
@@ -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;

});
Original file line number Diff line number Diff line change
@@ -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 });

});
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict';

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

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

exports.lib1 = lib1;
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict';

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

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

exports.lib2 = lib2;
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { l as lib2 } from './generated-lib2.js';

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

export { lib1 as l };
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { l as lib1 } from './generated-lib1.js';

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

export { lib2 as l };
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import './generated-lib2.js';
export { l as lib1 } from './generated-lib1.js';
Original file line number Diff line number Diff line change
@@ -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}`);

}
};
});
Original file line number Diff line number Diff line change
@@ -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}`);

}
};
});
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { lib1 } from './lib1.js';