|
1 | | -// import { copy } from "esbuild-plugin-copy"; |
2 | 1 | import { defineConfig } from "tsup"; |
3 | | -// import typiaPlug from "@ryoppippi/unplugin-typia/esbuild"; |
| 2 | +import copy from "esbuild-plugin-copy"; |
| 3 | +import { addNodeRequireShim } from "./internals"; |
4 | 4 |
|
5 | | -export default defineConfig({ |
6 | | - // entry: ["src/index.ts", "src/bin/app.ts"], |
7 | | - entry: ["src/index.ts"], |
8 | | - target: "es2020", |
9 | | - clean: true, |
10 | | - format: ["esm"], |
11 | | - // noExternal: ["typia"], |
| 5 | +//---------------------- |
| 6 | +// Functions |
| 7 | +//---------------------- |
12 | 8 |
|
13 | | - // esbuildPlugins: [ |
14 | | - // typiaPlug({ tsconfig: "./tsconfig.json", cache: false }), |
15 | | - // copy({ |
16 | | - // assets: [ |
17 | | - // { from: "./package.json", to: "./package.json" }, |
18 | | - // { from: "./.npmrc", to: "./.npmrc" }, |
19 | | - // { from: "./.npmignore", to: "./.npmignore" }, |
20 | | - // { from: "./README.md", to: "./README.md" }, |
21 | | - // { from: "./src/templates/configs/*", to: "./templates/configs" } |
22 | | - // ] |
23 | | - // }) |
24 | | - // ], |
25 | | - banner: ({ format }) => { |
26 | | - if (format === "esm") { |
27 | | - const banner = ` |
28 | | -import { createRequire } from "node:module"; |
29 | | -const require = createRequire(import.meta.url); |
30 | | - `; |
31 | | - |
32 | | - return { js: banner }; |
| 9 | +/** @internal */ |
| 10 | +export const BasicConfig = (isDev: boolean) => |
| 11 | + ({ |
| 12 | + METAFILES_TO_COPY: isDev |
| 13 | + ? {} |
| 14 | + : { |
| 15 | + entry: ["src/index.ts"], |
| 16 | + plugins: [ |
| 17 | + copy({ |
| 18 | + assets: [ |
| 19 | + { from: "./package.json", to: "./package.json" }, |
| 20 | + { from: "./.npmrc", to: "./.npmrc" }, |
| 21 | + { from: "./.npmignore", to: "./.npmignore" }, |
| 22 | + { from: "./README.md", to: "./README.md" } |
| 23 | + // { from: "./src/templates/configs/*", to: "./templates/configs" } |
| 24 | + ] |
| 25 | + }) |
| 26 | + ] |
| 27 | + }, |
| 28 | + CLI_APP: { |
| 29 | + entry: ["src/bin/app.ts"], |
| 30 | + outDir: `${isDev ? "lib" : "dist"}/bin`, |
| 31 | + target: "esnext", |
| 32 | + banner: addNodeRequireShim, |
| 33 | + watch: isDev ? ["src"] : false |
| 34 | + }, |
| 35 | + PACKAGE: { |
| 36 | + entry: ["src/index.ts"], |
| 37 | + outDir: isDev ? "lib" : "dist", |
| 38 | + target: "es2020", |
| 39 | + banner: addNodeRequireShim, |
| 40 | + watch: isDev ? ["src"] : false |
33 | 41 | } |
34 | | - } |
35 | | -}); |
| 42 | + }) as const satisfies Record<string, Parameters<typeof defineConfig>[number]>; |
| 43 | + |
| 44 | +/** @internal */ |
| 45 | +export const devConfigs = BasicConfig(true); |
| 46 | + |
| 47 | +/** @internal */ |
| 48 | +export const prodConfigs = BasicConfig(false); |
| 49 | + |
| 50 | +export default BasicConfig; |
0 commit comments