Skip to content

Commit bb6924c

Browse files
dahliaampagent
andcommitted
Use noExternal to selectively bundle @fedify/fixture for testing/mod.ts
The previous approach of splitting src/testing/mod.ts into a separate defineConfig caused the cfworkers build to fail because tsdown flattened the single-entry output to dist/mod.js instead of dist/testing/mod.js, breaking the import in src/cfworkers/server.ts. Instead, keep src/testing/mod.ts and *.test.ts in a single defineConfig (preserving directory structure in output), mark @fedify/fixture as external, and use noExternal with a function to selectively bundle it back in only when imported from src/testing/ files. This way: - The cfworkers build gets @fedify/fixture inlined in testing/mod.js - Test files keep @fedify/fixture external, avoiding the UNLOADABLE_DEPENDENCY error during pnpm pack --recursive https://github.com/fedify-dev/fedify/actions/runs/23243929108/job/67567201018 Co-authored-by: Amp (https://ampcode.com) Amp-Thread-ID: https://ampcode.com/threads/T-019d00c0-4bd0-70fe-b81f-82e3738959e9 Co-authored-by: Amp <amp@ampcode.com>
1 parent 484b5b4 commit bb6924c

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

packages/fedify/tsdown.config.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,20 @@ export default [
3535
},
3636
}),
3737
defineConfig({
38-
entry: ["./src/testing/mod.ts"],
39-
external: [/^node:/],
38+
entry: [
39+
"./src/testing/mod.ts",
40+
...(await Array.fromAsync(glob(`src/**/*.test.ts`)))
41+
.map((f) => f.replace(sep, "/")),
42+
],
43+
external: [/^node:/, "@fedify/fixture"],
44+
// Bundle @fedify/fixture back in for src/testing/ files (needed for
45+
// cfworkers), while keeping it external for test files so that
46+
// pnpm pack --recursive does not try to resolve the private package:
47+
noExternal: (id: string, importer: string | undefined) => {
48+
if (id !== "@fedify/fixture") return false;
49+
const normalized = importer?.replaceAll(sep, "/");
50+
return normalized?.includes("/testing/") ?? false;
51+
},
4052
inputOptions: {
4153
onwarn(warning, defaultHandler) {
4254
if (
@@ -57,18 +69,6 @@ export default [
5769
`,
5870
},
5971
}),
60-
defineConfig({
61-
entry: (await Array.fromAsync(glob(`src/**/*.test.ts`)))
62-
.map((f) => f.replace(sep, "/")),
63-
external: [/^node:/, "@fedify/fixture"],
64-
outputOptions: {
65-
intro: `
66-
import { Temporal } from "@js-temporal/polyfill";
67-
import { URLPattern } from "urlpattern-polyfill";
68-
globalThis.addEventListener = () => {};
69-
`,
70-
},
71-
}),
7272
];
7373

7474
// cSpell: ignore onwarn

0 commit comments

Comments
 (0)