Repository navigation
feat: Add experimental.autoIncludeSources to zip only the sources used by the build - #2675
ninadsutrave wants to merge 5 commits into
Conversation
…sed by the build
✅ Deploy Preview for creative-fairy-df92c4 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
@wxt-dev/analytics
@wxt-dev/auto-icons
@wxt-dev/browser
@wxt-dev/i18n
@wxt-dev/is-background
@wxt-dev/module-react
@wxt-dev/module-solid
@wxt-dev/module-svelte
@wxt-dev/module-vue
@wxt-dev/runner
@wxt-dev/storage
@wxt-dev/unocss
@wxt-dev/webextension-polyfill
wxt
commit: |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2675 +/- ##
==========================================
+ Coverage 79.45% 79.78% +0.33%
==========================================
Files 138 139 +1
Lines 4118 4146 +28
Branches 946 954 +8
==========================================
+ Hits 3272 3308 +36
+ Misses 745 739 -6
+ Partials 101 99 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…ources # Conflicts: # packages/wxt/src/internal/builtin-modules/index.ts
Head branch was pushed to by a user without write access
Overview
Adds an experimental flag that builds the sources ZIP from the files Vite actually used, instead of everything in
zip.sourcesRoot.A built-in module adds a small Vite plugin that collects
this.getModuleIds()after each build. Unlike the chunks'moduleIds, this includes modules removed by tree-shaking (like re-export-only files). Onzip:sources:start, those files are added tozip.includeSources, along with the top-level files of the project (package.json, lockfile, config files), the public directory and local modules, since Vite never loads those.A couple of decisions worth calling out:
includeSourcesdefaults to[]when the flag is on, but is still respected, and so isexcludeSources. Some files can't be detected (CSS@imports, files only read by modules), so there needs to be a way to add them, and exclude keeps a way to keep secrets out. Happy to switch to fully ignoring both if you prefer.zip.sourcesRootaren't added, since most unzip tools skip../entries. WXT logs which files were skipped; for monorepos, setsourcesRootto the repo root.Manual Testing
bun run test run e2e/tests/zip.test.ts -t autoIncludeSourcesThe first test checks the exact file list in the sources ZIP and rebuilds the extension from the extracted sources. The second checks that a file outside the project root is included when
sourcesRootis the parent directory.To try it on the demo, set
experimental: { autoIncludeSources: true }inpackages/wxt-demo/wxt.config.tsand runbun wxt zip -b firefox. The printed file list should only contain files used by the build.Related Issue
This PR closes #1505