← Home ← Codex ← DEBT
Browse by Category
+ added · updated 7d
← Back to glossary

JavaScript Bundling — Vite, Webpack, esbuild

JavaScript ES2015 Intermediate
debt(d7/e5/b5/t7)
d7 Detectability Operational debt — how invisible misuse is to your safety net

Closest to 'only careful code review or runtime testing' (d7). The detection_hints note automated=no, and the tools listed (lighthouse, webpack-bundle-analyzer) are post-hoc performance/analysis tools rather than pre-deployment guards. Serving unbundled modules or hardcoded filenames won't fail at build time — it silently degrades performance or breaks cache-busting only visible through manual audit or Lighthouse runs.

e5 Effort Remediation debt — work required to fix once spotted

Closest to 'touches multiple files / significant refactor in one component' (e5). The quick_fix points to adopting Laravel's @vite() directive or reading manifest.json, but fixing the common mistakes (unbundled production assets, hardcoded filenames across PHP templates, dist/ in git, CI build pipeline setup) requires changes across multiple PHP templates, build configuration, and CI scripts — beyond a single-line patch but short of a full architectural rework.

b5 Burden Structural debt — long-term weight of choosing wrong

Closest to 'persistent productivity tax' (b5). The applies_to context is web broadly, and the bundler choice (Vite vs Webpack vs esbuild) plus the asset manifest integration pattern shapes how every PHP template references JS/CSS assets. Misconfiguration or inconsistency imposes an ongoing tax on deployments and onboarding, but it doesn't fundamentally redefine the entire system's architecture.

t7 Trap Cognitive debt — how counter-intuitive correct behaviour is

Closest to 'serious trap' (t7). The misconception field explicitly states developers believe PHP can serve unbundled ES module files directly — a belief that contradicts how production web performance and HTTP/2 actually behave. The 'obvious' approach (just serve the files) appears to work locally in modern browsers but fails in production at scale. This contradicts assumptions developers carry from other contexts (e.g. simple script tags working fine in small projects).

About DEBT scoring →

Also Known As

Vite Webpack esbuild bundler Laravel Mix Laravel Vite

TL;DR

Bundlers combine JS modules into optimised files served by PHP — Vite for dev speed, Webpack for complex pipelines, esbuild for raw performance.

Explanation

PHP serves static assets (JS, CSS) either directly or via a bundler output. Vite (Rollup-based): instant dev server with HMR, fast production builds — recommended for new projects. Webpack: mature, rich plugin ecosystem, complex config — used in Laravel Mix. esbuild: Go-based, 10-100x faster than Webpack, minimal config. Laravel Vite plugin: integrates Vite with PHP's asset manifests. Bun: JS runtime + bundler. All output a manifest.json (or similar) mapping source files to hashed production filenames PHP uses.

Common Misconception

PHP can serve unbundled JavaScript module files directly in production — browsers require many HTTP/2 requests for unbundled ES modules; a bundler reduces this to a few optimised files with tree-shaking and minification.

Why It Matters

PHP projects using modern JavaScript need a bundler to produce optimised assets — understanding Vite's asset manifest lets PHP correctly reference hashed filenames for cache-busting.

Common Mistakes

  • Serving unbundled node_modules in production
  • Not using the asset manifest for PHP template references
  • Committing dist/ folder to git instead of building in CI

Code Examples

✗ Vulnerable
<!-- Referencing src file directly — no cache busting, no minification: -->
<script src="/resources/js/app.js"></script>
✓ Fixed
<!-- Vite manifest.json: {"resources/js/app.js": {"file": "assets/app.Abc123.js"}} -->

<!-- PHP reads manifest for hashed filename: -->
<?php
$manifest = json_decode(file_get_contents(public_path('build/manifest.json')), true);
$appJs = $manifest['resources/js/app.js']['file'];
?>
<script src="/build/<?= $appJs ?>" type="module"></script>
<!-- Or use Laravel's @vite('resources/js/app.js') directive -->

Added 17 Mar 2026
Edited 22 Mar 2026
Views 66
Rate this term
No ratings yet
🤖 AI Guestbook educational data only
| |
Last 30 days
0 pings T 1 ping W 1 ping T 0 pings F 1 ping S 0 pings S 0 pings M 0 pings T 0 pings W 1 ping T 4 pings F 2 pings S 3 pings S 2 pings M 1 ping T 0 pings W 0 pings T 0 pings F 0 pings S 0 pings S 0 pings M 0 pings T 1 ping W 0 pings T 0 pings F 2 pings S 0 pings S 2 pings M 0 pings T 0 pings W
No pings yet today
No pings yesterday
Scrapy 11 Amazonbot 9 Google 6 Perplexity 5 SEMrush 5 Ahrefs 4 ChatGPT 3 Unknown AI 2 Claude 2 Bing 2 Majestic 1 Meta AI 1 PetalBot 1
crawler 48 crawler_json 4
DEV INTEL Tools & Severity
🟡 Medium ⚙ Fix effort: Medium
⚡ Quick Fix
Use Laravel's @vite() directive or read the Vite manifest.json in PHP to reference correctly hashed asset filenames
📦 Applies To
javascript ES2015 web laravel
🔗 Prerequisites
🔍 Detection Hints
PHP templates hardcoding JS filenames without reading asset manifest; node_modules referenced directly in production HTML
Auto-detectable: ✗ No lighthouse webpack-bundle-analyzer
⚠ Related Problems
🤖 AI Agent
Confidence: Low False Positives: Medium ✗ Manual fix Fix: Medium Context: File


✓ schema.org compliant