fix: remove pnpm prune from Dockerfile (runtime deps in devDeps) - #11
Closed
stubbi wants to merge 4 commits into
Closed
fix: remove pnpm prune from Dockerfile (runtime deps in devDeps)#11stubbi wants to merge 4 commits into
stubbi wants to merge 4 commits into
Conversation
Switch all workspace package exports from src/*.ts to dist/*.js so the server runs on precompiled JavaScript without needing tsx as a runtime transpiler. Changes: - All package.json exports fields now point to dist/ (previously pointed to src/ for development convenience, with publishConfig overriding for npm publish) - Dockerfile CMD changed from node --import tsx/loader to node directly - Dockerfile now prunes devDependencies (tsx no longer needed at runtime) - Selective dist-only COPY in production stage works correctly now Benefits: - Faster startup (no runtime transpilation) - Smaller image (no tsx, no TypeScript source in production) - No devDependencies shipped - More secure (no source code in production image) - Reproducible (compiled output is deterministic) Verified: server starts and runs correctly with node server/dist/index.js without tsx loader. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
TypeScript resolves types via the "types" condition (pointing to src/*.ts for zero-build typechecking), while Node resolves runtime imports via the "import" condition (pointing to dist/*.js). This lets pnpm -r typecheck work without building first, while the runtime still uses precompiled output. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Use Node's --conditions flag to switch between source and compiled output: - "default" → ./src/*.ts (dev, tests, typecheck — no build needed) - "production" → ./dist/*.js (Docker, deployed environments) Dockerfile CMD uses --conditions=production so Node resolves workspace imports to precompiled dist/ output. Dev tools (vitest, tsx, tsc) use the default condition and resolve to source. Verified: typecheck passes, 569 tests pass, server starts with --conditions=production without tsx. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Upstream lists runtime deps like drizzle-orm in devDependencies. Pruning removes them, causing ERR_MODULE_NOT_FOUND at runtime. Image size is controlled by the selective COPY in the production stage instead. Co-Authored-By: Claude Opus 4.6 (1M context) <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.
Production is in CrashLoopBackOff — drizzle-orm pruned but needed at runtime.