You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Replace the Grunt task runner with npm scripts and existing tooling (tsc, rollup, postcss). Grunt currently acts only as an orchestration layer—all actual build work is already delegated to modern tools. This migration removes Grunt entirely, simplifies the build pipeline, improves maintainability, adds a clean TypeScript compilation pipeline with temporary output isolation, and standardizes copyright banner injection across all output files.
Expected Benefits
Reduced dependencies: Remove outdated Grunt and its plugins (grunt, grunt-banner, grunt-contrib-clean, grunt-contrib-copy, grunt-exec)
Simpler maintenance: npm scripts are more transparent and don't require learning Grunt's API
Cleaner build artifacts: TypeScript outputs to dist/tmp/js (temporary) instead of src/main/js, preventing accidental commits of compiled files
Better watch mode: Use concurrently for parallel watching of CSS, TS, and JS
Cross-platform compatibility: All scripts use Node.js APIs or cross-platform CLI tools (rimraf)
"build": "npm run prebuild && npm run build:ts && npm run build:copy-jquery && npm run build:rollup && npm run build:css && npm run build:css-min && npm run build:clean-tmp"
Modern JS (Node/bundlers):dist/bootstrap5-toggle.cjs and dist/bootstrap5-toggle.mjs (via "main" and "module" fields)
TypeScript Types:dist/bootstrap5-toggle.d.ts (via "types" and "typings" fields)
Watch Mode Behavior
npm run watch runs all tools in parallel using concurrently:
tsc --watch: Recompiles TypeScript on changes
rollup -c --watch: Rebundles on changes to dist/tmp/js/
postcss --watch (3 instances): Rebuilds CSS (dev, minified, and dist) on changes
Note: Loss of sequential dependency is accepted. Each tool watches independently. Developers must ensure TypeScript compiles successfully before Rollup can pick up changes (Rollup will retry on subsequent file system events).
Version Workflow
The version hook runs automatically during npm version:
npm version verifies clean working directory
Bumps version in package.json
Runs version hook: npm run build && npm run readme && doctoc README.md --github && git add -A
Commits changes with new version tag
All generated files (built outputs, README, table of contents) are automatically staged and committed with the version bump.
Additional Comments
Risks & Mitigations
Risk
Mitigation
Broken Rollup inputs: Changing input path from src/main/js/ to dist/tmp/js/ could break if TypeScript compilation fails
Build script runs tsc before Rollup; failure halts the pipeline
Missing jQuery wrapper:index.jquery.js must be copied to dist/tmp/js/ before Rollup
Explicit copy step in build script; file remains in version control
Declaration bundling:rollup-plugin-dts expects input at src/main/@types/index.d.ts
Unchanged from current configuration; declarations are correctly emitted
Stale dist/tmp: If cleanup fails, temporary files could be published
dist/tmp/ is added to .gitignore and files field excludes it; cleanup step ensures removal
PostCSS watch duplication: Three separate PostCSS watch processes run concurrently
Acceptable overhead; each process watches the same input file but outputs to different destinations
Version hook git add:git add -A could stage unintended changes
npm version requires clean working directory; only build artifacts and README changes are staged
Copyright banner accuracy: Banner must reflect correct version and copyright holders
scripts/package-banner.js reads package.json dynamically; version injected at build time
Migration Path for Users
Existing users: No breaking changes. All existing import paths (css/, js/) remain functional.
Modern bundler users: Can now import from dist/ for CJS/ESM modules with TypeScript support.
Future deprecation: The dist/bootstrap5-toggle.css file provides a migration path; css/ may be deprecated in a future major version.
Rollback Plan
If migration causes issues:
Restore Gruntfile.cjs from git
Restore previous package.json scripts and dependencies
Remove new dependencies: npm uninstall rimraf concurrently postcss-banner
The existing js/ and css/ outputs are untouched by this change, so CDN and browser users are unaffected. Only npm users with modern bundlers will notice improvements (TypeScript types, CJS/ESM modules).
Feature Request Checklist
Confirm that you agree to follow the project's code of conduct.
Confirm that you have reviewed open and rejected feature requests to ensure novelty.
Short Description of the Feature
Replace the Grunt task runner with npm scripts and existing tooling (
tsc,rollup,postcss). Grunt currently acts only as an orchestration layer—all actual build work is already delegated to modern tools. This migration removes Grunt entirely, simplifies the build pipeline, improves maintainability, adds a clean TypeScript compilation pipeline with temporary output isolation, and standardizes copyright banner injection across all output files.Expected Benefits
grunt,grunt-banner,grunt-contrib-clean,grunt-contrib-copy,grunt-exec)dist/tmp/js(temporary) instead ofsrc/main/js, preventing accidental commits of compiled filesconcurrentlyfor parallel watching of CSS, TS, and JSrimraf)npm versionintegration using theversionhookdist/bootstrap5-toggle.cssalongside existingcss/for future migration pathscripts/package-banner.jsAcceptance Criteria
grunt,grunt-banner,grunt-contrib-clean,grunt-contrib-copy,grunt-execfromdevDependenciesrimraf,concurrently,postcss-bannerscripts/package-banner.js: ExportbannerContentfunction that readspackage.jsonand returns formatted copyright bannertsconfig.json:"outDir": "dist/tmp/js"(was"src/main/js")"declaration": trueand"declarationDir": "src/main/@types""rootDir": "src/main/ts"rollup.config.js:bannerContentfrom./scripts/package-banner.jsoutput.bannerfor all formats (UMD, CJS, ESM)inputpaths fromsrc/main/js/*.jstodist/tmp/js/*.jsjs/(UMD) anddist/(CJS/ESM)rollup-plugin-dtsfor TypeScript declaration bundling (input remainssrc/main/@types/index.d.ts)postcss.config.js:bannerContentfrom./scripts/package-banner.jspostcss-bannerplugin withbannerContentpackage.jsonscripts:"clean": "rimraf js css dist dist/tmp""prebuild": "npm run clean""build:ts": "tsc""build:copy-jquery": "cp src/main/js/index.jquery.js dist/tmp/js/index.jquery.js""build:rollup": "rollup -c""build:css": "postcss src/main/css/bootstrap5-toggle.css -o css/bootstrap5-toggle.css --map""build:css-min": "postcss src/main/css/bootstrap5-toggle.css -o css/bootstrap5-toggle.min.css --map --env production && postcss src/main/css/bootstrap5-toggle.css -o dist/bootstrap5-toggle.css --map --env production""build:clean-tmp": "rimraf dist/tmp""build": "npm run prebuild && npm run build:ts && npm run build:copy-jquery && npm run build:rollup && npm run build:css && npm run build:css-min && npm run build:clean-tmp""watch": "concurrently \"tsc --watch\" \"rollup -c --watch\" \"postcss src/main/css/bootstrap5-toggle.css -o css/bootstrap5-toggle.css --map --watch\" \"postcss src/main/css/bootstrap5-toggle.css -o css/bootstrap5-toggle.min.css --map --env production --watch\" \"postcss src/main/css/bootstrap5-toggle.css -o dist/bootstrap5-toggle.css --map --env production --watch\"""readme": "node -e \"const fs=require('fs'); const pkg=require('./package.json'); fs.writeFileSync('README.md', fs.readFileSync('README.template.md','utf8').replaceAll('#version#', pkg.version))\"""version": "npm run build && npm run readme && doctoc README.md --github && git add -A""prepack": "npm run build && npm run readme && doctoc README.md --github"package.jsonfiles field: Keep["css/*", "js/*", "dist"](unchanged).gitignoreentry: Adddist/tmp/to ignore compiled temporary filessrc/main/js/from version control: Onlyindex.jquery.jsshould remain; all other.jsand.js.mapfiles are now generated indist/tmp/js/bootstrap5-toggle.ecmas.jsand.min.jsunchanged (UMD)js/bootstrap5-toggle.jquery.jsand.min.jsunchanged (UMD)css/bootstrap5-toggle.cssand.min.cssunchanged (with banners)dist/bootstrap5-toggle.cjs(existing, with banners)dist/bootstrap5-toggle.mjs(existing, with banners)dist/bootstrap5-toggle.d.ts(existing, with banners)dist/bootstrap5-toggle.css(new, minified, with banner)package.jsondist/tmpremoved after build (temporary TypeScript outputs and copied jQuery wrapper)npm test)Documentation
Build Pipeline Architecture
The new build pipeline consists of the following stages:
js/,css/,dist/,dist/tmp/)src/main/ts/*.ts→dist/tmp/js/*.jssrc/main/@types/*.d.tssrc/main/js/index.jquery.js→dist/tmp/js/index.jquery.jsdist/tmp/js/index.js(from TS) anddist/tmp/js/index.jquery.js(copied)js/(ECMAS and jQuery versions)dist/src/main/@types/index.d.ts→dist/bootstrap5-toggle.d.tsoutput.bannersrc/main/css/bootstrap5-toggle.csscss/dist/bootstrap5-toggle.csspostcss-bannerdist/tmp/temporary directorypackage.jsonintoREADME.mdPackage Distribution Strategy
The package maintains backward compatibility while adding modern distribution paths:
css/bootstrap5-toggle.min.css(via"style"field)dist/bootstrap5-toggle.css(minified, for future migration)js/bootstrap5-toggle.ecmas.min.js(via"browser"field)dist/bootstrap5-toggle.cjsanddist/bootstrap5-toggle.mjs(via"main"and"module"fields)dist/bootstrap5-toggle.d.ts(via"types"and"typings"fields)Watch Mode Behavior
npm run watchruns all tools in parallel usingconcurrently:tsc --watch: Recompiles TypeScript on changesrollup -c --watch: Rebundles on changes todist/tmp/js/postcss --watch(3 instances): Rebuilds CSS (dev, minified, and dist) on changesNote: Loss of sequential dependency is accepted. Each tool watches independently. Developers must ensure TypeScript compiles successfully before Rollup can pick up changes (Rollup will retry on subsequent file system events).
Version Workflow
The
versionhook runs automatically duringnpm version:npm versionverifies clean working directorypackage.jsonversionhook:npm run build && npm run readme && doctoc README.md --github && git add -AAll generated files (built outputs, README, table of contents) are automatically staged and committed with the version bump.
Additional Comments
Risks & Mitigations
src/main/js/todist/tmp/js/could break if TypeScript compilation failstscbefore Rollup; failure halts the pipelineindex.jquery.jsmust be copied todist/tmp/js/before Rolluprollup-plugin-dtsexpects input atsrc/main/@types/index.d.tsdist/tmp: If cleanup fails, temporary files could be publisheddist/tmp/is added to.gitignoreandfilesfield excludes it; cleanup step ensures removalgit add -Acould stage unintended changesnpm versionrequires clean working directory; only build artifacts and README changes are stagedscripts/package-banner.jsreadspackage.jsondynamically; version injected at build timeMigration Path for Users
css/,js/) remain functional.dist/for CJS/ESM modules with TypeScript support.dist/bootstrap5-toggle.cssfile provides a migration path;css/may be deprecated in a future major version.Rollback Plan
If migration causes issues:
Gruntfile.cjsfrom gitpackage.jsonscripts and dependenciesnpm install grunt grunt-banner grunt-contrib-clean grunt-contrib-copy grunt-exectsconfig.jsonoutDirtosrc/main/jsrollup.config.jsinputs tosrc/main/js/npm uninstall rimraf concurrently postcss-bannerThe existing
js/andcss/outputs are untouched by this change, so CDN and browser users are unaffected. Only npm users with modern bundlers will notice improvements (TypeScript types, CJS/ESM modules).Feature Request Checklist