Skip to content

feat: Add experimental.autoIncludeSources to zip only the sources used by the build - #2675

Open
ninadsutrave wants to merge 5 commits into
wxt-dev:mainfrom
ninadsutrave:feat/auto-include-sources
Open

ninadsutrave wants to merge 5 commits into
wxt-dev:mainfrom
ninadsutrave:feat/auto-include-sources

Conversation

@ninadsutrave

Copy link
Copy Markdown

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). On zip:sources:start, those files are added to zip.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:

  • includeSources defaults to [] when the flag is on, but is still respected, and so is excludeSources. 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.
  • Files outside zip.sourcesRoot aren't added, since most unzip tools skip ../ entries. WXT logs which files were skipped; for monorepos, set sourcesRoot to the repo root.

Manual Testing

bun run test run e2e/tests/zip.test.ts -t autoIncludeSources

The 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 sourcesRoot is the parent directory.

To try it on the demo, set experimental: { autoIncludeSources: true } in packages/wxt-demo/wxt.config.ts and run bun wxt zip -b firefox. The printed file list should only contain files used by the build.

Related Issue

This PR closes #1505

@netlify

netlify Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for creative-fairy-df92c4 ready!

Name Link
🔨 Latest commit 087b422
🔍 Latest deploy log https://app.netlify.com/projects/creative-fairy-df92c4/deploys/6ae180a848cf5289f1a4e1b4
😎 Deploy Preview https://deploy-preview-2675--creative-fairy-df92c4.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: bca586d8-7dbd-4fc6-9d31-9b208eeee336

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the pkg/wxt Includes changes to the `packages/wxt` directory label Oct 18, 2026
@nishu-murmu
nishu-murmu enabled auto-merge (squash) October 19, 2026 09:13
@pkg-pr-new

pkg-pr-new Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@wxt-dev/analytics

npm i https://pkg.pr.new/@wxt-dev/analytics@2675

@wxt-dev/auto-icons

npm i https://pkg.pr.new/@wxt-dev/auto-icons@2675

@wxt-dev/browser

npm i https://pkg.pr.new/@wxt-dev/browser@2675

@wxt-dev/i18n

npm i https://pkg.pr.new/@wxt-dev/i18n@2675

@wxt-dev/is-background

npm i https://pkg.pr.new/@wxt-dev/is-background@2675

@wxt-dev/module-react

npm i https://pkg.pr.new/@wxt-dev/module-react@2675

@wxt-dev/module-solid

npm i https://pkg.pr.new/@wxt-dev/module-solid@2675

@wxt-dev/module-svelte

npm i https://pkg.pr.new/@wxt-dev/module-svelte@2675

@wxt-dev/module-vue

npm i https://pkg.pr.new/@wxt-dev/module-vue@2675

@wxt-dev/runner

npm i https://pkg.pr.new/@wxt-dev/runner@2675

@wxt-dev/storage

npm i https://pkg.pr.new/@wxt-dev/storage@2675

@wxt-dev/unocss

npm i https://pkg.pr.new/@wxt-dev/unocss@2675

@wxt-dev/webextension-polyfill

npm i https://pkg.pr.new/@wxt-dev/webextension-polyfill@2675

wxt

npm i https://pkg.pr.new/wxt@2675

commit: bceabea

@codecov

codecov Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.78%. Comparing base (bd1ef60) to head (7944d33).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

auto-merge was automatically disabled October 27, 2026 19:19

Head branch was pushed to by a user without write access

This branch has not been deployed

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

Labels

pkg/wxt Includes changes to the `packages/wxt` directory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Automatic gathering of used files for zip

2 participants