Skip to content

Instantly share code, notes, and snippets.

@jfparadis
Created February 28, 2020 04:24
Show Gist options
  • Save jfparadis/b708db69f1915053035a4f3c435f8727 to your computer and use it in GitHub Desktop.
Save jfparadis/b708db69f1915053035a4f3c435f8727 to your computer and use it in GitHub Desktop.

Rollup demo

Here is how to run the demo after you download the zip file containing this gist.

Native ESM

$ node main.mjs
[Function: foo] [Function: foo] [Function: bar] [Function: bar]

Via Rollup

$ npx rollup --format=esm --file=bundle.mjs -- main.mjs
main.mjs → bundle.mjs...
created bundle.mjs in 30ms
$ node bundle.mjs
[Function: foo] [Function: foo$1] [Function: bar] [Function: bar$1]
// a.mjs
const foo = () => {};
export { foo };
export function bar() { }
// b.mjs
const foo = () => {};
export { foo };
export function bar() { }
// a.js
const foo = () => {};
function bar() { }
// b.js
const foo$1 = () => {};
function bar$1() { }
// main.js
console.log(foo, foo$1, bar, bar$1);
// main.mjs
import { foo as afoo, bar as abar } from "./a.mjs"
import { foo as bfoo, bar as bbar } from "./b.mjs"
console.log(afoo, bfoo, abar, bbar);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment