Skip to content

Replace Bower with npm/webpack across dev, prod, and unit tests#1116

Merged
catinhere merged 19 commits into
masterfrom
task/bower-migration
Jul 8, 2026
Merged

Replace Bower with npm/webpack across dev, prod, and unit tests#1116
catinhere merged 19 commits into
masterfrom
task/bower-migration

Conversation

@catinhere

Copy link
Copy Markdown
Contributor

Replace Bower with npm/webpack across the entire frontend build pipeline (dev bundling, prod bundling, and unit tests) and delete bower.json/bower_components.

  • Dev mode: JS/CSS bundling moved from Bower + wiredep's <script>/<link> tag injection to webpack (webpack-entry.js/webpack.config.js), invoked via npm run build:dev. tincan.js and pdf.js-viewer stay outside the webpack bundle (see code comments for why) and are copied from node_modules via gulp instead.
  • Prod mode: gulpfile.js's existing concat/uglify/rev pipeline is unchanged in mechanism, just repointed from bower_components/ to node_modules/, using each package's actual browser-ready file rather than its "main" field (several packages' "main" is a CommonJS-only wrapper that throws when concatenated raw).
  • Unit tests: karma.conf.js moved off wiredep/bower.json onto karma-webpack, reusing the same webpack config as dev mode via a new karma-entry.js that auto-discovers spec files with require.context. No spec files needed
    require() calls added, except for the 9 beforeEach(module(...)) calls changed to angular.mock.module(...), since webpack's own module binding shadows angular-mocks' global helper of the same name.
  • Bower removed entirely: bower.json deleted, Dockerfile/.gitignore/gulpfile.js cleaned of now-dead references, bower/gulp-bower/wiredep/main-bower-files uninstalled.

catinhere added 10 commits July 2, 2026 15:39
Add npm equivalents (or git-tag pins) for all 29 bower.json dependencies, ahead of replacing Bower/wiredep with webpack. Vendor ng-breadcrumbs directly since it was never published to npm and its repo has no package.json. Drop navigator-sendbeacon entirely: its polyfill only patches navigator.sendBeacon when the browser lacks a native implementation, and every supported browser has provided one natively since 2015-2016, so that branch never runs.
Adds `webpack.config.js` and a new entry point that requires all service files (auto-discovered via `require.context`, since dev and prod previously used two different manual orderings and both worked - modules just need to load before directives/services, which they now do explicitly).

Also fixes two pre-existing bugs this surfaced: `rich-content-directive.js` called `app.directive(...)` instead of `module.directive(...)`, which only "worked" before because angular-timer leaked a global `app` variable by accident; and `angular-chosen-localytics` needs `chosen-js` loaded separately as its own package, which wasn't happening.

`index-dev.html` now loads one bundled script instead of ~68 individual tags. CSS, `tincanjs`, and `pdf.js-viewer` remain on the old Bower-served paths for now.
Extracts CSS to a real file (mini-css-extract-plugin) instead of style-loader's runtime injection, since the latter landed after compair.less in the DOM and broke the app's font-family overrides. Also adds humanize-duration and window.jQuery to webpack-entry.js/ProvidePlugin - both were still missing pieces the old Bower setup supplied as separate globals, only surfacing once those features (timer countdown, angular.element) were actually exercised.
`ng-file-saver` reads `window.saveAs` directly instead of `require()`'ing `file-saver` itself, and `npm` had resolved the wrong version (1.3.8 vs the 2.0.4 Bower actually used) since `ng-file-saver`'s `package.json` and `bower.json` disagree on the range. Pins `file-saver@2.0.4` and requires it explicitly - same category as the `chosen-js/humanize-duration` fixes, a Bower-transitive companion script that needed a global.

Verified via the classlist "Export Users" button: a real CSV now downloads instead of throwing "saveAs is not supported"
@greptile-apps

greptile-apps Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR replaces the old Bower frontend pipeline with npm and webpack. The main changes are:

  • Webpack bundles the AngularJS app and npm-managed vendor assets.
  • Gulp now copies standalone assets like tincan.js and pdf.js viewer files from node_modules.
  • Production templates load the new webpack CSS and JS bundles.
  • Unit tests run through karma-webpack with a shared webpack entry.
  • Bower config, dependencies, and generated paths were removed.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
compair/templates/index-dev.html Loads the dev webpack bundle, keeps tincan.js as a standalone script, and updates the IE warning.
compair/templates/index.html Loads the revved production webpack assets and standalone tincan.js file.
compair/static/webpack-entry.js Adds the webpack entry that imports vendor CSS, AngularJS dependencies, app config, modules, directives, and services.
gulpfile.js Reworks asset tasks to use npm sources and prepares standalone files for dev and production builds.
compair/static/test/config/karma.conf.js Switches unit test loading from Bower-injected files to a webpack-preprocessed test entry.

Reviews (3): Last reviewed commit: "Document webpack step in the production ..." | Re-trigger Greptile

Comment thread compair/templates/index-dev.html
@catinhere

Copy link
Copy Markdown
Contributor Author

@greptileai

@catinhere

Copy link
Copy Markdown
Contributor Author

@greptileai

@catinhere

catinhere commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

Updated:

  • Removed IE related code in index.html and index-dev.html
  • Final image should be getting the JS and CSS from webpack now. Deployed to staging to test. Feel free to take a look!

@ionparticle ionparticle left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Great work, bower was deeply integrated, so I'm sure this was complicated. This is very much appreciated.

I verify the prod build is loading as expected after the fix, so merge approved.

@catinhere
catinhere merged commit fba72af into master Jul 8, 2026
12 checks passed
@catinhere
catinhere deleted the task/bower-migration branch July 8, 2026 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants