Skip to content

fix(zip)!: make includeSources/excludeSources follow standard allowlist behavior - #2114

Merged
aklinker1 merged 13 commits into
wxt-dev:majorfrom
kaigritun:fix-zip-includeSources
Jul 26, 2026
Merged

fix(zip)!: make includeSources/excludeSources follow standard allowlist behavior#2114
aklinker1 merged 13 commits into
wxt-dev:majorfrom
kaigritun:fix-zip-includeSources

Conversation

@kaigritun

@kaigritun kaigritun commented Feb 11, 2026

Copy link
Copy Markdown
Contributor

When includeSources patterns are provided, only files matching those patterns should be included in the sources ZIP. Previously, includeSources patterns were added to the default **/* glob, which could leak sensitive files that weren't explicitly excluded.

Changes per maintainer review (replaces #2111):

  • Move default ['**/*'] into resolveZipConfig
  • Pass excludeSources directly to glob's ignore option
  • Remove hardcoded node_modules glob (already in excludeSources default)
  • Simplify zipDir logic
  • Adds a dotSources option to allow configuring tinyglobby's dot option, allowing for zipping hidden files

BREAKING CHANGE: Sources zip generation behavior has changed.

Fixes #2059
Supersedes #2111

lishaduck and others added 5 commits February 7, 2026 08:34
Co-authored-by: Patryk Kuniczak <p.kuniczak@gmail.com>
When includeSources patterns are provided, only files matching those
patterns should be included in the sources ZIP. Previously, includeSources
patterns were added to the default **/* glob, which could leak sensitive
files that weren't explicitly excluded.

Changes per maintainer review:
- Move default ['**/*'] into resolveZipConfig
- Pass excludeSources directly to glob's ignore option
- Remove hardcoded node_modules glob (already in excludeSources default)
- Simplify zipDir logic

BREAKING CHANGE: If you were using includeSources to add specific files
to the default set (e.g., hidden files), you now need to include all
files you want in the ZIP.

Fixes wxt-dev#2059

@aklinker1 aklinker1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While reviewing, I remembered some past issues related to zipping sources that we need to support:

TLDR: We need to support including hidden files and files in hidden directories. I think this requirement was why the logic was so complex.

Right now, I don't think this PR supports adding hidden files at all.

I ran some tests to refresh my knowledge of fast-glob, verifying the three cases we care about (regular files, hidden files, regular files in hidden directories):

Details
import { glob, Options } from "fast-glob";
import fs from "node:fs/promises";
import { inspect } from "node:util";

const test = async (sources: string[], options: Options) => {
  const res = await glob(sources, options);
  console.log(
    `
───

glob(
  ${inspect(sources, { colors: true })},
  ${inspect(options, { colors: true })}
)
= ${inspect(res, { colors: true })}`,
  );
};

const allFiles = await fs.readdir(".", {
  recursive: true,
});
console.log("All files (minus node_modules):");
console.log(
  allFiles.filter((file: string) => !file.startsWith("node_modules")),
);

await test(["**/*"], { ignore: ["**/node_modules/**"] });
await test(["**/.*"], { ignore: ["**/node_modules/**"] });
await test(["**/.*/**/*"], { ignore: ["**/node_modules/**"] });

and the output:

All files (minus node_modules):
[ ".wxt", "bun.lock", "package.json", ".env", "index.ts", ".wxt/test.txt" ]

───

glob(
  [ '**/*' ],
  { ignore: [ '**/node_modules/**' ] }
)
= [ 'bun.lock', 'package.json', 'index.ts' ]

───

glob(
  [ '**/.*' ],
  { ignore: [ '**/node_modules/**' ] }
)
= [ '.env' ]

───

glob(
  [ '**/.*/**/*' ],
  { ignore: [ '**/node_modules/**' ] }
)
= []

But it seems like fast-glob doesn't support including files from inside hidden directories (I did try the dot: true option as well, but it didn't make a difference)...

So I tried glob instead:

Details
import { glob, GlobOptions } from "glob";
import fs from "node:fs/promises";
import { inspect } from "node:util";

const test = async (sources: string[], options: GlobOptions) => {
  const res = await glob(sources, options);
  console.log(
    `
───

glob(
  ${inspect(sources, { colors: true })},
  ${inspect(options, { colors: true })}
)
= ${inspect(res, { colors: true })}`,
  );
};

const allFiles = await fs.readdir(".", {
  recursive: true,
});
console.log("All files (minus node_modules):");
console.log(
  allFiles.filter((file: string) => !file.startsWith("node_modules")),
);

await test(["**/*"], { ignore: ["**/node_modules/**"] });
await test(["**/.*"], { ignore: ["**/node_modules/**"] });
await test(["**/.*/**/*"], { ignore: ["**/node_modules/**"] });
await test(["**/.*/**/*"], { ignore: ["**/node_modules/**"], nodir: true });
All files (minus node_modules):
[ ".wxt", "bun.lock", "package.json", ".env", "index.ts", ".wxt/test.txt" ]

