Source code is written as:
export async function run() {
const myLib = await import("some-lib");
}
run();However output for CJS is:
//#region src/index.ts
async function run() {
await import("some-lib");
}
run();
//#endregion
exports.run = run;I would expect the dynamic import to be rewritten as a dynamic require:
//#region src/index.ts
async function run() {
require("some-lib");
}
run();
//#endregion
exports.run = run;I was able to work around it in a hacky way by adding a plugin, but this doesn't feel like the way to resolve this.
plugins: [
{
name: "import-require",
transform: (code) => {
return code.replaceAll(" await import(", " require(");
},
},
];The dist folder is included. But you can run yarn install (optionally corepack enable) and then yarn tsdown