egoist / tsup

The simplest and fastest way to bundle your TypeScript libraries.

Home Page:https://tsup.egoist.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`.mjs` files getting automatically renamed after build

musjj opened this issue · comments

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

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar