I'm having a really weird issue where my .mjs
files gets renamed to .js
after tsup finishes building.
My tsup.config.ts
:
import { defineConfig, type Options } from "tsup";
export default defineConfig((options: Options) => ({
clean: true,
format: ["esm"],
...options,
}));
It goes like this:
$ tsup --onSuccess "ls dist" src # This will list files in dist/ after building
CLI Building entry: src/index.ts
CLI Using tsconfig: tsconfig.json
CLI tsup v8.0.2
CLI Using tsup config: ...
CLI Target: es2022
CLI Cleaning output folder
ESM Build start
ESM dist/index.mjs 743.75 KB
ESM ⚡️ Build success in 46ms
index.mjs # <-- Note the .mjs extension
$ ls dist
index.js
The file is mysteriously renamed. So when you do:
$ tsup --onSuccess "node dist/index.mjs" src
It will fail because the file is no longer there. node dist/index.js
doesn't work either, so I suspect there is a small window where the file just doesn't exist. Does anyone know why this is happening?
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too