Skip to content

refactor: migrate manual lib dependencies to npm and gulp bundle#6720

Open
Jetshree wants to merge 8 commits intosugarlabs:masterfrom
Jetshree:dep-part1
Open

refactor: migrate manual lib dependencies to npm and gulp bundle#6720
Jetshree wants to merge 8 commits intosugarlabs:masterfrom
Jetshree:dep-part1

Conversation

@Jetshree
Copy link
Copy Markdown
Contributor

@Jetshree Jetshree commented Apr 19, 2026

This PR fundamentally modernizes how dependencies are managed in Music Blocks. It replaces the legacy system of manually dropping third-party libraries into the lib/ folder with a standard, automated npm and gulp-based pipeline. Third-party dependencies are now explicitly versioned in package.json and concatenated into a dist/vendor.min.js bundle to significantly clean up index.html and js/loader.js.

This PR introduces structural changes to the build pipeline. The goal is to remove manual management of dependencies through the lib folder and rely entirely on package.json and Gulp. It needs close review and opinions from the core maintainers before merging.

This PR is first part, if the idea feels good then other libraries in /lib folder will also be moved to package.json in separate PRs.

PR Category

  • Bug Fix — Fixes a bug or incorrect behavior
  • Feature — Adds new functionality (Automated build pipeline)
  • Performance — Improves performance (load time, memory, rendering, etc.) by bundling vendor libraries
  • Tests — Adds or updates test coverage
  • Documentation — Updates to docs, comments, or README

Changes Made

  • Migrated to package.json: Moved jquery, jquery-ui-dist, materialize-css, abcjs , howler, and tone into NPM dependencies.
  • Version Compatibility: Pinned the package.json NPM versions to exactly match the legacy versions previously found in the lib/ directory to maximize backward compatibility.
  • Automated Bundling: Updated gulpfile.js to include a new vendorTask that concatenates these specific NPM packages into a single dist/vendor.min.js file.
  • Cleaned up HTML: Removed redundant individual third-party <script> tag requests from index.html.
  • Loader Compatibility: Updated js/loader.js's PRELOADED_SCRIPTS array to correctly map global module exports coming from the new unified vendor bundle.
  • CI/Linting Fixes: Appended --no-warn-ignored to lint-staged in package.json to prevent Husky pre-commit hooks from failing when auto-checking output files like dist/vendor.min.js.

Testing Performed

  • Verified that npm install gracefully resolves and installs the legacy-pinned package versions.
  • Tested npx gulp vendorTask to ensure dist/vendor.min.js is generated with correct paths.
  • Verified that index.html correctly defaults to loading the new unified bundle.
  • All the libraries shifted to package.json now loads properly from vendor.min.js

Before:
Screenshot 2026-04-19 144434

After:
Screenshot 2026-04-19 144936

Checklist

  • I have tested these changes locally and they work as expected.
  • I have added/updated tests that prove the effectiveness of these changes.
  • I have followed the project's coding style guidelines.
  • I have run npm run lint and npx prettier --check . with no errors.
  • I have enabled "Allow edits from maintainers" (required for auto-rebase; this only affects the PR branch, not your fork).

Additional Notes for Reviewers

Please pay close attention to jquery-ui-dist. The legacy lib/ folder contained v1.11.4, but that version was never officially published to NPM under the jquery-ui-dist package. It has been pinned to v1.12.1 in package.json as the closest, safest alternative.

@github-actions github-actions bot added feature Adds new functionality size/M Medium: 50-249 lines changed area/javascript Changes to JS source files area/tests Changes to test files area/core Changes to core app entry files labels Apr 19, 2026
@github-actions
Copy link
Copy Markdown
Contributor

✅ All Jest tests passed! This PR is ready to merge.

Coverage: Coverage summary unavailable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core Changes to core app entry files area/javascript Changes to JS source files area/tests Changes to test files feature Adds new functionality size/M Medium: 50-249 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant