Repository navigation
Description
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
Steps to reproduce
- Enable source map generation under
wxt.config.ts > defineConfig > vite > build - Add a hook that deletes the source maps after the build
- Run
pnpm build - 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.7Used Package Manager
pnpm
Validations
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Activity
donatoaguirre24 commentedon Jun 13, 2025
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.