3 ms·
Can anybody explain to me why ES didn't simply adopt the require syntax from Node.js?
by pvorb 8y ago
Can anybody explain to me why ES didn't simply adopt the require syntax from Node.js?
- yuchi 8y agoImport statements must be asynchronous in the latency-controlled environments (mostly browsers). CJS is by definition synchronous and has different order semantics when treating execution of an asynchronous loader.
- pvorb 8y agoBut it could simply be implemented using the same routine in browsers like `import`. I don't see why `require` can't be asynchronous. There's an implicit join after the last import. Maybe it would have been enough to restrict calls to `require` to the top of a file.