Hacker News new | ask | show | jobs
by jsmith99 1626 days ago
Node modules are usually on the local filesystem and load quickly, whereas loading an ES6 module in a browser requires a network trip.
1 comments

Right. Working with Node.js I assume all dependencies are on the local disk. And that makes it simple and straightforward to use "require" in Node.js.

But sometimes I'd like the same code to work also in the browser. Then I should be using ES6, but it doesn't work very smoothly with Node.js and I fear there may be complications if I have to wait (or "await") for the modules to have loaded.

The ES6 "dynamic imports" add more considerations to the mix. Surely their exports can not be used until "await" is over?

I think it would simplify things if I didn't have to choose between module-systems when I really just want to choose between sync and async.