|
1 | | -import { cp } from "node:fs/promises"; |
2 | | -import { join } from "node:path"; |
| 1 | +import { cp, glob } from "node:fs/promises"; |
| 2 | +import { join, sep } from "node:path"; |
3 | 3 | import { defineConfig } from "tsdown"; |
4 | 4 |
|
5 | | -export default defineConfig({ |
6 | | - entry: ["src/mod.ts"], |
7 | | - dts: true, |
8 | | - format: ["esm", "cjs"], |
9 | | - platform: "node", |
10 | | - external: [/^node:/], |
11 | | - hooks: { |
12 | | - "build:done": async (ctx) => { |
13 | | - await cp( |
14 | | - join("src", "schema.yaml"), |
15 | | - join(ctx.options.outDir, "schema.yaml"), |
16 | | - { force: true }, |
17 | | - ); |
| 5 | +export default [ |
| 6 | + defineConfig({ |
| 7 | + entry: ["src/mod.ts"], |
| 8 | + dts: true, |
| 9 | + format: ["esm", "cjs"], |
| 10 | + platform: "neutral", |
| 11 | + external: [/^node:/], |
| 12 | + hooks: { |
| 13 | + "build:done": async (ctx) => { |
| 14 | + await cp( |
| 15 | + join("src", "schema.yaml"), |
| 16 | + join(ctx.options.outDir, "schema.yaml"), |
| 17 | + { force: true }, |
| 18 | + ); |
| 19 | + }, |
18 | 20 | }, |
19 | | - }, |
20 | | -}); |
| 21 | + }), |
| 22 | + defineConfig({ |
| 23 | + entry: (await Array.fromAsync(glob(`src/**/*.test.ts`))) |
| 24 | + .map((f) => f.replace(sep, "/")), |
| 25 | + format: ["esm"], |
| 26 | + platform: "node", |
| 27 | + external: [ |
| 28 | + /^node:/, |
| 29 | + /^bun:/, |
| 30 | + ], |
| 31 | + inputOptions: { |
| 32 | + onwarn(warning, defaultHandler) { |
| 33 | + if ( |
| 34 | + warning.code === "UNRESOLVED_IMPORT" && |
| 35 | + warning.id?.endsWith(".test.ts") && |
| 36 | + warning.exporter && |
| 37 | + ["bun:test", "@std/testing/snapshot"].includes(warning.exporter) |
| 38 | + ) { |
| 39 | + return; |
| 40 | + } |
| 41 | + defaultHandler(warning); |
| 42 | + }, |
| 43 | + }, |
| 44 | + hooks: { |
| 45 | + "build:done": async (ctx) => { |
| 46 | + await cp( |
| 47 | + join("src", "__snapshots__"), |
| 48 | + join(ctx.options.outDir, "__snapshots__"), |
| 49 | + { recursive: true }, |
| 50 | + ); |
| 51 | + }, |
| 52 | + }, |
| 53 | + }), |
| 54 | +]; |
| 55 | +// cSpell: ignore onwarn |
0 commit comments