esmoduleserve icon indicating copy to clipboard operation
esmoduleserve copied to clipboard

Support non-esm modules

Open kapouer opened this issue 5 years ago • 8 comments

The simplicity of it is so cool. It's a proof-of-concept however - i'm a noobie w.r.t. acorn.

kapouer avatar Jan 08 '21 21:01 kapouer

Did github mangle the (code.charAt(ast.start) == "" ? "" : "") expressions or is there something I don't understand going on there?

marijnh avatar Jan 08 '21 21:01 marijnh

Not github, me - to be able to diff i removed semicolons too agressively.

kapouer avatar Jan 08 '21 22:01 kapouer

That should fix it

kapouer avatar Jan 08 '21 22:01 kapouer

I don't expect these PR to be accepted right away - please consider them as inspiration, if that's not too much to ask :)

kapouer avatar Jan 08 '21 22:01 kapouer

What do you want to do with require calls?

marijnh avatar Jan 10 '21 18:01 marijnh

Nothing: most front-end modules come in a single require-able bundle, so exporting module.exports using that patch, es6-style, is just enough to be able to import the npm-installed bundled module.

kapouer avatar Jan 10 '21 18:01 kapouer

Though replacing require x by import from x would be elegant but i fear the hidden complexities.

kapouer avatar Jan 10 '21 18:01 kapouer

most front-end modules come in a single require-able bundle

In my experience the concept of dependencies is definitely also used in many front-end modules. So shipping a solution that just ignores that doesn't feel very reasonable. (I intentionally didn't provide any support for non-ES modules initially because I'm not that interested in being pulled into the morass of trying to make this work.)

marijnh avatar Jan 11 '21 10:01 marijnh