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 was referenced Jul 13, 2026
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) when the project's Dockerfile drops devDependencies before running atsc-based build. 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.What changes
src/commands/actors/push.tsdetectOmitDevTscTrap(cwd)— pure function, returns a warning message ornull. 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 line and emits the message through the existing yellowwarning()output helper (goes to stderr). Push proceeds either way.test/local/commands/push.test.ts--omit, non-tscbuild, missing Dockerfile / malformed package.json).Design notes:
existsSync+try/catchso a missing or unreadable Dockerfile / package.json silently no-ops.tscregex is a word-boundary-ish match(^|[\s&|;])tsc($|[\s&|;])so we don't false-positive ontsc-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 yellow warning appears before the upload phaseapify pushin a well-configured multi-stage project and confirm no warning firesRelated — coordinated remediation stack
Four defense layers, each covering a different failure mode:
apify/actor-templates— ts-* Dockerfiles ship a multi-stage build (already in master via #592, Dec 2025). Users ofapify create -t ts-*cannot hit the trap.apify pushpreflight warning when a Dockerfile has--omit=devbeforenpm run buildthat invokestsc.apify/apify-cli#1261—apify createforces--include=dev+NODE_ENV=developmenton the post-scaffold install, soapify runworks locally.apify/apify-docs#2716— docs callout on the Source-code page for the direct-docker build/ search-fallback case.Surfaced during an evaluation of Apify surfaces for agent-driven Actor development.