Here is how to run the demo after you download the zip file containing this gist.
$ node main.mjs
[Function: foo] [Function: foo] [Function: bar] [Function: bar]
$ 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]