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

Properly render dynamic imports when imported module is empty #2714

Merged
merged 1 commit into from Feb 23, 2019
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
2 changes: 1 addition & 1 deletion src/Chunk.ts
Expand Up @@ -382,7 +382,7 @@ export default class Chunk {
for (const { node, resolution } of module.dynamicImports) {
if (!resolution) continue;
if (resolution instanceof Module) {
if (resolution.isIncluded() && resolution.chunk !== this) {
if (!resolution.chunk.isEmpty && resolution.chunk !== this) {
const resolutionChunk = resolution.facadeChunk || resolution.chunk;
let relPath = normalize(relative(dirname(this.id), resolutionChunk.id));
if (!relPath.startsWith('../')) relPath = './' + relPath;
Expand Down
@@ -0,0 +1,6 @@
module.exports = {
description: 'handles dynamic imports when the imported module only reexports from other modules',
options: {
input: ['main']
}
};
@@ -0,0 +1,7 @@
define(['exports'], function (exports) { 'use strict';

const value = 42;

exports.value = value;

});
@@ -0,0 +1,5 @@
define(['require'], function (require) { 'use strict';

new Promise(function (resolve, reject) { require(['./generated-chunk.js'], resolve, reject) }).then(({ value }) => console.log(value));

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

const value = 42;

exports.value = value;
@@ -0,0 +1,3 @@
'use strict';

Promise.resolve(require('./generated-chunk.js')).then(({ value }) => console.log(value));
@@ -0,0 +1,3 @@
const value = 42;

export { value };
@@ -0,0 +1 @@
import('./generated-chunk.js').then(({ value }) => console.log(value));
@@ -0,0 +1,10 @@
System.register([], function (exports, module) {
'use strict';
return {
execute: function () {

const value = exports('value', 42);

}
};
});
@@ -0,0 +1,10 @@
System.register([], function (exports, module) {
'use strict';
return {
execute: function () {

module.import('./generated-chunk.js').then(({ value }) => console.log(value));

}
};
});
@@ -0,0 +1 @@
export const value = 42;
@@ -0,0 +1 @@
export {value} from './dep';
@@ -0,0 +1 @@
import('./dynamic').then(({ value }) => console.log(value));