ah, that form is not possible since the shape of the module needs to be known ahead of time.
Bradley Farias

I’m not sure I understand well but it looks like if the use cases you created exists since you want to requirethe commonjs module as if they were actual ES6 modules.

But my suggestion is really to take CommonJS module as what they are, a JavaScript script that exports an object (module.exports). This is why the `import {require} from ‘node:commonjs’; // bikeshed` line of your example was a const definition destructuring the exported object of the awaited async module load.

The idea is to first load all CommonJS module, with a one object export shape and then load every ES6 modules.

As soon as you do not require CommonJS module, you would just use ES6 modules and if you require CommonJS modules then you would have to use the above quirks.

That said, monkey patching `System.import` could be monkey patched to wrap CommonJS modules instead of transpiling them a priori as i suggested before. It would give a chance to add all the constant added to modules by NodeJS like `__dirname`.

Sorry to bother you, i certainly not pretend to know the subject better than you but i want to be sure we won’t miss a simple way to go ESM.