Open getify opened 4 years ago
Also interesting issues to address differently from how Rollup behaves:
How to handle name conflicts when re-naming won't work? Rollup issues a warning and just drops the duplicate stuff (via tree shaking, I guess?)?
main.js
:
export * from "./a.js";
export * from "./b.js";
a.js
:
var foo = 2;
export function hello() { console.log(foo); }
b.js
:
var foo = 3;
export function hello() { console.log(foo * 2); }
Rollup does issue a warning that there's a collision between the two hello
identifiers both being exported. Unfortuantely, the warning isn't fatal, and then Rollup just drops the entire contents of b.js
(tree shaking, I assume?):
var foo = 2;
function hello() { console.log(foo); }
export { hello };
How to just stitch two peer modules together without some main entry-point module that "re-exports" them?
main.js
:
var foo = 2;
export function hello() { console.log(foo); }
a.js
:
var foo = 3;
export function hello2() { console.log(foo * 2); }
Unfortunately, Rollup expects a main entry-point module, so (via tree shaking?) produces just this:
var foo = 2;
function hello() { console.log(foo); }
export { hello };
This emphasizes that Moduloze provides better for this use-case than Rollup, in that Moduloze (not relying on tree-shaking) doesn't require a single entry-point file to key off of, it just bundles a tree of peer files together.
TBF, while Rollup doesn't support this directly, there's a plugin that seems to do so: multi-entry.
I am interested in this feature. Is there anything I can help with to get this done?
Take inspiration from some very clever re-naming logic in rollup that handles collisions well:
main.js
:a.js
:b.js
:Produces...
output.js
: