// es6a.js
await foo(); // takes 10 milliseconds
require('./y.js');
// es6b.js
console.log("from es6b");
// cjsa.js
const a = require("es6a.js");
const b = require("es6b.js");
- If it takes less than 10 milliseconds to retrieve es6b.js from disk, this will evaluate es6a.js, y.js, es6b.js
- If it takes more than 10 milliseconds to retrieve es6b.js, this will evaluate es6a.js, es6b.js, y.js.
In contrast, with promises (or with equivalent ES6 imports):
// cjsb.js
(async () => {
const a = await require("es6a.js");
const b = await require("es6b.js");
})
.catch(console.error);
Evaluation order will always be es6a.js, y.js, es6b.js.