youtube icon indicating copy to clipboard operation
youtube copied to clipboard

Add manifest v2->v3 converter + Rollup bundling

Open simon1st25 opened this issue 3 months ago • 3 comments

Adds a best-effort manifest v2 -> v3 converter, optional service-worker bundling via Rollup, a VS Code workspace file, and a short WORKSPACE_README.md explaining usage.

Files changed:

  • scripts/convert-manifest.js (converter, --bundle-sw support, warnings)
  • scripts/rollup.config.js (rollup config to bundle background scripts)
  • package.json (bundle script + devDependencies)
  • youtube.code-workspace (workspace settings)
  • WORKSPACE_README.md (how to open workspace & run converter)

How to test locally:

  1. Install dev deps (use legacy peer deps if npm complains):
npm install --legacy-peer-deps
  1. Run the converter with bundling enabled:
node scripts/convert-manifest.js --input build/manifest2.json --output build/manifest3.json --bundle-sw
  1. Verify outputs (not committed):
  • build/manifest3.json — check manifest_version: 3, background.service_worker and host_permissions.
  • build/generated_service_worker.js — review the generated bundle for APIs incompatible with MV3.

Notes & cautions:

  • The converter is heuristic. Please review Content Security Policy, webRequest usage, and any APIs that require adaptation for Manifest V3 (e.g., use declarativeNetRequest for blocking network requests).
  • The generated service worker is created by Rollup (or a fallback importScripts wrapper). Test thoroughly in Chrome/Chromium with the extension loaded unpacked.
  • Build outputs were intentionally not committed. If maintainers want the bundle generated as part of CI, consider adding a CI job that runs npm ci && npm run bundle-sw and artifacts publishing.

CI workflow added:

  • A GitHub Actions workflow .github/workflows/manifest-v3.yml was added in this branch. It runs on pull requests and feature/** pushes and performs:
    1. npm ci --legacy-peer-deps
    2. node scripts/convert-manifest.js --input build/manifest2.json --output build/manifest3.json --bundle-sw
    3. node scripts/validate-manifest3.js build/manifest3.json

This workflow bundles the service worker and validates the generated manifest3.json. It fails the check if manifest_version !== 3 or if background.service_worker is missing.

Suggested follow-ups:

  • Add an explicit CI artifact upload if maintainers want the generated bundle attached to the job.
  • Consider adding "type": "module" to package.json to avoid a Rollup ES module warning during action runs.

If you prefer, I can add the CI artifact step or adjust triggers to run only for PRs targeting master in the upstream repo.

simon1st25 avatar Nov 23 '25 06:11 simon1st25

Testing & review instructions for this PR

Quick test (local):

  1. Install dev deps (use legacy peer deps if npm complains):
npm install --legacy-peer-deps
  1. Run the converter with bundling enabled:
node scripts/convert-manifest.js --input build/manifest2.json --output build/manifest3.json --bundle-sw
  1. Verify outputs (not committed):
  • build/manifest3.json — check manifest_version: 3, background.service_worker and host_permissions.
  • build/generated_service_worker.js — review the generated bundle for APIs incompatible with MV3.

Notes & cautions:

  • The converter is heuristic. Please review Content Security Policy, webRequest usage, and any APIs that require adaptation for Manifest V3 (e.g., use declarativeNetRequest for blocking network requests).
  • The generated service worker is created by Rollup (or a fallback importScripts wrapper). Test thoroughly in Chrome/Chromium with the extension loaded unpacked.
  • Build outputs were intentionally not committed. If maintainers want the bundle generated as part of CI, consider adding a CI job that runs npm ci && npm run bundle-sw and artifacts publishing.

Suggested follow-ups:

  • Add CI step to validate manifest3.json schema and smoke-test the bundle.
  • Consider adding "type": "module" to package.json to remove the Rollup ES-module warning in Node.

If you want, I can add the CI job or update the PR description with this checklist.

simon1st25 avatar Nov 23 '25 06:11 simon1st25

Kurzinfo: Die CI-Artefakt-Automation ist nun aktiv.

  • Bei PR-Updates oder Pushes auf dieser Branch erzeugt der Workflow ein Bundle und lädt Artefakte hoch.
  • Die Action postet einen Kommentar mit dem Download-Link, fügt das Label artifact-ready hinzu und weist den PR-Autor sowie angeforderte Reviewer als Assignees zu.

Trigger: Push oder Update der PR (z. B. ein zusätzlicher Commit).

Wenn du eine andere Farbe, Namen oder zusätzliche Empfänger möchtest, sag kurz Bescheid.

simon1st25 avatar Nov 23 '25 07:11 simon1st25

hi! @simon1st25 https://github.com/code-charity/Bulk-Contributor https://github.com/code-charity/Manifest-v3

ImprovedTube avatar Nov 23 '25 19:11 ImprovedTube