Skip to content

printFileList causes the build to fail if files are deleted before it runs #1735

Closed

Description

@donatoaguirre24

Describe the bug

I'm using @sentry/vite-plugin to upload the source maps during the build process.

Given that source maps considerably increase the bundle size, I want to use the plugin's sourcemaps.filesToDeleteAfterUpload option to delete source maps after they've been uploaded to Sentry.

Enabling that causes my builds to fail with the following error: ENOENT: no such file or directory, lstat '/Users/my-user/Developer/Project/.output/chrome-mv3/background.js.map'.

At first, I thought the plugin was causing the issue, so I added a hook to delete the source maps after the build finished. However, this produced the same result.

I searched the WXT codebase for occurrences of lstat and found it is used by the printFileList function. I suspect the files parameter is passed before the build finishes, so it contains elements that no longer exist, which causes fs.lstat(file) to throw an error, but I'm not sure how to fix it or disable it.

Any help would be appreciated!

hooks: {
  'build:done': ({ config }) => {
    if (config.mode === 'production') {
      rimrafSync('.output/**/*.js.map', { glob: true });
      console.log('Source maps deleted');
    }
  },
},

Reproduction

Build-Issue-Reproduction.zip

Steps to reproduce

  1. Enable source map generation under wxt.config.ts > defineConfig > vite > build
  2. Add a hook that deletes the source maps after the build
  3. Run pnpm build
  4. The build fails with the error described earlier

The reproduction I attached already has source maps generation enabled and the post-build hook that deletes them.

System Info

System:
  OS: macOS 15.5
  CPU: (11) arm64 Apple M3 Pro
  Memory: 115.98 MB / 18.00 GB
  Shell: 5.9 - /bin/zsh
Binaries:
  Node: 22.16.0 - ~/.local/share/mise/installs/node/22.16.0/bin/node
  npm: 11.4.1 - ~/.local/share/mise/installs/node/22.16.0/bin/npm
  pnpm: 10.4.1 - ~/.local/share/mise/installs/node/22.16.0/bin/pnpm
  Watchman: 2025.05.26.00 - /opt/homebrew/bin/watchman
Browsers:
  Brave Browser: 137.1.79.123
  Safari: 18.5
npmPackages:
  wxt: ^0.20.6 => 0.20.7

Used Package Manager

pnpm

Validations

Activity

  1. added
    pending-triage
    on Jun 13, 2025
  2. donatoaguirre24 commented on Jun 13, 2025

    @donatoaguirre24
    Author

    Given that source maps are only an issue for production builds, as a temporary workaround, I'm using the following hook to delete them before generating the zip file.

    hooks: {
      'zip:extension:start': ({ config }) => {
        if (config.mode === 'production') {
          console.log('Attempting to delete source maps');
          rimrafSync('.output/**/*.js.map', { glob: true });
          console.log('Source maps deleted');
        }
      },
    }
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

    pending-triage

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions