Skip to content

Commit 1a07e2e

Browse files
tkirda-bisonclaude
andcommitted
build: replace grunt with node terser script
PR-2 of the modernization plan: removes grunt + grunt-contrib-uglify in favor of a ~50-line Node ESM build script that does what the gruntfile used to do. Same dist layout, same banner format, no source changes. scripts/build.mjs: - Substitutes %version% from package.json into dist/jquery.autocomplete.js. - Minifies via terser with a preamble that matches the gruntfile's banner format exactly (no leading-space, year 2025 hardcoded as before). - Syncs version in devbridge-autocomplete.jquery.json. devDependency churn: - Drop: grunt, grunt-contrib-uglify (removed 96 transitive packages). - Add: terser. vitest already pulled terser transitively, so dedupe lands. Output: - dist/jquery.autocomplete.js: byte-identical to pre-PR. - dist/jquery.autocomplete.min.js: semantically equivalent. Terser 5 emits ~73 bytes more than uglify-js 3 because it preserves slightly more local var names; tests still pass. Lint/format scope broadens to scripts/build.mjs but deliberately excludes the pre-existing demo files (scripts/countries.js, scripts/demo.js) which are runtime assets loaded by index.htm, not build tooling. Surviving npm audit advisories (6, all dev-only) are pre-existing and unrelated to this PR; auto-fixable separately with npm audit fix. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 4652fe9 commit 1a07e2e

7 files changed

Lines changed: 174 additions & 1131 deletions

File tree

CLAUDE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ This is a single-file jQuery plugin (Ajax Autocomplete). The entire implementati
1010

1111
- `npm test` — Vitest run (headless, jsdom). Single-shot, exits nonzero on failure.
1212
- `npm run test:watch` — Vitest watch mode for local TDD.
13-
- `npm run lint` — ESLint (flat config in `eslint.config.mjs`) over `src/` and `test/`.
14-
- `npm run format` — Prettier rewrite of `src/` and `test/` (100-col, 4-space, ES5 trailing commas — config in `package.json`).
15-
- `npm run build``grunt build`: copies `src/jquery.autocomplete.js` to `dist/jquery.autocomplete.js` while substituting the `%version%` placeholder with `package.json` `version`, uglifies to `dist/jquery.autocomplete.min.js`, and syncs `devbridge-autocomplete.jquery.json` version. Run this before release/commit when source changes. *(Slated for replacement with a smaller Node script in the next modernization PR.)*
13+
- `npm run lint` — ESLint (flat config in `eslint.config.mjs`) over `src/`, `test/`, and `scripts/build.mjs`.
14+
- `npm run format` — Prettier rewrite of `src/`, `test/`, and `scripts/build.mjs` (100-col, 4-space, ES5 trailing commas — config in `package.json`). Demo files under `scripts/` (`countries.js`, `demo.js`) are intentionally excluded.
15+
- `npm run build`runs `scripts/build.mjs` (Node ESM, no bundler): copies `src/jquery.autocomplete.js` to `dist/jquery.autocomplete.js` while substituting the `%version%` placeholder with `package.json` `version`, minifies to `dist/jquery.autocomplete.min.js` via terser with a fresh banner, and syncs `devbridge-autocomplete.jquery.json` version. Run this before release/commit when source changes.
1616

1717
## Tests
1818

dist/jquery.autocomplete.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

eslint.config.mjs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,14 @@ export default [
3535
},
3636
},
3737
},
38+
{
39+
files: ['scripts/**/*.mjs'],
40+
languageOptions: {
41+
ecmaVersion: 2022,
42+
sourceType: 'module',
43+
globals: {
44+
console: 'readonly',
45+
},
46+
},
47+
},
3848
];

gruntfile.js

Lines changed: 0 additions & 54 deletions
This file was deleted.

0 commit comments

Comments
 (0)