Add option for ES bundling, as alternative/mode for ES index output
Take inspiration from some very clever re-naming logic in rollup that handles collisions well:
main.js:
import { hello as h1 } from "./a.js";
import { hello as h2, foo } from "./b.js";
h1();
h2();
console.log(f2);
export { foo };
a.js:
var foo = 2;
export function hello() { console.log(foo); }
b.js:
var foo = 3;
export function hello() { console.log(foo); }
export { foo }
Produces...
output.js:
var foo = 2;
function hello() { console.log(foo); }
var foo$1 = 3;
function hello$1() { console.log(foo$1); }
hello();
hello$1();
console.log(f2);
export { foo$1 as foo };
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
helloidentifiers both being exported. Unfortuantely, the warning isn't fatal, and then Rollup just drops the entire contents ofb.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?