Skip to content

The zip command prints "Could not get stats" warnings when the sources root is not the extension folder #2626

Closed

Description

@pigfox

Versions

  • wxt 0.21.4
  • Node 24.21.0
  • pnpm 12.5.1
  • Linux

Setup

pnpm monorepo. Each extension is in extensions/<name>, and the sources zip is configured to include the workspace root so reviewers can rebuild it (packages/shared, root package.json, lockfile):

zip: {
  sourcesRoot: fileURLToPath(new URL('../..', import.meta.url)),
  includeSources: [
    'SOURCE_BUILD.md', 'LICENSE', 'package.json', 'pnpm-workspace.yaml',
    'pnpm-lock.yaml', 'tsconfig.base.json', 'packages/shared/**',
    `extensions/${EXTENSION_NAME}/**`,
  ],
},

Steps to reproduce

  1. git clone https://github.com/pigfox/browser-extensions && cd browser-extensions (commit 65017d5)
  2. pnpm install
  3. pnpm zip (this runs wxt zip -b firefox in each extensions/<name> folder)

Actual

For each extension, the sources step logs one warning per file in the zip:

WARN  Could not get stats of 'LICENSE' error: Error: ENOENT: no such file or directory, lstat 'LICENSE'
WARN  Could not get stats of 'extensions/ghost-job-detector/package.json' error: Error: ENOENT: no such file or directory, lstat 'extensions/ghost-job-detector/package.json'

The sources zip has 20 files, and 19 of them get this warning per extension (76 across the four extensions). The one without a warning is package.json, and only because a different file with that name exists in the extension folder. So its reported size is the extension's package.json, not the root one that was zipped.

Expected

No warnings, and correct sizes in the file list.

The zips themselves are correct: rebuilding each extension from its sources zip gives a Firefox build that is byte-for-byte identical. Only the log output is wrong.

Likely cause (as observed)

In zip.ts, printFileList(..., wxt.config.zip.sourcesRoot, files) receives file paths relative to sourcesRoot. But printFileList calls lstat(file) on those relative paths without resolving them against baseDir. They end up resolved against process.cwd() (the extension folder), not the sources root. Resolving with path.resolve(baseDir, file) before lstat would fix it.

Related: #1735 (same function, different cause).

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions