Open
Description
Take a look at this scenario
// a.js
exports.x = 'x';
exports.y = 'y';
// b.js
var a = require('./a.js');
console.log(a.x);
console.log(a.y);
// > x
// > y
✅ Works
Gets transpiled to:
// a.js
export var x = 'x';
export var y = 'y';
// b.js
import a from './a';
console.log(a.x);
console.log(a.y);
// > export 'default' (imported as 'a') was not found in './a'
❌ Nope.
In order to solve this you need a manual change, so:
// b.js
import { x, y } from './a';
console.log(x);
console.log(y);
// > x
// > y
✅ There we go. But again, this is a manual change.
Once I solved all those kind of issues, all the rest of safe transforms worked like a charm 👍.
I know, in order to figure out this kind of scenarios, lebab
should do a lot of extra heavy lifting and run checks of usage across files. This issue is not a feature request. Just pointing out that commonjs is not that safe, specially when using it through --replace
. Thoughts?