Skip to content

Replace Webpack dev server with zero-dependency alternative#11485

Merged
aduth merged 5 commits intomainfrom
aduth-webpack-server
Nov 12, 2024
Merged

Replace Webpack dev server with zero-dependency alternative#11485
aduth merged 5 commits intomainfrom
aduth-webpack-server

Conversation

@aduth
Copy link
Copy Markdown
Contributor

@aduth aduth commented Nov 8, 2024

🛠 Summary of changes

Implements a lightweight, zero-dependency alternative to webpack-dev-server.

Why?

webpack-dev-server is pretty feature rich, but we use very few of its features. Arguably, we could get rid of it altogether and everything would be fine, but some features like pausing the request while compilation is in-progress are useful to improve confidence during development when testing changes.

Of note is that webpack-dev-server creates a very deep dependency tree because it's implemented as an Express-based web server. Moving away from it has additional benefits:

  • Decreases risk and maintenance burden for security advisories. Express and related dependencies are frequent targets for security advisories, and consequently these security advisories bubble up through webpack-dev-server. All 9 of the 9 open security advisories trace back to webpack-dev-server.
  • Decreases inherent risk and installation time for third-party dependencies. Dropping webpack-dev-server drops 133 dependencies (!!!)†, and reduces the size of yarn.lock by 996 lines (-40kb / -12%).

Counted via: git diff main -- yarn.lock | tail -n +5 | grep -E "^-\S" | wc -l minus git diff main -- yarn.lock | tail -n +5 | grep -E "^\+\S" | wc -l

📜 Testing Plan

Verify that JavaScript continues to compile and behave as expected in local development:

  1. rm -rf public/packs
  2. make run
  3. Go to http://localhost:3000
  4. Verify that JavaScript behaviors still work (e.g. "Here's how you know" banner collapse, language selector, field validation, etc).

Copy link
Copy Markdown
Contributor

@zachmargolis zachmargolis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM big fan! small questions, not blockers

@aduth aduth force-pushed the aduth-webpack-server branch from 9d62496 to 739d4cb Compare November 12, 2024 19:11
@aduth aduth merged commit 6203156 into main Nov 12, 2024
@aduth aduth deleted the aduth-webpack-server branch November 12, 2024 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants