How to build in a way that every client component is stored in its own file? #7
-
I have the following folder structure src
- category-1
- component-1.tsx
- component-2.tsx # starts with "use client";
- ...
- category-2
- component-n.tsx
- ...
- category-n
- ...
- index.ts # exporting all components And the following import { defineConfig } from "tsup";
import reactUseClient from "esbuild-react18-useclient";
export default defineConfig((options) => ({
dts: true,
entry: ["src/**/*.tsx", "src/index.ts"],
esbuildPlugins: [reactUseClient],
external: ["react"],
format: ["esm"],
minify: !options.watch,
})); With this setup I get every component in its own file in the dist
- category-1
- component-1.d.ts
- component-1.mjs
- component-2.d.ts
- component-2.mjs
- ...
- category-2
- component-n.d.ts
- component-n.mjs
- ...
- category-n
- ...
- chunk-1.mjs
- chunk-2.mjs
- chunk-n.mjs
- index.d.ts
- index.js BUT the Disclaimer: I'm totally new to tsup and am not even sure, if this is an issue with the plugin or rather with tsup/esbuild itself. Please let me know, if this is the wrong place to ask this question. :) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hi, thanks for reaching out. Could you please share a link to a repo containing a minimum reproducible example. Also, I recommend you to use (turborepo-template)[https://github.com/react18-tools/turborepo-template/] that uses |
Beta Was this translation helpful? Give feedback.
Your
tsup
version is outdated. Please use latest dependencies. Upgrade dependencies by runningpnpm update --latest
. Or use version 8+ fortsup
.