|
1 | 1 | import { describe, expect, it } from "bun:test"; |
2 | | -import { createProject, findFile, runDtsBuild } from "../utils"; |
| 2 | +import { createProject, findFile, runBuild, runDtsBuild } from "../utils"; |
3 | 3 |
|
4 | 4 | describe("dts-resolve", () => { |
| 5 | + it("should not override explicit dts.resolve false for bundled devDependencies", async () => { |
| 6 | + createProject({ |
| 7 | + "package.json": JSON.stringify({ |
| 8 | + name: "test-package", |
| 9 | + version: "1.0.0", |
| 10 | + devDependencies: { |
| 11 | + "dev-bundled-lib": "^1.0.0", |
| 12 | + }, |
| 13 | + }), |
| 14 | + "src/index.ts": ` |
| 15 | + import type { DevBundledType } from "dev-bundled-lib"; |
| 16 | +
|
| 17 | + export function process(value: DevBundledType): DevBundledType { |
| 18 | + return value; |
| 19 | + } |
| 20 | + `, |
| 21 | + "node_modules/dev-bundled-lib/index.d.ts": ` |
| 22 | + export interface DevBundledType { |
| 23 | + regressionSentinel: "dev-bundled"; |
| 24 | + } |
| 25 | + `, |
| 26 | + }); |
| 27 | + |
| 28 | + const result = await runBuild({ |
| 29 | + entry: "src/index.ts", |
| 30 | + format: "esm", |
| 31 | + dts: { |
| 32 | + resolve: false, |
| 33 | + }, |
| 34 | + }); |
| 35 | + |
| 36 | + expect(result.success).toBe(true); |
| 37 | + const dtsFile = findFile(result, "index", ".d.mts"); |
| 38 | + expect(dtsFile).toBeDefined(); |
| 39 | + expect(dtsFile?.content).toContain(`from "dev-bundled-lib"`); |
| 40 | + expect(dtsFile?.content).not.toContain(`regressionSentinel: "dev-bundled"`); |
| 41 | + }); |
| 42 | + |
| 43 | + it("should not override explicit dts.resolve false for bundled noExternal deps", async () => { |
| 44 | + createProject({ |
| 45 | + "package.json": JSON.stringify({ |
| 46 | + name: "test-package", |
| 47 | + version: "1.0.0", |
| 48 | + dependencies: { |
| 49 | + "included-lib": "^1.0.0", |
| 50 | + }, |
| 51 | + }), |
| 52 | + "src/index.ts": ` |
| 53 | + import type { IncludedType } from "included-lib"; |
| 54 | +
|
| 55 | + export function process(value: IncludedType): IncludedType { |
| 56 | + return value; |
| 57 | + } |
| 58 | + `, |
| 59 | + "node_modules/included-lib/index.d.ts": ` |
| 60 | + export interface IncludedType { |
| 61 | + regressionSentinel: "no-external"; |
| 62 | + } |
| 63 | + `, |
| 64 | + }); |
| 65 | + |
| 66 | + const result = await runDtsBuild({ |
| 67 | + entry: "src/index.ts", |
| 68 | + format: "esm", |
| 69 | + noExternal: ["included-lib"], |
| 70 | + dts: { |
| 71 | + resolve: false, |
| 72 | + }, |
| 73 | + }); |
| 74 | + |
| 75 | + expect(result.success).toBe(true); |
| 76 | + const dtsFile = findFile(result, "index", ".d.mts"); |
| 77 | + expect(dtsFile).toBeDefined(); |
| 78 | + expect(dtsFile?.content).toContain(`from "included-lib"`); |
| 79 | + expect(dtsFile?.content).not.toContain(`regressionSentinel: "no-external"`); |
| 80 | + }); |
| 81 | + |
5 | 82 | it("should respect custom dts.resolve configuration", async () => { |
6 | 83 | createProject({ |
7 | 84 | "package.json": JSON.stringify({ |
|
0 commit comments