───

glob(
  [ '**/*' ],
  { ignore: [ '**/node_modules/**' ] }
)
= [ 'index.ts', 'package.json', 'bun.lock' ]

───

glob(
  [ '**/.*' ],
  { ignore: [ '**/node_modules/**' ] }
)
= [ '.env', '.wxt' ]

───

glob(
  [ '**/.*/**/*' ],
  { ignore: [ '**/node_modules/**' ] }
)
= [ '.wxt/test.txt' ]

───

glob(
  [ '**/.*/**/*' ],
  { ignore: [ '**/node_modules/**' ], nodir: true }
)
= []

It works, but I can't get it to return just files. It does support returning with file-types, so we could filter out directories that way.

Unforunate since glob is 10x as large...

Maybe there's another glob library that's lighter-weight and would allow devs to include hidden files and files in hidden directories?

Otherwise I think we have to switch from fast-glob to glob.

Comment thread packages/wxt/src/core/zip.ts Outdated
import JSZip from 'jszip';
import glob from 'fast-glob';
import { normalizePath } from './utils/paths';
import { minimatchMultiple } from './utils/minimatch-multiple';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can delete this file and it's test completely, this was the only place they were used.

@aklinker1

Copy link
Copy Markdown
Member

Can you also update the docs, adding a section about this change to the docs here:

Maybe wait to do that until all the changes are finalized through.

@MichaelDeBoey

Copy link
Copy Markdown

I'm not making any claims about the quality of their work, but I wanted to let you know that @kaigritun is a fully-autonomous non-human actor
https://socket.dev/blog/ai-agent-lands-prs-in-major-oss-projects-targets-maintainers-via-cold-outreach

@PatrykKuniczak

Copy link
Copy Markdown
Collaborator

@kaigritun Are you want to go on?

@PatrykKuniczak

Copy link
Copy Markdown
Collaborator

@kaigritun One more poke :)

@aklinker1 aklinker1 changed the title fix(zip): make includeSources use allowlist behavior fix(zip)!: make includeSources/excludeSources follow standard allowlist behavior Jul 26, 2026

@aklinker1 aklinker1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to make some changes around how hidden files are included, but I'm happy with the result. I imagine for wxt 1.0, we may need to provide the full options for tinyglobby, not just include, exclude, and dot. But this is good enough to get feedback on.

@codecov

codecov Bot commented Jul 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.26%. Comparing base (1f95c6c) to head (f0a320a).
⚠️ Report is 1 commits behind head on major.

Additional details and impacted files
@@            Coverage Diff             @@
##            major    #2114      +/-   ##
==========================================
- Coverage   79.48%   79.26%   -0.22%     
==========================================
  Files         132      131       -1     
  Lines        3982     3970      -12     
  Branches      908      905       -3     
==========================================
- Hits         3165     3147      -18     
- Misses        728      731       +3     
- Partials       89       92       +3     

☔ 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.

@aklinker1
aklinker1 merged commit ac8408d into wxt-dev:major Jul 26, 2026
12 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for helping make WXT better!

aklinker1 added a commit that referenced this pull request Jul 26, 2026
…owlist behavior (#2114)

Co-authored-by: Eli <88557639+lishaduck@users.noreply.github.com>
Co-authored-by: ТΞNSΛI <tensai@gmx.net>
Co-authored-by: Aaron <aaronklinker1@gmail.com>
Co-authored-by: Patryk Kuniczak <p.kuniczak@gmail.com>
Co-authored-by: Kai Gritun <kai@kaigritun.com>
aklinker1 added a commit that referenced this pull request Jul 26, 2026
…owlist behavior (#2114)

Co-authored-by: Eli <88557639+lishaduck@users.noreply.github.com>
Co-authored-by: ТΞNSΛI <tensai@gmx.net>
Co-authored-by: Aaron <aaronklinker1@gmail.com>
Co-authored-by: Patryk Kuniczak <p.kuniczak@gmail.com>
Co-authored-by: Kai Gritun <kai@kaigritun.com>
eliandoran added a commit to TriliumNext/Trilium that referenced this pull request Jul 30, 2026
wxt 0.21 changed zip.includeSources from an additive, exclude-overriding
list to a plain allowlist (wxt-dev/wxt#2114). Our config listed only
entrypoints/offscreen/index.html there (to force-include the Chrome-only
entrypoint that wxt auto-excludes as skipped on Firefox), so the AMO
sources zip ended up completely empty.

Drop the includeSources override to get the full-sources default back,
and re-add the offscreen entrypoint in the zip:sources:done hook via
jszip, since wxt no longer offers a way to un-exclude a skipped
entrypoint.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants