egoist / tsup

The simplest and fastest way to bundle your TypeScript libraries.
https://tsup.egoist.dev
MIT License
8.46k stars 209 forks source link

`.mjs` files getting automatically renamed after build #1132

Open musjj opened 1 month ago

musjj commented 1 month ago

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?

Upvote & Fund

Fund with Polar