agentleFS
0avi0avi/skills/angular-webpack-esbuild-migration/SKILL.md

angular-webpack-esbuild-migration

Skill1 starsChanged 3 months agoMITView on GitHub

Migrates an Angular project off a webpack-based builder (@angular-builders/custom-webpack, or @angular-devkit/build-angular:browser) to Angular's native esbuild builder - the application builder, or browser-esbuild as a stepping stone. Trigger when moving an Angular app off webpack or custom-webpack, switching to the application or esbuild builder, speeding up slow Angular production builds, removing webpack.config.js / babel-loader / core-js polyfills, moving Karma to the Jest builder, or fixing the errors that appear after the switch - TS2307 on package "/src/" or "/dist/" imports, TS2612 "will overwrite the base property", TS2729 "used before its initialization", zone.js/dist paths, SCSS "~" url() paths, a stray "browser/" output subfolder, or CommonJS bundle warnings. Works for any Angular version and any repo state, including multi-project workspaces and partially migrated repos.

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 2 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Every reference carries a ## Version notes section stating what changes across Angular majors, and a ## Gotchas list of the specific …

    line 28
  2. Very specific:

    Step 1: Read the Angular major from package.json (@angular/core), not from a global CLI install - a globally installed CLI is frequently a …

    line 32
  3. Distinctive:

    Read angular-versions.md for the full matrix, the repo-state rules, and the Karma-versus-Jest decision.

    line 40
  4. Distinctive:

    Migration Checklist: Every rule in one scannable list, plus the five that cause the most damage and the typical before/after metrics.

    line 86

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Angular webpack → esbuild Migration Guidelines

Covers any Angular version currently on a webpack builder. The destination is the esbuild application builder on Angular 17+, or browser-esbuild as a stepping stone on 16.

  1. Always determine the Angular major and the destination builder before editing anything. The builder's package name changed at 20, the application builder does not exist before 17, and the option shapes differ between them. Advice that is correct on 19 will not load on 16.
  2. Inventory first and let it set the scope. Which steps apply depends entirely on what the project actually uses. Never work the steps blind - read angular.json, webpack.config.js, polyfills.ts, tsconfig.json and package.json, and run the inventory sweep in audit-and-baseline.md, before editing anything.
  3. The new compiler errors are real bugs, not migration noise. TS2612 and TS2729 are genuine defects the webpack build silently swallowed. Fix the code. Never reach for @ts-ignore, @ts-nocheck, skipLibCheck, or a loosened tsconfig - that moves a compile failure to runtime.
  4. On Windows, never mass-edit with sed -i. In Git Bash it rewrites every scanned file to LF, producing thousands of spurious diffs that bury the real ones. Use PowerShell's [System.IO.File]::ReadAllText/WriteAllText, which preserves each file's original line endings, or targeted single-file edits. See troubleshooting.md T8.
  5. Build after every batch of fixes, never once at the end. Each build reveals the next layer of errors. Fixing blind and building once wastes time and buries the signal.
  6. A green build is not a finished migration. The dev server must start, tests must compile, the output must land where the backend serves it, and the UI must be smoke-tested. See checklist.md.
  7. Every step is idempotent. On a partially migrated repo, re-run the inventory sweep and do only what it still finds; repeating a completed step is a no-op. Commit or stash first so the diff stays reviewable.

Every reference carries a ## Version notes section stating what changes across Angular majors, and a ## Gotchas list of the specific mistakes agents make in that area. Read the gotchas even when skimming.

Determining the Destination Builder

Step 1. Read the Angular major from package.json (@angular/core), not from a global CLI install - a globally installed CLI is frequently a different major.

Step 2. Map the major to a destination builder - 20+ @angular/build:application, 17-19 @angular-devkit/build-angular:application, 16 @angular-devkit/build-angular:browser-esbuild, below 16 upgrade Angular first. Use whichever package name exists in the installed CLI.

Step 3. Confirm the current builder actually contains webpack. If it does not, this skill probably does not apply - stop and confirm with the user rather than migrating something already migrated.

Step 4. In a multi-project workspace, resolve this per project. Migrate every projectType: "application"; leave every projectType: "library" alone - libraries build with ng-packagr, not the browser or esbuild builder.

Read angular-versions.md for the full matrix, the repo-state rules, and the Karma-versus-Jest decision.

The Migration, In Order

#StepRead
0Angular major, destination builder, repo stateangular-versions.md
1Inventory the workspace, capture a baseline to measure againstaudit-and-baseline.md
2Resolve peer deps, remove webpack-era packages, clean the npm scriptspackages.md
3Swap the builders, fix outputPath, delete webpack.config.jsangular-json.md
4Strip polyfills.ts back to what evergreen browsers needpolyfills.md
5Retarget the tsconfigs - moduleResolution: "bundler" is the load-bearing changetypescript-config.md
6Fix SCSS ~ prefixes and url() resolutionstyles-and-assets.md
7Optionally move Karma to the Jest buildertest-runner.md
8Work the build errors - the longest steptroubleshooting.md
9Gate before declaring the migration donechecklist.md

Steps 2-7 are edits and step 8 is a loop; interleave them. Do not batch all the edits and build once.

Out of scope: replacing CommonJS dependencies with ESM equivalents. CJS packages produce warnings, not errors - allowedCommonJsDependencies handles them and the build succeeds. Swapping lodash for lodash-es or moment for date-fns is general dependency hygiene that would be equally valid on webpack, and each swap is an API change with its own regression risk. The one place it connects is T10, where a lost webpack optimisation plugin causes a bundle regression whose proper fix is an ESM-native replacement. Record that regression and treat the replacement as separate work.

Expect roughly 50-70 % faster production builds and the removal of the webpack, babel and IE-polyfill dependency tree. Expect also a set of pre-existing defects the lenient webpack compiler hid. Both halves are normal.

When the Build Throws Errors

Each entry in troubleshooting.md is symptom → cause → fix. Index by the error you actually have:

Error / symptomEntry
ERESOLVE on installT1
TS2307 on pkg/src/... or pkg/dist/...T2
TS2612 will overwrite the base propertyT3
TS2729 used before its initializationT4
Could not resolve "~assets/...", or a wrong relative pathT5
Blank page or 404 after a successful buildT6
TS2307 on zone.js/dist/...T7
Thousands of CRLF/LF "changes" on WindowsT8
Non-ESM / CommonJS warningsT9
Bundle grew - a webpack plugin has no esbuild equivalentT10
async not exported from @angular/core/testingT11
Jest builder: duplicate spec filenames collideT12
Jest builder: Windows path-quoting validation errorT13
"Test suite must contain at least one test"T14

Checklist

  • Migration Checklist: Every rule in one scannable list, plus the five that cause the most damage and the typical before/after metrics. Use this as the gate before declaring Phase 1 done. Read checklist.md

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.