Skip to content

Commit 5cf331f

Browse files
committed
fix(cli): stop the bundle archiver dropping the indexer entry points
The bundler emits the controller entry points at paths mirroring the CLI's install location, which contains a node_modules segment when the CLI runs via npx. The archiver's blanket node_modules exclusion silently stripped them from the uploaded bundle, so the image build failed at the indexer stage with MODULE_NOT_FOUND. Only .DS_Store is excluded now.
1 parent e5f316a commit 5cf331f

2 files changed

Lines changed: 35 additions & 6 deletions

File tree

packages/cli-v3/src/deploy/bundleArchive.test.ts

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,23 @@ describe("createBundleArchive", () => {
6060
expect(skill).toBe("# skill");
6161
});
6262

63-
it("excludes node_modules and .DS_Store but nothing else", async () => {
63+
it("excludes only .DS_Store — node_modules paths must survive", async () => {
6464
await writeFile(join(bundleDir, "build.json"), "{}");
6565
await writeFile(join(bundleDir, ".DS_Store"), "junk");
66-
await mkdir(join(bundleDir, "node_modules", "leftover"), { recursive: true });
67-
await writeFile(join(bundleDir, "node_modules", "leftover", "index.js"), "x");
66+
// The bundler emits controller entry points at paths mirroring the CLI's
67+
// install location — under npx that contains a node_modules segment. Those
68+
// files are load-bearing (the Containerfile's indexer stage runs them).
69+
const controllerDir = join(
70+
bundleDir,
71+
".npm",
72+
"_npx",
73+
"abc123",
74+
"node_modules",
75+
"trigger.dev",
76+
"dist"
77+
);
78+
await mkdir(controllerDir, { recursive: true });
79+
await writeFile(join(controllerDir, "managed-index-controller.mjs"), "x");
6880
// dist-like names must NOT be excluded — the bundle IS build output
6981
await mkdir(join(bundleDir, "dist"), { recursive: true });
7082
await writeFile(join(bundleDir, "dist", "chunk.mjs"), "x");
@@ -77,7 +89,22 @@ describe("createBundleArchive", () => {
7789
await tar.extract({ file: archivePath, cwd: extractDir });
7890

7991
const rootEntries = (await readdir(extractDir)).sort();
80-
expect(rootEntries).toEqual(["build.json", "dist"].sort());
92+
expect(rootEntries).toEqual(["build.json", "dist", ".npm"].sort());
93+
94+
const controller = await readFile(
95+
join(
96+
extractDir,
97+
".npm",
98+
"_npx",
99+
"abc123",
100+
"node_modules",
101+
"trigger.dev",
102+
"dist",
103+
"managed-index-controller.mjs"
104+
),
105+
"utf-8"
106+
);
107+
expect(controller).toBe("x");
81108
});
82109

83110
it("throws when the bundle dir is empty", async () => {

packages/cli-v3/src/deploy/bundleArchive.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ import { logger } from "../utilities/logger.js";
55
// The bundle dir is generated build output (bundled JS, synthesized package.json,
66
// build.json, Containerfile, .trigger/skills). Unlike the source-context archiver,
77
// it must NOT apply the usual build-output ignores (dist, build, .trigger) — those
8-
// would strip the bundle itself. Only genuinely unwanted entries are excluded.
9-
const BUNDLE_IGNORES = ["**/node_modules", "**/.DS_Store"];
8+
// would strip the bundle itself. node_modules must NOT be excluded either: the
9+
// bundler emits the controller entry points at paths mirroring the CLI's install
10+
// location, which contains a node_modules segment when the CLI runs via npx.
11+
const BUNDLE_IGNORES = ["**/.DS_Store"];
1012

1113
/**
1214
* Archives a pre-built bundle directory (the buildWorker destination) so its

0 commit comments

Comments
 (0)