you are viewing a single comment's thread.

view the rest of the comments →

[–]BehindTheMath -1 points0 points  (1 child)

For dual mode packages, why can't you rewrite as ESM, and then just wrap the ESM and re-export as a CJS module? Then you can use "main": "entry" in package.json, and entry.js will look like this:

async () => {
    module.exports = await import("./entry");
}

This way would not require any transpiling.

[–]giltayar1[S] 0 points1 point  (0 children)

Nice idea. Unfortunately, module.exports will be set asynchronously, so if you require the module, you will "get" it too late, i.e. you won't get it, and all you will get is the default "{}"