Skip to content

Commit

Permalink
Fix handling of namespace reexports when preserving modules
Browse files Browse the repository at this point in the history
  • Loading branch information
lukastaegert committed Dec 23, 2022
1 parent 1243370 commit 22283f4
Show file tree
Hide file tree
Showing 18 changed files with 91 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Chunk.ts
Expand Up @@ -782,6 +782,9 @@ export default class Chunk {
continue;
}
const chunkDep = this.renderedDependencies!.get(chunk)!;
if (!chunkDep) {
continue;
}
const { imports, reexports } = chunkDep;
const importedByReexported = reexports?.find(
({ reexported }) => reexported === exportName
Expand Down
@@ -0,0 +1,8 @@
module.exports = {
description: 'handles doing a namespace reexport of a reexport',
options: {
output: {
preserveModules: true
}
}
};
@@ -0,0 +1,7 @@
define(['exports'], (function (exports) { 'use strict';

const value = 'foo';

exports.value = value;

}));
@@ -0,0 +1,5 @@
define(['./reexport', './dep'], (function (reexport, dep) { 'use strict';

console.log(dep.value);

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

console.log('reexport');

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

const value = 'foo';

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

require('./reexport.js');
var dep = require('./dep.js');

console.log(dep.value);
@@ -0,0 +1,3 @@
'use strict';

console.log('reexport');
@@ -0,0 +1,3 @@
const value = 'foo';

export { value };
@@ -0,0 +1,4 @@
import './reexport.js';
import { value } from './dep.js';

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

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

})
};
}));
@@ -0,0 +1,14 @@
System.register(['./reexport.js', './dep.js'], (function () {
'use strict';
var value;
return {
setters: [null, function (module) {
value = module.value;
}],
execute: (function () {

console.log(value);

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

console.log('reexport');

})
};
}));
@@ -0,0 +1 @@
export const value = 'foo';
@@ -0,0 +1,3 @@
import { value } from './reexport2';

console.log(value);
@@ -0,0 +1,2 @@
export { value } from './dep.js';
console.log('reexport');
@@ -0,0 +1 @@
export * from './reexport.js';

0 comments on commit 22283f4

Please sign in to comment.