← Back to Pull requests

feat(compiler): add bundleDependencies option to the rspack builder #3683

Closed
unknown closed this pull request without merging on Nov 16, 2026 08:05 UTC
View on GitHub
unknown unknown commented on Nov 08, 2026 17:09 UTC
Author

PR Checklist


Please check if your PR fulfills the following requirements:

  • The commit message follows our guidelines: https://github.com/nestjs/nest/blob/master/CONTRIBUTING.md

  • Tests for the changes have been added (for bug fixes / features)

  • Docs have been added / updated (for bug fixes / features)
  • PR Type


    What kind of change does this PR introduce?

    [ ] Bugfix
    [x] Feature
    [ ] Code style update (formatting, local variables)
    [ ] Refactoring (no functional changes, no api changes)
    [ ] Build related changes
    [ ] CI related changes
    [ ] Other... Please describe:
    

    What is the current behavior?

    rspack builder keeps all of node_modules external, so prod image needs full dependency tree next to dist. Bundling it today means hand written config: no webpack-node-externals, builtins as node-commonjs for ESM, IgnorePlugin for optional peers, native addons kept external with own package.json. And even then ESM deps that load CJS peers with createRequire(import.meta.url) keep build machine path in the bundle, so it runs only where it was built

    Issue Number: N/A

    What is the new behavior?

    New opt-in compilerOptions.bundleDependencies for rspack builder, or nest build --bundle-dependencies / --no-bundle-dependencies (nest start too):

    { "compilerOptions": { "builder": "rspack", "bundleDependencies": true } }
    

  • false (default) - same as now, only the app is compiled

  • true - everything is bundled except Node builtins, packages with native addons and swagger-ui-dist (served from disk). Those are pinned in emitted dist/package.json, npm install --omit=dev there installs only them

  • { exclude: ['typeorm'] } - same, but listed packages stay external too, for deps that don't survive bundling
  • Flag overrides config, but keeps configured exclude. With other builders it warns like typeCheck does with non swc. In bundle mode createRequire calls are parsed, known optional packages are ignored only when not installed, and build prints what was ignored and what stays external. Unit specs cover all modes

    Does this PR introduce a breaking change?


    [ ] Yes
    [x] No
    

    Other information

    terminus needs nestjs/terminus#2790 to run bundled. Docs: nestjs/docs.nestjs.com#3746 (draft, to merge with release)

    Numbers and details in comments below

    Diff: 294 lines (+220 / -74) across 3 files Reviewer: kamilmysliwiec Review duration: 10976m
    All Vouch review confidence checks passed
    Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 294 lines diff across 3 files
    0.40
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.340
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #3683"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 39.9% (MEDIUM) · Higher = larger blast radius
    39.9%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 15.8% · Safe to merge
    15.8%