Sunday, 22 March 2020

Status of ES modules?

In the latest node version what is --experimental-modules for? I thought you can use modules already out of the box by setting "type": "module" in package.json?I'm converting all my code from require to import but realized there's a couple of places where I call require dynamically. Unfortunately dynamic calls to require aren't supported with import. Is there any way to make a few dynamic calls to require work even though I've set "type": "module"?I remember there being a dynamic import() function that was going to be added to node, but I don't see it anywhere on https://node.green/. Where can I see the status of this for the ES spec or implementation in node? Is using Babel the only way to get import() to work today?I want to avoid preprocessors for server side code so if Babel is the only way to do this I'll stick with require until dynamic import() becomes available in node.

Submitted March 22, 2020 at 09:29PM by nowboarding

No comments:

Post a Comment