bug: ESM named export identifier conflict
This kind of code:
var publicAPI = {
something
};
module.exports.something = publicAPI.something;
function something() {}
...is transpiled to ESM format as:
var publicAPI = {
something
};
export let {
something // <---- conflict
} = publicAPI;
function something() {} // <---- conflict
The alternative named export form would have been:
let _exp1234 = publicAPI.something;
export { _exp1234 as something };
Need to check for this name conflict and use this alternate form if necessary.
References:
https://github.com/getify/moduloze/blob/0ceb03a54223207c8d2a0611cb6caedb59e322f8/src/esm.js#L424-L477
https://github.com/getify/moduloze/blob/0ceb03a54223207c8d2a0611cb6caedb59e322f8/src/analysis.js#L643-L665
So, if I understand it correctly, the esm.js already can handle both types of conversions.
But the analysis.js file is only using the "destructured-declaration-export".
A possible solution would be to add some code for checking the conflict and using the "named-declaration-export" bit ?
@vipulbhj I believe that's the case, yes. I hope that's all it is.
Will try to look into it. Thanks 😁