feat(push): warn on npm --omit=dev + tsc build script (typescript compilation trap)#1252
Draft
DaveHanns wants to merge 1 commit into
Draft
feat(push): warn on npm --omit=dev + tsc build script (typescript compilation trap)#1252DaveHanns wants to merge 1 commit into
DaveHanns wants to merge 1 commit into
Conversation
…pilation trap) A common packaging mistake when moving a local TypeScript Actor to the Apify platform: a single-stage Dockerfile runs `npm install --omit=dev` (or `--production`), then `npm run build` shells out to `tsc` — but `typescript` lives in devDependencies, so it was just dropped. The platform-side Docker build fails with an opaque "tsc: not found" and the user has to guess. This adds a best-effort local sanity check to `apify push` that inspects the Dockerfile and package.json before upload and emits a yellow warning (not an error) when all three conditions hold: (1) `.actor/Dockerfile` or `./Dockerfile` contains a dev-dep-dropping `npm ci|install|i --omit=dev` (or `--production`), (2) `scripts.build` shells out to a standalone `tsc` (not tsc-alias, tsdown, etc.), and (3) `typescript` is in devDependencies but not in dependencies. The warning points to the two standard fixes: multi-stage Dockerfile with a build stage that keeps devDeps, or drop `--omit=dev`. Push is never blocked — the platform build remains the source of truth. Companion to apify/apify-docs #2716 (docs side of the same finding). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add a pre-upload sanity check in
apify pushthat warns (never blocks) whenthe project's Dockerfile drops devDependencies before running a
tsc-basedbuild. This is one of the most common "worked locally, fails on the platform"
traps for TypeScript Actors, and the platform build error (
tsc: not found)gives no hint that the fix is on the Dockerfile side.
Companion PR to apify/apify-docs #2716 (documents the same trap). Finding
F30-companionfrom the agentic-actor-development eval sweep.What changes
src/commands/actors/push.tsdetectOmitDevTscTrap(cwd)— pure function, returnsa warning message or
null. Handles both.actor/Dockerfileand./Dockerfile, folds backslash line-continuations, matches both--omit=devand--production, and refuses to fire ontsc-alias,tsdown, or whentypescriptis duplicated intodependencies.run()handler calls it right after the "Deploying Actor" log lineand emits the message through the existing yellow
warning()outputhelper (goes to stderr). Push proceeds either way.
test/local/commands/push.test.tsguards (typescript in both, no
--omit, non-tscbuild, missingDockerfile / malformed package.json).
Design notes:
still authoritative, and we don't want a heuristic to block anyone.
existsSync+try/catchso a missing orunreadable Dockerfile / package.json silently no-ops.
tscregex is a word-boundary-ish match(^|[\s&|;])tsc($|[\s&|;])so we don't false-positive on
tsc-alias,tsconfig-paths,tsdown, etc.Test plan
oxlint --type-awareclean onpush.tsandpush.test.tstsc --noEmit -p .cleanapify pushin a project with a single-stage--omit=devDockerfile +tscbuild script and confirm the yellowwarning appears before the upload phase
apify pushin a well-configured multi-stage project andconfirm no warning fires
Cross-references
F30-companion(agentic-actor-development eval sweep)