Migrate build system from Webpack to WXT#22
Open
skid-dev wants to merge 1 commit into
Open
Conversation
Replace webpack.config.cjs + hand-authored src/manifest.json with WXT's
convention-based entrypoint discovery and wxt.config.ts:
- Move src/background/background.ts -> src/entrypoints/background.ts
(wrapped in defineBackground; listener registrations moved into main())
- Move src/popup/* -> src/entrypoints/popup/index.html + popup.ts + styles.css
- Move 9 dynamically-injected content scripts under src/entrypoints/*.ts
(wrapped in defineUnlistedScript; output paths preserved so existing
chrome.scripting.executeScript({ files: [...] }) calls still resolve)
- Move all injected CSS into public/ for verbatim copy at the same paths
- Delete webpack.config.cjs and src/manifest.json
- Replace dist/ build target with .output/chrome-mv3/
- Update tsconfig.json to extend ./.wxt/tsconfig.json
- Update .releaserc.json to build via 'bun run zip' and copy the artifact
- Update README with WXT-flavoured development instructions
Side-effect cleanups surfaced by the code review:
- Extract show_detection_banner() helper, consume from detect_domain and
detect_rss_feed (kills ~22 lines of duplicate banner code per file)
- Use set_setting() in detect_domain / detect_rss_feed instead of
inlining chrome.storage.sync.get -> mutate -> set
- Split set_setting into its own file so content-script entrypoints don't
pull in pull_feed / fast-xml-parser (saves ~63 kB per detect_* bundle)
- Collapse mirrored added/removed branches in detect_schooltape into a
single handle_stylesheet_change() helper
- Trim verbose w_a_r list to glob patterns
- Drop redundant 'compile' npm script
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
src/manifest.jsonwith WXT: manifest is now generated fromwxt.config.ts+ entrypoint discovery insrc/entrypoints/.background.js,popup.html,launcher_homepage.js, etc.) so existingchrome.scripting.executeScript({ files: [...] })andinsertCSScall sites insrc/background/events/injects/**keep working without changes.public/for verbatim copy at the same root paths.dist/→.output/chrome-mv3/.bun run zipproduces a Web-Store-ready zip at.output/<name>-<version>-chrome.zip.The migration is intentionally minimal —
chrome.*globals are left in place (WXT runs them as-is),src/storage/is unchanged, and React isn't pulled into the popup. All of those can be follow-ups.What changed
webpack.config.cjs(5+ loaders, 8 deps)wxt.config.ts(~25 lines)src/manifest.jsonwxt.config.ts+ entrypointschrome.*.addListener(...)callsdefineBackground(() => { ... })dist/defineUnlistedScript(() => { ... })insrc/entrypoints/*.tsCopyWebpackPluginpatternspublic/**/*.cssbun run dev→ Webpack watchbun run dev→ Vite + HMR + auto-launched browserbun run build:firefoxworks for freeCode review cleanups (from
/simplify)show_detection_banner()helper used bydetect_domainanddetect_rss_feed(kills ~22 lines of duplicate banner code per file).detect_domain/detect_rss_feedto useset_setting()instead of inliningchrome.storage.sync.get → mutate → set.set_setting()into its own file so content-script entrypoints don't transitively pull inpoll_feed/fast-xml-parser. This saves ~63 kB perdetect_*bundle (detect_schooltape.js: 64.74 kB → 1.37 kB).addedNodes/removedNodesbranches indetect_schooltape.tsinto ahandle_stylesheet_change()helper.web_accessible_resourceslist to glob patterns.compilenpm script.Total bundle size went from 548 kB (post-naive-migration) to 485 kB after the cleanup — actually smaller than what Webpack was producing, because the
set_settingsplit also fixes a pre-existing transitive-import bloat indetect_schooltape.js.Test plan
bun run typecheckpassesbun run buildproduces all 11 expected JS entries + 9 CSS files + popup.html + manifest.jsonbun run zipproduces.output/schoolbox-chrome-extension-1.3.0-chrome.zip.output/chrome-mv3/as unpacked extension in Chromeschooltape_compatibilitywhen SchoolTape installs/removes its stylesheetThe migration plan and full WXT reference are saved in
~/.claude/plans/pure-bouncing-cat.md.🤖 Generated with Claude Code