fix: add clean script and update start scripts for Webpack migration#401
fix: add clean script and update start scripts for Webpack migration#401DennisOSRM wants to merge 7 commits intogh-pagesfrom
Conversation
- Add 'clean' script to remove stale bundle.raw.js artifact - Update 'build' script to run clean before replace and compile - Replace deprecated budo/bistre with webpack-dev-server for development - Add webpack-dev-server to devDependencies - Simplify start-prod to just run build - Configure webpack-dev-server to serve static files from project root Prevents stale Browserify output from being confused with active build artifacts. Addresses reviewer feedback on PR #399 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Updates build/start tooling as part of the Browserify → Webpack migration follow-up, adding a cleanup step and switching development serving to webpack-dev-server.
Changes:
- Added a
cleanscript and reordered the build pipeline (clean → replace → webpack compile → copy CSS). - Replaced budo/bistre-based dev start with
webpack serve. - Added
devServerconfiguration to serve static files from the project root.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
package.json |
Adds clean, updates build/start scripts, and swaps dev tooling to webpack/webpack-dev-server. |
webpack.config.js |
Introduces webpack config including devServer static serving and module fallbacks. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "compile": "webpack --config webpack.config.js", | ||
| "build": "npm run clean && npm run replace && npm run compile && cp node_modules/leaflet/dist/leaflet.css css/leaflet.css", | ||
| "start": "npm run build && webpack serve --config webpack.config.js --mode development", | ||
| "start-prod": "npm run build", |
There was a problem hiding this comment.
start-prod no longer starts an HTTP server (it only runs the build and exits). This breaks the existing Docker runtime (docker/Dockerfile runs npm run start-prod and exposes port 9966), and will cause containers to terminate immediately. Please change start-prod to start a server (e.g., webpack serve or a lightweight static server) and ensure it binds to the expected port/host (9966 / 0.0.0.0), or update the Docker entrypoint accordingly.
| "start-prod": "npm run build", | |
| "start-prod": "npm run build && webpack serve --config webpack.config.js --mode production --host 0.0.0.0 --port 9966", |
| "build": "npm run clean && npm run replace && npm run compile && cp node_modules/leaflet/dist/leaflet.css css/leaflet.css", | ||
| "start": "npm run build && webpack serve --config webpack.config.js --mode development", |
There was a problem hiding this comment.
npm run start runs npm run build and then starts webpack serve, which recompiles the bundle again in-memory. This duplicates work and slows down local startup. Consider splitting dev vs prod steps (e.g., run only clean/replace/CSS copy before webpack serve, or move CSS copying into the webpack pipeline so webpack serve is the single compilation step).
| "build": "npm run clean && npm run replace && npm run compile && cp node_modules/leaflet/dist/leaflet.css css/leaflet.css", | |
| "start": "npm run build && webpack serve --config webpack.config.js --mode development", | |
| "start-prep": "npm run clean && npm run replace && cp node_modules/leaflet/dist/leaflet.css css/leaflet.css", | |
| "build": "npm run clean && npm run replace && npm run compile && cp node_modules/leaflet/dist/leaflet.css css/leaflet.css", | |
| "start": "npm run start-prep && webpack serve --config webpack.config.js --mode development", |
| "clean": "rm -f bundle.raw.js", | ||
| "compile": "webpack --config webpack.config.js", | ||
| "build": "npm run clean && npm run replace && npm run compile && cp node_modules/leaflet/dist/leaflet.css css/leaflet.css", |
There was a problem hiding this comment.
The new clean script uses rm -f, which is not available in a default Windows environment. The README currently documents a Windows dev workflow, so this introduces an additional cross-platform regression (and npm run start now depends on clean). Prefer a cross-platform deletion (e.g., a small Node script using fs.rmSync(...,{force:true}) or a tool like rimraf). Also, if bundle.raw.js is still tracked in git, consider removing it from the repo and adding it to .gitignore so it doesn’t reappear as a stale artifact.
- Replace .eslintrc (deprecated) with eslint.config.js - Move ignore patterns from .eslintignore to ignores property - Update languageOptions with proper globals for Node and browser - Add type: module to package.json to eliminate Node warnings This resolves ESLint v10.2.0 compatibility issues. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The directive on line 2 was unused since the actual comparisons with null already have their own disable comments on lines 6 and 14. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
429aab4 to
f9f5de7
Compare
Adding type: module breaks CommonJS scripts used in the build process. ESLint can handle eslint.config.js as ESM without the type field. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Using .mjs extension explicitly marks the file as an ES module, eliminating the MODULE_TYPELESS_PACKAGE_JSON warning without requiring type: module in package.json (which breaks build scripts). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Summary
Addresses reviewer feedback on PR #399 by:
bundle.raw.jsartifact before builds to prevent confusion with active build outputsChanges
package.json: Added clean script, updated build/start scripts, added webpack-dev-serverwebpack.config.js: Added devServer configurationTesting
npm run buildsuccessfully cleans and compilesnpm run startserves the webpage at http://localhost:9000Related to
PR #399: Replace Browserify with Webpack