davidantoon/davnx/davnx-webpack
Claude Code and agent skill by davidantoon/davnx
- community
Checking that the SKILL.md file is still in the repository.
Guide for setting up NestJS server projects with @davnx/webpack build and serve executors. Use this skill whenever a user needs to configure an Nx project with @davnx/webpack, create a main entry file with devserver support, add worker processes (queue consumers, event listeners), configure bundling with orgScopes, set up gateway middleware, or troubleshoot webpack-based NestJS builds. Also use when the user mentions davnx, webpack executors, devserver mode, createChildApp, or worker entry poin…
Install
npx vskill@latest install davidantoon/davnx/davnx-webpackSKILL.md
The same SKILL.md was published earlier as davidantoon/davnx/davnx-webpack.
@davnx/webpack — NestJS Build & Serve Setup Guide
Custom Nx executors for building and serving NestJS applications with webpack. Provides production builds with full optimization and a multi-process dev server with hot module reload.
Architecture Overview
The dev server uses a parent/child architecture:
- Parent listens on a stable public port, proxies requests via round-robin to healthy children
- Children (
APP_RUNNER=1) load the webpack bundle, callglobal.createChildApp()to bootstrap NestJS, and listen on Unix sockets - Workers are standalone processes that run compiled worker bundles — they do NOT bind to any port and are restarted on each reload
Quick Start
1. Configure project.json
2. Create a Dual-Mode Entry Point (src/main.ts)
The entry file must support two modes: standalone (production) and devserver (development). The devserver sets DEVSERVER_MODE=1 and expects global.createChildApp to be a factory function.
The BuiltChildApp contract is critical — the devserver expects:
handler: rawhttp.RequestListener(from Fastify or Express)serviceConfig: object withport(can be0in dev)close(): graceful shutdown — called when the devserver hot-swaps to a new bundle
3. Run
Workers
Workers are background processes — queue consumers, event listeners, scheduled jobs. They must NOT bind to any HTTP port. They are compiled as separate webpack entry points and run as standalone child processes managed by the devserver parent.
Configuring Workers
Add the workers array to both build and serve targets:
name— output filename without.jsextension (e.g.,"queue-processor"→queue-processor.js)entryPath— path to the worker entry file,./paths are relative to project root
Worker Entry File Pattern
Use NestFactory.createApplicationContext() (not create()) since workers don't need an HTTP adapter. The process stays alive as long as there are active event listeners (queue connections, timers, etc).
Worker Lifecycle
| Phase | Build (nx build) | Serve (nx serve) | |
|---|---|---|---|
| Compile | Webpack bundles [name].js alongside main.js | Webpack watch compiles all entries together | |
| Minify | Terser post-processes worker bundles | Skipped in dev | |
| Run | Not started (deploy separately) | Parent devserver forks each worker as a child process | |
| Reload | N/A | Workers are killed and respawned on each webpack rebuild |
Bundling Control
By default, all node_modules are externalized (not bundled). Use orgScopes and bundlePackages to override this for packages that must be bundled.
orgScopes
Controls which packages are bundled instead of externalized. Supports 4 modes:
| Pattern | Matches | Example | |
|---|---|---|---|
@myorg | All packages under the org | @myorg/foo, @myorg/bar | |
@myorg/prefix | Packages with that prefix | @myorg/prefix-a, @myorg/prefix-b | |
/^regex/ | Custom regex | /^@internal\/.*/ | |
lodash | Exact package + subpaths | lodash, lodash/merge |
bundlePackages
Force specific packages to be bundled:
nodeExternalsConfig
Fine-grained control over webpack-node-externals:
Dev Server Options
Gateway Middleware
Simulate an API gateway locally by injecting headers before requests are proxied to the NestJS app. The middleware runs in the parent process.
The middleware file must export a function:
servePrefix
Mimics production gateway path routing. When set, the devserver enforces that all requests start with /{prefix}/ — requests without it get a 404, matching production behavior.
Result: http://localhost:3050/my-service/health works, http://localhost:3050/health returns 404.
serviceName
Overrides the service name used for config YAML resolution and socket directory naming. Does not affect URL prefix — use servePrefix for that.
configEnv
Selects which config YAML to load: config/config.{configEnv}.yaml. Defaults to "development". Useful for running different configurations locally:
childCount
Number of HTTP child processes. Defaults to 1. Increase to test round-robin load balancing locally.
Hot-Reload Gotchas
Externalized AsyncLocalStorage singletons
If a library you depend on creates an AsyncLocalStorage and calls .enterWith(...) once at module top-level (e.g. @frontegg/context, or many request-scoping libs), and that package is externalized (default for everything in node_modules), then:
- First boot works —
enterWithruns, the store is set. - After a hot reload, the bundle is re-evaluated but the externalized module is reused from
require.cache. Its top-level code does NOT run again — no freshenterWith. The new app's bootstrap runs in a different async chain wheregetStore()isundefined. Code paths that doscope.get(...)(typically logger middleware fired fromonModuleInit) crash with:
`` TypeError: Cannot read properties of undefined (reading 'get') ``
…and the devserver reports No healthy children available.
Fix — in your bundle entry (or wherever runs every reload), re-enter the store before bootstrap. Only the bundled side knows which library to fix up, so this belongs in the app, not the devserver:
See examples/main-entry.md → Re-entering AsyncLocalStorage on reload for the full pattern.
Reference Files
For complete schema details, read:
references/build-schema.md— all build executor options with types and defaultsreferences/serve-schema.md— all serve executor options with types and defaults
For real-world code patterns, read:
examples/project-json.md— project.json configurations (minimal, with workers, multiple serve targets)examples/main-entry.md— main.ts patterns (minimal HTTP, NestJS+Fastify, with bootstrap utilities)examples/worker-entry.md— worker patterns (minimal, NestJS queue consumer)examples/gateway-middleware.md— gateway middleware with JWT decoding
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckinglibs/webpack/skills/davnx-webpack/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/davidantoon/davnx/davnx-webpack)