From 2551c5a497932e8b23e0580763ddb32cd26697a7 Mon Sep 17 00:00:00 2001 From: jxom <7336481+jxom@users.noreply.github.com> Date: Thu, 9 Apr 2026 16:19:54 +1000 Subject: [PATCH 1/5] fix: add rootDir to generated tsconfig for TypeScript 6 compat TS 6 requires rootDir to be explicitly set when it can infer the common source directory. The generated tsconfig.tmp.json was missing this, causing: 'The rootDir setting must be explicitly set'. Preserves user's rootDir if set, otherwise defaults to '.'. Amp-Thread-ID: https://ampcode.com/threads/T-019d70c8-e64b-704b-8e07-492aa2fffb55 --- src/Package.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Package.ts b/src/Package.ts index 13cbab5..827267a 100644 --- a/src/Package.ts +++ b/src/Package.ts @@ -709,6 +709,7 @@ export async function transpile(options: transpile.Options): Promise Date: Thu, 9 Apr 2026 16:22:36 +1000 Subject: [PATCH 2/5] test: update snapshots for rootDir addition Amp-Thread-ID: https://ampcode.com/threads/T-019d70c8-e64b-704b-8e07-492aa2fffb55 --- src/Packages.test.ts | 2 + src/__snapshots__/Cli.test.ts.snap | 134 +++----- src/__snapshots__/Package.test.ts.snap | 405 +----------------------- src/__snapshots__/Packages.test.ts.snap | 8 + 4 files changed, 54 insertions(+), 495 deletions(-) diff --git a/src/Packages.test.ts b/src/Packages.test.ts index b07a412..79b8d8d 100644 --- a/src/Packages.test.ts +++ b/src/Packages.test.ts @@ -38,6 +38,7 @@ describe('Packages.find', () => { "/examples/monorepo/packages/foo", "/examples/monorepo/packages/bar", "/examples/basic", + "/dist/internal", ] `) }) @@ -199,6 +200,7 @@ describe('Packages.find', () => { "/examples/monorepo/packages/foo", "/examples/monorepo/packages/bar", "/examples/basic", + "/dist/internal", ] `) }) diff --git a/src/__snapshots__/Cli.test.ts.snap b/src/__snapshots__/Cli.test.ts.snap index cb6461d..740dc1f 100644 --- a/src/__snapshots__/Cli.test.ts.snap +++ b/src/__snapshots__/Cli.test.ts.snap @@ -244,11 +244,6 @@ exports[`'/basic-object-exports': Cli.run > link > output 1`] = ` exports[`'/basic-object-exports': Cli.run > link > types-target 1`] = `"../index.ts"`; -exports[`'/bin-with-src': Cli.run > default > main 1`] = ` -"export const foo = 'bar'; -//# sourceMappingURL=index.js.map" -`; - exports[`'/bin-with-src': Cli.run > default > output 1`] = ` "{ "name": "bin-with-src", @@ -274,14 +269,15 @@ exports[`'/bin-with-src': Cli.run > default > output 1`] = ` ├── dist -│ ├── cli.d.ts -│ ├── cli.d.ts.map -│ ├── cli.js -│ ├── cli.js.map -│ ├── index.d.ts -│ ├── index.d.ts.map -│ ├── index.js -│ └── index.js.map +│ └── src +│ ├── cli.d.ts +│ ├── cli.d.ts.map +│ ├── cli.js +│ ├── cli.js.map +│ ├── index.d.ts +│ ├── index.d.ts.map +│ ├── index.js +│ └── index.js.map ├── src │ ├── cli.ts │ └── index.ts @@ -290,11 +286,6 @@ exports[`'/bin-with-src': Cli.run > default > output 1`] = ` " `; -exports[`'/bin-with-src': Cli.run > default > types 1`] = ` -"export declare const foo = "bar"; -//# sourceMappingURL=index.d.ts.map" -`; - exports[`'/bin-with-src': Cli.run > link > main-target 1`] = `"../src/index.ts"`; exports[`'/bin-with-src': Cli.run > link > output 1`] = ` @@ -335,11 +326,6 @@ exports[`'/bin-with-src': Cli.run > link > output 1`] = ` exports[`'/bin-with-src': Cli.run > link > types-target 1`] = `"../src/index.ts"`; -exports[`'/dts-exports': Cli.run > default > main 1`] = ` -"export const foo = 'bar'; -//# sourceMappingURL=index.js.map" -`; - exports[`'/dts-exports': Cli.run > default > output 1`] = ` "{ "name": "dts-exports", @@ -365,11 +351,12 @@ exports[`'/dts-exports': Cli.run > default > output 1`] = ` ├── dist -│ ├── globals.d.ts -│ ├── index.d.ts -│ ├── index.d.ts.map -│ ├── index.js -│ └── index.js.map +│ ├── src +│ │ ├── index.d.ts +│ │ ├── index.d.ts.map +│ │ ├── index.js +│ │ └── index.js.map +│ └── globals.d.ts ├── src │ ├── globals.d.ts │ └── index.ts @@ -378,11 +365,6 @@ exports[`'/dts-exports': Cli.run > default > output 1`] = ` " `; -exports[`'/dts-exports': Cli.run > default > types 1`] = ` -"export declare const foo = "bar"; -//# sourceMappingURL=index.d.ts.map" -`; - exports[`'/dts-exports': Cli.run > link > main-target 1`] = `"../src/index.ts"`; exports[`'/dts-exports': Cli.run > link > output 1`] = ` @@ -423,11 +405,6 @@ exports[`'/dts-exports': Cli.run > link > output 1`] = ` exports[`'/dts-exports': Cli.run > link > types-target 1`] = `"../src/index.ts"`; -exports[`'/dts-exports-object': Cli.run > default > main 1`] = ` -"export const foo = 'bar'; -//# sourceMappingURL=index.js.map" -`; - exports[`'/dts-exports-object': Cli.run > default > output 1`] = ` "{ "name": "dts-exports-object", @@ -453,11 +430,12 @@ exports[`'/dts-exports-object': Cli.run > default > output 1`] = ` ├── dist -│ ├── globals.d.ts -│ ├── index.d.ts -│ ├── index.d.ts.map -│ ├── index.js -│ └── index.js.map +│ ├── src +│ │ ├── index.d.ts +│ │ ├── index.d.ts.map +│ │ ├── index.js +│ │ └── index.js.map +│ └── globals.d.ts ├── src │ ├── globals.d.ts │ └── index.ts @@ -466,11 +444,6 @@ exports[`'/dts-exports-object': Cli.run > default > output 1`] = ` " `; -exports[`'/dts-exports-object': Cli.run > default > types 1`] = ` -"export declare const foo = "bar"; -//# sourceMappingURL=index.d.ts.map" -`; - exports[`'/dts-exports-object': Cli.run > link > main-target 1`] = `"../src/index.ts"`; exports[`'/dts-exports-object': Cli.run > link > output 1`] = ` @@ -511,25 +484,6 @@ exports[`'/dts-exports-object': Cli.run > link > output 1`] = ` exports[`'/dts-exports-object': Cli.run > link > types-target 1`] = `"../src/index.ts"`; -exports[`'/multiple-entrypoint': Cli.run > default > main 1`] = ` -"import { bar as bar1, foo as foo1 } from './foo.js'; -export function foo(options = {}) { - foo1(options); - console.log('Hello, foo!', options.value); -} -export function bar(options = {}) { - bar1(options); - console.log('Hello, bar!', options.value); -} -(function (bar) { - function baz(options = {}) { - console.log('Hello, baz!', options.value); - } - bar.baz = baz; -})(bar || (bar = {})); -//# sourceMappingURL=index.js.map" -`; - exports[`'/multiple-entrypoint': Cli.run > default > output 1`] = ` "{ "name": "multiple-entrypoint", @@ -561,20 +515,21 @@ exports[`'/multiple-entrypoint': Cli.run > default > output 1`] = ` ├── dist -│ ├── nested -│ │ └── dir -│ │ ├── bar.d.ts -│ │ ├── bar.d.ts.map -│ │ ├── bar.js -│ │ └── bar.js.map -│ ├── foo.d.ts -│ ├── foo.d.ts.map -│ ├── foo.js -│ ├── foo.js.map -│ ├── index.d.ts -│ ├── index.d.ts.map -│ ├── index.js -│ └── index.js.map +│ └── src +│ ├── nested +│ │ └── dir +│ │ ├── bar.d.ts +│ │ ├── bar.d.ts.map +│ │ ├── bar.js +│ │ └── bar.js.map +│ ├── foo.d.ts +│ ├── foo.d.ts.map +│ ├── foo.js +│ ├── foo.js.map +│ ├── index.d.ts +│ ├── index.d.ts.map +│ ├── index.js +│ └── index.js.map ├── src │ ├── nested │ │ └── dir @@ -586,23 +541,6 @@ exports[`'/multiple-entrypoint': Cli.run > default > output 1`] = ` " `; -exports[`'/multiple-entrypoint': Cli.run > default > types 1`] = ` -"export declare function foo(options?: foo.Options): void; -export declare namespace foo { - type Options = { - value?: string | undefined; - }; -} -export declare function bar(options?: bar.Options): void; -export declare namespace bar { - type Options = { - value?: string | undefined; - }; - function baz(options?: Options): void; -} -//# sourceMappingURL=index.d.ts.map" -`; - exports[`'/multiple-entrypoint': Cli.run > link > main-target 1`] = `"../src/index.ts"`; exports[`'/multiple-entrypoint': Cli.run > link > output 1`] = ` diff --git a/src/__snapshots__/Package.test.ts.snap b/src/__snapshots__/Package.test.ts.snap index a22c38c..fc8ffcc 100644 --- a/src/__snapshots__/Package.test.ts.snap +++ b/src/__snapshots__/Package.test.ts.snap @@ -163,6 +163,7 @@ exports[`'/basic': Package.build > default > result 1`] = ` "moduleResolution": "nodenext", "noEmit": false, "outDir": "/repos/basic/dist", + "rootDir": ".", "skipLibCheck": true, "sourceMap": true, "strict": true, @@ -403,6 +404,7 @@ exports[`'/basic-object-exports': Package.build > default > result 1`] = ` "moduleResolution": "nodenext", "noEmit": false, "outDir": "/repos/basic-object-exports/dist", + "rootDir": ".", "skipLibCheck": true, "sourceMap": true, "strict": true, @@ -501,81 +503,6 @@ exports[`'/basic-object-exports': Package.build > link > result 1`] = ` exports[`'/basic-object-exports': Package.build > link > types-target 1`] = `"../index.ts"`; -exports[`'/bin-with-src': Package.build > default > check 1`] = ` -{ - "output": { - "attw": " -bin-with-src v0.0.0 - - (ignoring resolutions: 'node10', 'node16-cjs') - -(ignored per resolution) ⚠️ A require call resolved to an ESM JavaScript file, which is an error in Node and some bundlers. CommonJS consumers will need to use a dynamic import. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/CJSResolvesToESM.md - - -"bin-with-src" - -node16 (from ESM): 🟢 (ESM) -bundler: 🟢 -node10: (ignored) 🟢 -node16 (from CJS): (ignored) ⚠️ ESM (dynamic import only) - -*********************************** -", - "publint": "Running publint v0.3.14 for bin-with-src... -Packing files with \`bun pack\`... -Linting... -All good! -", - }, -} -`; - -exports[`'/bin-with-src': Package.build > default > main 1`] = ` -"export const foo = 'bar'; -//# sourceMappingURL=index.js.map" -`; - -exports[`'/bin-with-src': Package.build > default > output 1`] = ` -"{ - "name": "bin-with-src", - "version": "0.0.0", - "type": "module", - "bin": { - "bin-with-src": "./dist/cli.js", - "bin-with-src.src": "./src/cli.ts" - }, - "main": "./dist/index.js", - "exports": { - ".": { - "types": "./dist/index.d.ts", - "src": "./src/index.ts", - "default": "./dist/index.js" - } - }, - "sideEffects": false, - "module": "./dist/index.js", - "types": "./dist/index.d.ts" -} - - - -├── dist -│ ├── cli.d.ts -│ ├── cli.d.ts.map -│ ├── cli.js -│ ├── cli.js.map -│ ├── index.d.ts -│ ├── index.d.ts.map -│ ├── index.js -│ └── index.js.map -├── src -│ ├── cli.ts -│ └── index.ts -├── package.json -└── tsconfig.json -" -`; - exports[`'/bin-with-src': Package.build > default > result 1`] = ` { "packageJson": { @@ -610,6 +537,7 @@ exports[`'/bin-with-src': Package.build > default > result 1`] = ` "moduleResolution": "NodeNext", "noEmit": false, "outDir": "dist", + "rootDir": ".", "skipLibCheck": true, "sourceMap": true, "strict": true, @@ -625,11 +553,6 @@ exports[`'/bin-with-src': Package.build > default > result 1`] = ` } `; -exports[`'/bin-with-src': Package.build > default > types 1`] = ` -"export declare const foo = "bar"; -//# sourceMappingURL=index.d.ts.map" -`; - exports[`'/bin-with-src': Package.build > link > main-target 1`] = `"../src/index.ts"`; exports[`'/bin-with-src': Package.build > link > output 1`] = ` @@ -712,89 +635,6 @@ exports[`'/bin-with-src': Package.build > link > result 1`] = ` exports[`'/bin-with-src': Package.build > link > types-target 1`] = `"../src/index.ts"`; -exports[`'/dts-exports': Package.build > default > check 1`] = ` -{ - "output": { - "attw": " -dts-exports v0.0.0 - - (ignoring resolutions: 'node10', 'node16-cjs') - -(ignored per resolution) ⚠️ A require call resolved to an ESM JavaScript file, which is an error in Node and some bundlers. CommonJS consumers will need to use a dynamic import. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/CJSResolvesToESM.md - -(ignored per resolution) 💀 Import failed to resolve to type declarations or JavaScript files. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/NoResolution.md - - -"dts-exports" - -node16 (from ESM): 🟢 (ESM) -bundler: 🟢 -node10: (ignored) 🟢 -node16 (from CJS): (ignored) ⚠️ ESM (dynamic import only) - -*********************************** - -"dts-exports/globals" - -node16 (from ESM): 🟢 (ESM) -bundler: 🟢 -node10: (ignored) 💀 Resolution failed -node16 (from CJS): (ignored) ⚠️ ESM (dynamic import only) - -*********************************** -", - "publint": "Running publint v0.3.14 for dts-exports... -Packing files with \`bun pack\`... -Linting... -All good! -", - }, -} -`; - -exports[`'/dts-exports': Package.build > default > main 1`] = ` -"export const foo = 'bar'; -//# sourceMappingURL=index.js.map" -`; - -exports[`'/dts-exports': Package.build > default > output 1`] = ` -"{ - "name": "dts-exports", - "version": "0.0.0", - "type": "module", - "main": "./dist/index.js", - "exports": { - ".": { - "types": "./dist/index.d.ts", - "src": "./src/index.ts", - "default": "./dist/index.js" - }, - "./globals": { - "types": "./dist/globals.d.ts", - "src": "./src/globals.d.ts" - } - }, - "sideEffects": false, - "module": "./dist/index.js", - "types": "./dist/index.d.ts" -} - - - -├── dist -│ ├── globals.d.ts -│ ├── index.d.ts -│ ├── index.d.ts.map -│ ├── index.js -│ └── index.js.map -├── src -│ ├── globals.d.ts -│ └── index.ts -├── package.json -└── tsconfig.json -" -`; - exports[`'/dts-exports': Package.build > default > result 1`] = ` { "packageJson": { @@ -831,6 +671,7 @@ exports[`'/dts-exports': Package.build > default > result 1`] = ` "moduleResolution": "nodenext", "noEmit": false, "outDir": "/repos/dts-exports/dist", + "rootDir": ".", "skipLibCheck": true, "sourceMap": true, "strict": true, @@ -845,11 +686,6 @@ exports[`'/dts-exports': Package.build > default > result 1`] = ` } `; -exports[`'/dts-exports': Package.build > default > types 1`] = ` -"export declare const foo = "bar"; -//# sourceMappingURL=index.d.ts.map" -`; - exports[`'/dts-exports': Package.build > link > main-target 1`] = `"../src/index.ts"`; exports[`'/dts-exports': Package.build > link > output 1`] = ` @@ -927,89 +763,6 @@ exports[`'/dts-exports': Package.build > link > result 1`] = ` exports[`'/dts-exports': Package.build > link > types-target 1`] = `"../src/index.ts"`; -exports[`'/dts-exports-object': Package.build > default > check 1`] = ` -{ - "output": { - "attw": " -dts-exports-object v0.0.0 - - (ignoring resolutions: 'node10', 'node16-cjs') - -(ignored per resolution) ⚠️ A require call resolved to an ESM JavaScript file, which is an error in Node and some bundlers. CommonJS consumers will need to use a dynamic import. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/CJSResolvesToESM.md - -(ignored per resolution) 💀 Import failed to resolve to type declarations or JavaScript files. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/NoResolution.md - - -"dts-exports-object" - -node16 (from ESM): 🟢 (ESM) -bundler: 🟢 -node10: (ignored) 🟢 -node16 (from CJS): (ignored) ⚠️ ESM (dynamic import only) - -*********************************** - -"dts-exports-object/globals" - -node16 (from ESM): 🟢 (ESM) -bundler: 🟢 -node10: (ignored) 💀 Resolution failed -node16 (from CJS): (ignored) ⚠️ ESM (dynamic import only) - -*********************************** -", - "publint": "Running publint v0.3.14 for dts-exports-object... -Packing files with \`bun pack\`... -Linting... -All good! -", - }, -} -`; - -exports[`'/dts-exports-object': Package.build > default > main 1`] = ` -"export const foo = 'bar'; -//# sourceMappingURL=index.js.map" -`; - -exports[`'/dts-exports-object': Package.build > default > output 1`] = ` -"{ - "name": "dts-exports-object", - "version": "0.0.0", - "type": "module", - "main": "./dist/index.js", - "exports": { - ".": { - "types": "./dist/index.d.ts", - "src": "./src/index.ts", - "default": "./dist/index.js" - }, - "./globals": { - "types": "./dist/globals.d.ts", - "src": "./src/globals.d.ts" - } - }, - "sideEffects": false, - "module": "./dist/index.js", - "types": "./dist/index.d.ts" -} - - - -├── dist -│ ├── globals.d.ts -│ ├── index.d.ts -│ ├── index.d.ts.map -│ ├── index.js -│ └── index.js.map -├── src -│ ├── globals.d.ts -│ └── index.ts -├── package.json -└── tsconfig.json -" -`; - exports[`'/dts-exports-object': Package.build > default > result 1`] = ` { "packageJson": { @@ -1046,6 +799,7 @@ exports[`'/dts-exports-object': Package.build > default > result 1`] = ` "moduleResolution": "nodenext", "noEmit": false, "outDir": "/repos/dts-exports-object/dist", + "rootDir": ".", "skipLibCheck": true, "sourceMap": true, "strict": true, @@ -1060,11 +814,6 @@ exports[`'/dts-exports-object': Package.build > default > result 1`] = ` } `; -exports[`'/dts-exports-object': Package.build > default > types 1`] = ` -"export declare const foo = "bar"; -//# sourceMappingURL=index.d.ts.map" -`; - exports[`'/dts-exports-object': Package.build > link > main-target 1`] = `"../src/index.ts"`; exports[`'/dts-exports-object': Package.build > link > output 1`] = ` @@ -1160,130 +909,6 @@ exports[`'/error-module-resolution': Package.build > default > error 1`] = ` - "moduleResolution" must be "nodenext". Found: "bundler"" `; -exports[`'/multiple-entrypoint': Package.build > default > check 1`] = ` -{ - "output": { - "attw": " -multiple-entrypoint v0.0.0 - - (ignoring resolutions: 'node10', 'node16-cjs') - -(ignored per resolution) ⚠️ A require call resolved to an ESM JavaScript file, which is an error in Node and some bundlers. CommonJS consumers will need to use a dynamic import. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/CJSResolvesToESM.md - -(ignored per resolution) 💀 Import failed to resolve to type declarations or JavaScript files. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/NoResolution.md - - -"multiple-entrypoint" - -node16 (from ESM): 🟢 (ESM) -bundler: 🟢 -node10: (ignored) 🟢 -node16 (from CJS): (ignored) ⚠️ ESM (dynamic import only) - -*********************************** - -"multiple-entrypoint/foo" - -node16 (from ESM): 🟢 (ESM) -bundler: 🟢 -node10: (ignored) 💀 Resolution failed -node16 (from CJS): (ignored) ⚠️ ESM (dynamic import only) - -*********************************** - -"multiple-entrypoint/nested/dir" - -node16 (from ESM): 🟢 (ESM) -bundler: 🟢 -node10: (ignored) 💀 Resolution failed -node16 (from CJS): (ignored) ⚠️ ESM (dynamic import only) - -*********************************** -", - "publint": "Running publint v0.3.14 for multiple-entrypoint... -Packing files with \`bun pack\`... -Linting... -All good! -", - }, -} -`; - -exports[`'/multiple-entrypoint': Package.build > default > main 1`] = ` -"import { bar as bar1, foo as foo1 } from './foo.js'; -export function foo(options = {}) { - foo1(options); - console.log('Hello, foo!', options.value); -} -export function bar(options = {}) { - bar1(options); - console.log('Hello, bar!', options.value); -} -(function (bar) { - function baz(options = {}) { - console.log('Hello, baz!', options.value); - } - bar.baz = baz; -})(bar || (bar = {})); -//# sourceMappingURL=index.js.map" -`; - -exports[`'/multiple-entrypoint': Package.build > default > output 1`] = ` -"{ - "name": "multiple-entrypoint", - "version": "0.0.0", - "type": "module", - "exports": { - ".": { - "types": "./dist/index.d.ts", - "src": "./src/index.ts", - "default": "./dist/index.js" - }, - "./foo": { - "types": "./dist/foo.d.ts", - "src": "./src/foo.ts", - "default": "./dist/foo.js" - }, - "./nested/dir": { - "types": "./dist/nested/dir/bar.d.ts", - "src": "./src/nested/dir/bar.ts", - "default": "./dist/nested/dir/bar.js" - } - }, - "sideEffects": false, - "main": "./dist/index.js", - "module": "./dist/index.js", - "types": "./dist/index.d.ts" -} - - - -├── dist -│ ├── nested -│ │ └── dir -│ │ ├── bar.d.ts -│ │ ├── bar.d.ts.map -│ │ ├── bar.js -│ │ └── bar.js.map -│ ├── foo.d.ts -│ ├── foo.d.ts.map -│ ├── foo.js -│ ├── foo.js.map -│ ├── index.d.ts -│ ├── index.d.ts.map -│ ├── index.js -│ └── index.js.map -├── src -│ ├── nested -│ │ └── dir -│ │ └── bar.ts -│ ├── foo.ts -│ └── index.ts -├── package.json -└── tsconfig.json -" -`; - exports[`'/multiple-entrypoint': Package.build > default > result 1`] = ` { "packageJson": { @@ -1326,6 +951,7 @@ exports[`'/multiple-entrypoint': Package.build > default > result 1`] = ` "moduleResolution": "nodenext", "noEmit": false, "outDir": "/repos/multiple-entrypoint/dist", + "rootDir": ".", "skipLibCheck": true, "sourceMap": true, "strict": true, @@ -1342,23 +968,6 @@ exports[`'/multiple-entrypoint': Package.build > default > result 1`] = ` } `; -exports[`'/multiple-entrypoint': Package.build > default > types 1`] = ` -"export declare function foo(options?: foo.Options): void; -export declare namespace foo { - type Options = { - value?: string | undefined; - }; -} -export declare function bar(options?: bar.Options): void; -export declare namespace bar { - type Options = { - value?: string | undefined; - }; - function baz(options?: Options): void; -} -//# sourceMappingURL=index.d.ts.map" -`; - exports[`'/multiple-entrypoint': Package.build > link > main-target 1`] = `"../src/index.ts"`; exports[`'/multiple-entrypoint': Package.build > link > output 1`] = ` @@ -1572,6 +1181,7 @@ exports[`'/single-entrypoint': Package.build > default > result 1`] = ` "moduleResolution": "nodenext", "noEmit": false, "outDir": "/repos/single-entrypoint/dist", + "rootDir": ".", "skipLibCheck": true, "sourceMap": true, "strict": true, @@ -1814,6 +1424,7 @@ exports[`'/wildcard-exports': Package.build > default > result 1`] = ` "moduleResolution": "nodenext", "noEmit": false, "outDir": "/repos/wildcard-exports/dist", + "rootDir": ".", "skipLibCheck": true, "sourceMap": true, "strict": true, diff --git a/src/__snapshots__/Packages.test.ts.snap b/src/__snapshots__/Packages.test.ts.snap index a6eedc9..737254e 100644 --- a/src/__snapshots__/Packages.test.ts.snap +++ b/src/__snapshots__/Packages.test.ts.snap @@ -38,6 +38,7 @@ exports[`Packages.build > builds all packages 1`] = ` "moduleResolution": "nodenext", "noEmit": false, "outDir": "/repos/wildcard-exports/dist", + "rootDir": ".", "skipLibCheck": true, "sourceMap": true, "strict": true, @@ -85,6 +86,7 @@ exports[`Packages.build > builds all packages 1`] = ` "moduleResolution": "nodenext", "noEmit": false, "outDir": "/repos/single-entrypoint/dist", + "rootDir": ".", "skipLibCheck": true, "sourceMap": true, "strict": true, @@ -138,6 +140,7 @@ exports[`Packages.build > builds all packages 1`] = ` "moduleResolution": "nodenext", "noEmit": false, "outDir": "/repos/multiple-entrypoint/dist", + "rootDir": ".", "skipLibCheck": true, "sourceMap": true, "strict": true, @@ -187,6 +190,7 @@ exports[`Packages.build > builds all packages 1`] = ` "moduleResolution": "nodenext", "noEmit": false, "outDir": "/repos/dts-exports-object/dist", + "rootDir": ".", "skipLibCheck": true, "sourceMap": true, "strict": true, @@ -234,6 +238,7 @@ exports[`Packages.build > builds all packages 1`] = ` "moduleResolution": "nodenext", "noEmit": false, "outDir": "/repos/dts-exports/dist", + "rootDir": ".", "skipLibCheck": true, "sourceMap": true, "strict": true, @@ -279,6 +284,7 @@ exports[`Packages.build > builds all packages 1`] = ` "moduleResolution": "NodeNext", "noEmit": false, "outDir": "dist", + "rootDir": ".", "skipLibCheck": true, "sourceMap": true, "strict": true, @@ -323,6 +329,7 @@ exports[`Packages.build > builds all packages 1`] = ` "moduleResolution": "nodenext", "noEmit": false, "outDir": "/repos/basic-object-exports/dist", + "rootDir": ".", "skipLibCheck": true, "sourceMap": true, "strict": true, @@ -376,6 +383,7 @@ exports[`Packages.build > builds all packages 1`] = ` "moduleResolution": "nodenext", "noEmit": false, "outDir": "/repos/basic/dist", + "rootDir": ".", "skipLibCheck": true, "sourceMap": true, "strict": true, From 76fe760742d2dd7906be7bd3d3637f9728141124 Mon Sep 17 00:00:00 2001 From: jxom <7336481+jxom@users.noreply.github.com> Date: Thu, 9 Apr 2026 16:24:25 +1000 Subject: [PATCH 3/5] test: fix snapshot that depended on dist/ existing Amp-Thread-ID: https://ampcode.com/threads/T-019d70c8-e64b-704b-8e07-492aa2fffb55 --- src/Packages.test.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Packages.test.ts b/src/Packages.test.ts index 79b8d8d..b07a412 100644 --- a/src/Packages.test.ts +++ b/src/Packages.test.ts @@ -38,7 +38,6 @@ describe('Packages.find', () => { "/examples/monorepo/packages/foo", "/examples/monorepo/packages/bar", "/examples/basic", - "/dist/internal", ] `) }) @@ -200,7 +199,6 @@ describe('Packages.find', () => { "/examples/monorepo/packages/foo", "/examples/monorepo/packages/bar", "/examples/basic", - "/dist/internal", ] `) }) From 0fc8c2b673a51b89d604fcc89a63388a64999844 Mon Sep 17 00:00:00 2001 From: jxom <7336481+jxom@users.noreply.github.com> Date: Thu, 9 Apr 2026 16:27:12 +1000 Subject: [PATCH 4/5] fix: use sourceDir for rootDir instead of '.' Defaulting rootDir to '.' caused 'src/' to appear in the output tree. Now uses the computed common source directory from getSourceDir(). Amp-Thread-ID: https://ampcode.com/threads/T-019d70c8-e64b-704b-8e07-492aa2fffb55 --- src/Package.ts | 8 +- src/__snapshots__/Cli.test.ts.snap | 134 +++++--- src/__snapshots__/Package.test.ts.snap | 413 +++++++++++++++++++++++- src/__snapshots__/Packages.test.ts.snap | 16 +- 4 files changed, 516 insertions(+), 55 deletions(-) diff --git a/src/Package.ts b/src/Package.ts index 827267a..3451164 100644 --- a/src/Package.ts +++ b/src/Package.ts @@ -30,7 +30,7 @@ export async function build(options: build.Options): Promise { const sourceDir = getSourceDir({ cwd, sources }) if (!link) { - const result = await transpile({ cwd, sources, tsgo }) + const result = await transpile({ cwd, sources, sourceDir, tsgo }) tsConfig = result.tsConfig } @@ -679,7 +679,7 @@ export declare namespace readTsconfigJson { * @returns Transpilation artifacts. */ export async function transpile(options: transpile.Options): Promise { - const { cwd = process.cwd(), sources, project = './tsconfig.json', tsgo } = options + const { cwd = process.cwd(), sources, sourceDir, project = './tsconfig.json', tsgo } = options const tsConfigJson = await readTsconfigJson({ cwd, project }) const tsconfigPath = path.resolve(cwd, project) @@ -709,7 +709,7 @@ export async function transpile(options: transpile.Options): Promise link > output 1`] = ` exports[`'/basic-object-exports': Cli.run > link > types-target 1`] = `"../index.ts"`; +exports[`'/bin-with-src': Cli.run > default > main 1`] = ` +"export const foo = 'bar'; +//# sourceMappingURL=index.js.map" +`; + exports[`'/bin-with-src': Cli.run > default > output 1`] = ` "{ "name": "bin-with-src", @@ -269,15 +274,14 @@ exports[`'/bin-with-src': Cli.run > default > output 1`] = ` ├── dist -│ └── src -│ ├── cli.d.ts -│ ├── cli.d.ts.map -│ ├── cli.js -│ ├── cli.js.map -│ ├── index.d.ts -│ ├── index.d.ts.map -│ ├── index.js -│ └── index.js.map +│ ├── cli.d.ts +│ ├── cli.d.ts.map +│ ├── cli.js +│ ├── cli.js.map +│ ├── index.d.ts +│ ├── index.d.ts.map +│ ├── index.js +│ └── index.js.map ├── src │ ├── cli.ts │ └── index.ts @@ -286,6 +290,11 @@ exports[`'/bin-with-src': Cli.run > default > output 1`] = ` " `; +exports[`'/bin-with-src': Cli.run > default > types 1`] = ` +"export declare const foo = "bar"; +//# sourceMappingURL=index.d.ts.map" +`; + exports[`'/bin-with-src': Cli.run > link > main-target 1`] = `"../src/index.ts"`; exports[`'/bin-with-src': Cli.run > link > output 1`] = ` @@ -326,6 +335,11 @@ exports[`'/bin-with-src': Cli.run > link > output 1`] = ` exports[`'/bin-with-src': Cli.run > link > types-target 1`] = `"../src/index.ts"`; +exports[`'/dts-exports': Cli.run > default > main 1`] = ` +"export const foo = 'bar'; +//# sourceMappingURL=index.js.map" +`; + exports[`'/dts-exports': Cli.run > default > output 1`] = ` "{ "name": "dts-exports", @@ -351,12 +365,11 @@ exports[`'/dts-exports': Cli.run > default > output 1`] = ` ├── dist -│ ├── src -│ │ ├── index.d.ts -│ │ ├── index.d.ts.map -│ │ ├── index.js -│ │ └── index.js.map -│ └── globals.d.ts +│ ├── globals.d.ts +│ ├── index.d.ts +│ ├── index.d.ts.map +│ ├── index.js +│ └── index.js.map ├── src │ ├── globals.d.ts │ └── index.ts @@ -365,6 +378,11 @@ exports[`'/dts-exports': Cli.run > default > output 1`] = ` " `; +exports[`'/dts-exports': Cli.run > default > types 1`] = ` +"export declare const foo = "bar"; +//# sourceMappingURL=index.d.ts.map" +`; + exports[`'/dts-exports': Cli.run > link > main-target 1`] = `"../src/index.ts"`; exports[`'/dts-exports': Cli.run > link > output 1`] = ` @@ -405,6 +423,11 @@ exports[`'/dts-exports': Cli.run > link > output 1`] = ` exports[`'/dts-exports': Cli.run > link > types-target 1`] = `"../src/index.ts"`; +exports[`'/dts-exports-object': Cli.run > default > main 1`] = ` +"export const foo = 'bar'; +//# sourceMappingURL=index.js.map" +`; + exports[`'/dts-exports-object': Cli.run > default > output 1`] = ` "{ "name": "dts-exports-object", @@ -430,12 +453,11 @@ exports[`'/dts-exports-object': Cli.run > default > output 1`] = ` ├── dist -│ ├── src -│ │ ├── index.d.ts -│ │ ├── index.d.ts.map -│ │ ├── index.js -│ │ └── index.js.map -│ └── globals.d.ts +│ ├── globals.d.ts +│ ├── index.d.ts +│ ├── index.d.ts.map +│ ├── index.js +│ └── index.js.map ├── src │ ├── globals.d.ts │ └── index.ts @@ -444,6 +466,11 @@ exports[`'/dts-exports-object': Cli.run > default > output 1`] = ` " `; +exports[`'/dts-exports-object': Cli.run > default > types 1`] = ` +"export declare const foo = "bar"; +//# sourceMappingURL=index.d.ts.map" +`; + exports[`'/dts-exports-object': Cli.run > link > main-target 1`] = `"../src/index.ts"`; exports[`'/dts-exports-object': Cli.run > link > output 1`] = ` @@ -484,6 +511,25 @@ exports[`'/dts-exports-object': Cli.run > link > output 1`] = ` exports[`'/dts-exports-object': Cli.run > link > types-target 1`] = `"../src/index.ts"`; +exports[`'/multiple-entrypoint': Cli.run > default > main 1`] = ` +"import { bar as bar1, foo as foo1 } from './foo.js'; +export function foo(options = {}) { + foo1(options); + console.log('Hello, foo!', options.value); +} +export function bar(options = {}) { + bar1(options); + console.log('Hello, bar!', options.value); +} +(function (bar) { + function baz(options = {}) { + console.log('Hello, baz!', options.value); + } + bar.baz = baz; +})(bar || (bar = {})); +//# sourceMappingURL=index.js.map" +`; + exports[`'/multiple-entrypoint': Cli.run > default > output 1`] = ` "{ "name": "multiple-entrypoint", @@ -515,21 +561,20 @@ exports[`'/multiple-entrypoint': Cli.run > default > output 1`] = ` ├── dist -│ └── src -│ ├── nested -│ │ └── dir -│ │ ├── bar.d.ts -│ │ ├── bar.d.ts.map -│ │ ├── bar.js -│ │ └── bar.js.map -│ ├── foo.d.ts -│ ├── foo.d.ts.map -│ ├── foo.js -│ ├── foo.js.map -│ ├── index.d.ts -│ ├── index.d.ts.map -│ ├── index.js -│ └── index.js.map +│ ├── nested +│ │ └── dir +│ │ ├── bar.d.ts +│ │ ├── bar.d.ts.map +│ │ ├── bar.js +│ │ └── bar.js.map +│ ├── foo.d.ts +│ ├── foo.d.ts.map +│ ├── foo.js +│ ├── foo.js.map +│ ├── index.d.ts +│ ├── index.d.ts.map +│ ├── index.js +│ └── index.js.map ├── src │ ├── nested │ │ └── dir @@ -541,6 +586,23 @@ exports[`'/multiple-entrypoint': Cli.run > default > output 1`] = ` " `; +exports[`'/multiple-entrypoint': Cli.run > default > types 1`] = ` +"export declare function foo(options?: foo.Options): void; +export declare namespace foo { + type Options = { + value?: string | undefined; + }; +} +export declare function bar(options?: bar.Options): void; +export declare namespace bar { + type Options = { + value?: string | undefined; + }; + function baz(options?: Options): void; +} +//# sourceMappingURL=index.d.ts.map" +`; + exports[`'/multiple-entrypoint': Cli.run > link > main-target 1`] = `"../src/index.ts"`; exports[`'/multiple-entrypoint': Cli.run > link > output 1`] = ` diff --git a/src/__snapshots__/Package.test.ts.snap b/src/__snapshots__/Package.test.ts.snap index fc8ffcc..e0dd0cc 100644 --- a/src/__snapshots__/Package.test.ts.snap +++ b/src/__snapshots__/Package.test.ts.snap @@ -163,7 +163,7 @@ exports[`'/basic': Package.build > default > result 1`] = ` "moduleResolution": "nodenext", "noEmit": false, "outDir": "/repos/basic/dist", - "rootDir": ".", + "rootDir": "/repos/basic", "skipLibCheck": true, "sourceMap": true, "strict": true, @@ -404,7 +404,7 @@ exports[`'/basic-object-exports': Package.build > default > result 1`] = ` "moduleResolution": "nodenext", "noEmit": false, "outDir": "/repos/basic-object-exports/dist", - "rootDir": ".", + "rootDir": "/repos/basic-object-exports", "skipLibCheck": true, "sourceMap": true, "strict": true, @@ -503,6 +503,81 @@ exports[`'/basic-object-exports': Package.build > link > result 1`] = ` exports[`'/basic-object-exports': Package.build > link > types-target 1`] = `"../index.ts"`; +exports[`'/bin-with-src': Package.build > default > check 1`] = ` +{ + "output": { + "attw": " +bin-with-src v0.0.0 + + (ignoring resolutions: 'node10', 'node16-cjs') + +(ignored per resolution) ⚠️ A require call resolved to an ESM JavaScript file, which is an error in Node and some bundlers. CommonJS consumers will need to use a dynamic import. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/CJSResolvesToESM.md + + +"bin-with-src" + +node16 (from ESM): 🟢 (ESM) +bundler: 🟢 +node10: (ignored) 🟢 +node16 (from CJS): (ignored) ⚠️ ESM (dynamic import only) + +*********************************** +", + "publint": "Running publint v0.3.14 for bin-with-src... +Packing files with \`bun pack\`... +Linting... +All good! +", + }, +} +`; + +exports[`'/bin-with-src': Package.build > default > main 1`] = ` +"export const foo = 'bar'; +//# sourceMappingURL=index.js.map" +`; + +exports[`'/bin-with-src': Package.build > default > output 1`] = ` +"{ + "name": "bin-with-src", + "version": "0.0.0", + "type": "module", + "bin": { + "bin-with-src": "./dist/cli.js", + "bin-with-src.src": "./src/cli.ts" + }, + "main": "./dist/index.js", + "exports": { + ".": { + "types": "./dist/index.d.ts", + "src": "./src/index.ts", + "default": "./dist/index.js" + } + }, + "sideEffects": false, + "module": "./dist/index.js", + "types": "./dist/index.d.ts" +} + + + +├── dist +│ ├── cli.d.ts +│ ├── cli.d.ts.map +│ ├── cli.js +│ ├── cli.js.map +│ ├── index.d.ts +│ ├── index.d.ts.map +│ ├── index.js +│ └── index.js.map +├── src +│ ├── cli.ts +│ └── index.ts +├── package.json +└── tsconfig.json +" +`; + exports[`'/bin-with-src': Package.build > default > result 1`] = ` { "packageJson": { @@ -537,7 +612,7 @@ exports[`'/bin-with-src': Package.build > default > result 1`] = ` "moduleResolution": "NodeNext", "noEmit": false, "outDir": "dist", - "rootDir": ".", + "rootDir": "/repos/bin-with-src/src", "skipLibCheck": true, "sourceMap": true, "strict": true, @@ -553,6 +628,11 @@ exports[`'/bin-with-src': Package.build > default > result 1`] = ` } `; +exports[`'/bin-with-src': Package.build > default > types 1`] = ` +"export declare const foo = "bar"; +//# sourceMappingURL=index.d.ts.map" +`; + exports[`'/bin-with-src': Package.build > link > main-target 1`] = `"../src/index.ts"`; exports[`'/bin-with-src': Package.build > link > output 1`] = ` @@ -635,6 +715,89 @@ exports[`'/bin-with-src': Package.build > link > result 1`] = ` exports[`'/bin-with-src': Package.build > link > types-target 1`] = `"../src/index.ts"`; +exports[`'/dts-exports': Package.build > default > check 1`] = ` +{ + "output": { + "attw": " +dts-exports v0.0.0 + + (ignoring resolutions: 'node10', 'node16-cjs') + +(ignored per resolution) ⚠️ A require call resolved to an ESM JavaScript file, which is an error in Node and some bundlers. CommonJS consumers will need to use a dynamic import. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/CJSResolvesToESM.md + +(ignored per resolution) 💀 Import failed to resolve to type declarations or JavaScript files. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/NoResolution.md + + +"dts-exports" + +node16 (from ESM): 🟢 (ESM) +bundler: 🟢 +node10: (ignored) 🟢 +node16 (from CJS): (ignored) ⚠️ ESM (dynamic import only) + +*********************************** + +"dts-exports/globals" + +node16 (from ESM): 🟢 (ESM) +bundler: 🟢 +node10: (ignored) 💀 Resolution failed +node16 (from CJS): (ignored) ⚠️ ESM (dynamic import only) + +*********************************** +", + "publint": "Running publint v0.3.14 for dts-exports... +Packing files with \`bun pack\`... +Linting... +All good! +", + }, +} +`; + +exports[`'/dts-exports': Package.build > default > main 1`] = ` +"export const foo = 'bar'; +//# sourceMappingURL=index.js.map" +`; + +exports[`'/dts-exports': Package.build > default > output 1`] = ` +"{ + "name": "dts-exports", + "version": "0.0.0", + "type": "module", + "main": "./dist/index.js", + "exports": { + ".": { + "types": "./dist/index.d.ts", + "src": "./src/index.ts", + "default": "./dist/index.js" + }, + "./globals": { + "types": "./dist/globals.d.ts", + "src": "./src/globals.d.ts" + } + }, + "sideEffects": false, + "module": "./dist/index.js", + "types": "./dist/index.d.ts" +} + + + +├── dist +│ ├── globals.d.ts +│ ├── index.d.ts +│ ├── index.d.ts.map +│ ├── index.js +│ └── index.js.map +├── src +│ ├── globals.d.ts +│ └── index.ts +├── package.json +└── tsconfig.json +" +`; + exports[`'/dts-exports': Package.build > default > result 1`] = ` { "packageJson": { @@ -671,7 +834,7 @@ exports[`'/dts-exports': Package.build > default > result 1`] = ` "moduleResolution": "nodenext", "noEmit": false, "outDir": "/repos/dts-exports/dist", - "rootDir": ".", + "rootDir": "/repos/dts-exports/src", "skipLibCheck": true, "sourceMap": true, "strict": true, @@ -686,6 +849,11 @@ exports[`'/dts-exports': Package.build > default > result 1`] = ` } `; +exports[`'/dts-exports': Package.build > default > types 1`] = ` +"export declare const foo = "bar"; +//# sourceMappingURL=index.d.ts.map" +`; + exports[`'/dts-exports': Package.build > link > main-target 1`] = `"../src/index.ts"`; exports[`'/dts-exports': Package.build > link > output 1`] = ` @@ -763,6 +931,89 @@ exports[`'/dts-exports': Package.build > link > result 1`] = ` exports[`'/dts-exports': Package.build > link > types-target 1`] = `"../src/index.ts"`; +exports[`'/dts-exports-object': Package.build > default > check 1`] = ` +{ + "output": { + "attw": " +dts-exports-object v0.0.0 + + (ignoring resolutions: 'node10', 'node16-cjs') + +(ignored per resolution) ⚠️ A require call resolved to an ESM JavaScript file, which is an error in Node and some bundlers. CommonJS consumers will need to use a dynamic import. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/CJSResolvesToESM.md + +(ignored per resolution) 💀 Import failed to resolve to type declarations or JavaScript files. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/NoResolution.md + + +"dts-exports-object" + +node16 (from ESM): 🟢 (ESM) +bundler: 🟢 +node10: (ignored) 🟢 +node16 (from CJS): (ignored) ⚠️ ESM (dynamic import only) + +*********************************** + +"dts-exports-object/globals" + +node16 (from ESM): 🟢 (ESM) +bundler: 🟢 +node10: (ignored) 💀 Resolution failed +node16 (from CJS): (ignored) ⚠️ ESM (dynamic import only) + +*********************************** +", + "publint": "Running publint v0.3.14 for dts-exports-object... +Packing files with \`bun pack\`... +Linting... +All good! +", + }, +} +`; + +exports[`'/dts-exports-object': Package.build > default > main 1`] = ` +"export const foo = 'bar'; +//# sourceMappingURL=index.js.map" +`; + +exports[`'/dts-exports-object': Package.build > default > output 1`] = ` +"{ + "name": "dts-exports-object", + "version": "0.0.0", + "type": "module", + "main": "./dist/index.js", + "exports": { + ".": { + "types": "./dist/index.d.ts", + "src": "./src/index.ts", + "default": "./dist/index.js" + }, + "./globals": { + "types": "./dist/globals.d.ts", + "src": "./src/globals.d.ts" + } + }, + "sideEffects": false, + "module": "./dist/index.js", + "types": "./dist/index.d.ts" +} + + + +├── dist +│ ├── globals.d.ts +│ ├── index.d.ts +│ ├── index.d.ts.map +│ ├── index.js +│ └── index.js.map +├── src +│ ├── globals.d.ts +│ └── index.ts +├── package.json +└── tsconfig.json +" +`; + exports[`'/dts-exports-object': Package.build > default > result 1`] = ` { "packageJson": { @@ -799,7 +1050,7 @@ exports[`'/dts-exports-object': Package.build > default > result 1`] = ` "moduleResolution": "nodenext", "noEmit": false, "outDir": "/repos/dts-exports-object/dist", - "rootDir": ".", + "rootDir": "/repos/dts-exports-object/src", "skipLibCheck": true, "sourceMap": true, "strict": true, @@ -814,6 +1065,11 @@ exports[`'/dts-exports-object': Package.build > default > result 1`] = ` } `; +exports[`'/dts-exports-object': Package.build > default > types 1`] = ` +"export declare const foo = "bar"; +//# sourceMappingURL=index.d.ts.map" +`; + exports[`'/dts-exports-object': Package.build > link > main-target 1`] = `"../src/index.ts"`; exports[`'/dts-exports-object': Package.build > link > output 1`] = ` @@ -909,6 +1165,130 @@ exports[`'/error-module-resolution': Package.build > default > error 1`] = ` - "moduleResolution" must be "nodenext". Found: "bundler"" `; +exports[`'/multiple-entrypoint': Package.build > default > check 1`] = ` +{ + "output": { + "attw": " +multiple-entrypoint v0.0.0 + + (ignoring resolutions: 'node10', 'node16-cjs') + +(ignored per resolution) ⚠️ A require call resolved to an ESM JavaScript file, which is an error in Node and some bundlers. CommonJS consumers will need to use a dynamic import. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/CJSResolvesToESM.md + +(ignored per resolution) 💀 Import failed to resolve to type declarations or JavaScript files. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/NoResolution.md + + +"multiple-entrypoint" + +node16 (from ESM): 🟢 (ESM) +bundler: 🟢 +node10: (ignored) 🟢 +node16 (from CJS): (ignored) ⚠️ ESM (dynamic import only) + +*********************************** + +"multiple-entrypoint/foo" + +node16 (from ESM): 🟢 (ESM) +bundler: 🟢 +node10: (ignored) 💀 Resolution failed +node16 (from CJS): (ignored) ⚠️ ESM (dynamic import only) + +*********************************** + +"multiple-entrypoint/nested/dir" + +node16 (from ESM): 🟢 (ESM) +bundler: 🟢 +node10: (ignored) 💀 Resolution failed +node16 (from CJS): (ignored) ⚠️ ESM (dynamic import only) + +*********************************** +", + "publint": "Running publint v0.3.14 for multiple-entrypoint... +Packing files with \`bun pack\`... +Linting... +All good! +", + }, +} +`; + +exports[`'/multiple-entrypoint': Package.build > default > main 1`] = ` +"import { bar as bar1, foo as foo1 } from './foo.js'; +export function foo(options = {}) { + foo1(options); + console.log('Hello, foo!', options.value); +} +export function bar(options = {}) { + bar1(options); + console.log('Hello, bar!', options.value); +} +(function (bar) { + function baz(options = {}) { + console.log('Hello, baz!', options.value); + } + bar.baz = baz; +})(bar || (bar = {})); +//# sourceMappingURL=index.js.map" +`; + +exports[`'/multiple-entrypoint': Package.build > default > output 1`] = ` +"{ + "name": "multiple-entrypoint", + "version": "0.0.0", + "type": "module", + "exports": { + ".": { + "types": "./dist/index.d.ts", + "src": "./src/index.ts", + "default": "./dist/index.js" + }, + "./foo": { + "types": "./dist/foo.d.ts", + "src": "./src/foo.ts", + "default": "./dist/foo.js" + }, + "./nested/dir": { + "types": "./dist/nested/dir/bar.d.ts", + "src": "./src/nested/dir/bar.ts", + "default": "./dist/nested/dir/bar.js" + } + }, + "sideEffects": false, + "main": "./dist/index.js", + "module": "./dist/index.js", + "types": "./dist/index.d.ts" +} + + + +├── dist +│ ├── nested +│ │ └── dir +│ │ ├── bar.d.ts +│ │ ├── bar.d.ts.map +│ │ ├── bar.js +│ │ └── bar.js.map +│ ├── foo.d.ts +│ ├── foo.d.ts.map +│ ├── foo.js +│ ├── foo.js.map +│ ├── index.d.ts +│ ├── index.d.ts.map +│ ├── index.js +│ └── index.js.map +├── src +│ ├── nested +│ │ └── dir +│ │ └── bar.ts +│ ├── foo.ts +│ └── index.ts +├── package.json +└── tsconfig.json +" +`; + exports[`'/multiple-entrypoint': Package.build > default > result 1`] = ` { "packageJson": { @@ -951,7 +1331,7 @@ exports[`'/multiple-entrypoint': Package.build > default > result 1`] = ` "moduleResolution": "nodenext", "noEmit": false, "outDir": "/repos/multiple-entrypoint/dist", - "rootDir": ".", + "rootDir": "/repos/multiple-entrypoint/src", "skipLibCheck": true, "sourceMap": true, "strict": true, @@ -968,6 +1348,23 @@ exports[`'/multiple-entrypoint': Package.build > default > result 1`] = ` } `; +exports[`'/multiple-entrypoint': Package.build > default > types 1`] = ` +"export declare function foo(options?: foo.Options): void; +export declare namespace foo { + type Options = { + value?: string | undefined; + }; +} +export declare function bar(options?: bar.Options): void; +export declare namespace bar { + type Options = { + value?: string | undefined; + }; + function baz(options?: Options): void; +} +//# sourceMappingURL=index.d.ts.map" +`; + exports[`'/multiple-entrypoint': Package.build > link > main-target 1`] = `"../src/index.ts"`; exports[`'/multiple-entrypoint': Package.build > link > output 1`] = ` @@ -1181,7 +1578,7 @@ exports[`'/single-entrypoint': Package.build > default > result 1`] = ` "moduleResolution": "nodenext", "noEmit": false, "outDir": "/repos/single-entrypoint/dist", - "rootDir": ".", + "rootDir": "/repos/single-entrypoint", "skipLibCheck": true, "sourceMap": true, "strict": true, @@ -1424,7 +1821,7 @@ exports[`'/wildcard-exports': Package.build > default > result 1`] = ` "moduleResolution": "nodenext", "noEmit": false, "outDir": "/repos/wildcard-exports/dist", - "rootDir": ".", + "rootDir": "/repos/wildcard-exports", "skipLibCheck": true, "sourceMap": true, "strict": true, diff --git a/src/__snapshots__/Packages.test.ts.snap b/src/__snapshots__/Packages.test.ts.snap index 737254e..4cf2039 100644 --- a/src/__snapshots__/Packages.test.ts.snap +++ b/src/__snapshots__/Packages.test.ts.snap @@ -38,7 +38,7 @@ exports[`Packages.build > builds all packages 1`] = ` "moduleResolution": "nodenext", "noEmit": false, "outDir": "/repos/wildcard-exports/dist", - "rootDir": ".", + "rootDir": "/repos/wildcard-exports", "skipLibCheck": true, "sourceMap": true, "strict": true, @@ -86,7 +86,7 @@ exports[`Packages.build > builds all packages 1`] = ` "moduleResolution": "nodenext", "noEmit": false, "outDir": "/repos/single-entrypoint/dist", - "rootDir": ".", + "rootDir": "/repos/single-entrypoint", "skipLibCheck": true, "sourceMap": true, "strict": true, @@ -140,7 +140,7 @@ exports[`Packages.build > builds all packages 1`] = ` "moduleResolution": "nodenext", "noEmit": false, "outDir": "/repos/multiple-entrypoint/dist", - "rootDir": ".", + "rootDir": "/repos/multiple-entrypoint/src", "skipLibCheck": true, "sourceMap": true, "strict": true, @@ -190,7 +190,7 @@ exports[`Packages.build > builds all packages 1`] = ` "moduleResolution": "nodenext", "noEmit": false, "outDir": "/repos/dts-exports-object/dist", - "rootDir": ".", + "rootDir": "/repos/dts-exports-object/src", "skipLibCheck": true, "sourceMap": true, "strict": true, @@ -238,7 +238,7 @@ exports[`Packages.build > builds all packages 1`] = ` "moduleResolution": "nodenext", "noEmit": false, "outDir": "/repos/dts-exports/dist", - "rootDir": ".", + "rootDir": "/repos/dts-exports/src", "skipLibCheck": true, "sourceMap": true, "strict": true, @@ -284,7 +284,7 @@ exports[`Packages.build > builds all packages 1`] = ` "moduleResolution": "NodeNext", "noEmit": false, "outDir": "dist", - "rootDir": ".", + "rootDir": "/repos/bin-with-src/src", "skipLibCheck": true, "sourceMap": true, "strict": true, @@ -329,7 +329,7 @@ exports[`Packages.build > builds all packages 1`] = ` "moduleResolution": "nodenext", "noEmit": false, "outDir": "/repos/basic-object-exports/dist", - "rootDir": ".", + "rootDir": "/repos/basic-object-exports", "skipLibCheck": true, "sourceMap": true, "strict": true, @@ -383,7 +383,7 @@ exports[`Packages.build > builds all packages 1`] = ` "moduleResolution": "nodenext", "noEmit": false, "outDir": "/repos/basic/dist", - "rootDir": ".", + "rootDir": "/repos/basic", "skipLibCheck": true, "sourceMap": true, "strict": true, From 18d4501ce51abda395cf8a6fea6ccf7610edae28 Mon Sep 17 00:00:00 2001 From: jxom <7336481+jxom@users.noreply.github.com> Date: Thu, 9 Apr 2026 16:28:25 +1000 Subject: [PATCH 5/5] chore: add changeset Amp-Thread-ID: https://ampcode.com/threads/T-019d70c8-e64b-704b-8e07-492aa2fffb55 --- .changeset/fix-ts6-rootdir.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/fix-ts6-rootdir.md diff --git a/.changeset/fix-ts6-rootdir.md b/.changeset/fix-ts6-rootdir.md new file mode 100644 index 0000000..edb2709 --- /dev/null +++ b/.changeset/fix-ts6-rootdir.md @@ -0,0 +1,5 @@ +--- +"zile": patch +--- + +Fixed TypeScript 6 compatibility by adding `rootDir` to the generated tsconfig. Uses the computed common source directory from entry points as the default.