-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Open
Open
Copy link
Labels
feat: hmrp2-edge-caseBug, but has workaround or limited in scope (priority)Bug, but has workaround or limited in scope (priority)
Description
Describe the bug
Even after #20768, the prune event is missed when removing the only import
from the parent module since import analysis plugin bails out when es-module-lexer
detects imports.length === 0
.
vite/packages/vite/src/node/plugins/importAnalysis.ts
Lines 295 to 306 in 2c47acc
if ( | |
!imports.length && | |
!(this as unknown as TransformPluginContext)._addedImports | |
) { | |
importerModule.isSelfAccepting = false | |
debug?.( | |
`${timeFrom(msAtStart)} ${colors.dim( | |
`[no imports] ${prettifyUrl(importer, root)}`, | |
)}`, | |
) | |
return source | |
} |
The reproduction below uses pkg.pr.new from #20768
Reproduction
https://stackblitz.com/edit/github-oc2husn5?file=src%2Fdep.js
Steps to reproduce
- run
pnpm run
- open http://localhost:5173/
- observe orange text
- comment out
import "./test.css"
fromsrc/dep.js
- observe text is still orange
- reload browser
- observe text is not orange
System Info
System:
OS: Linux 5.0 undefined
CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 0 Bytes / 0 Bytes
Shell: 1.0 - /bin/jsh
Binaries:
Node: 20.19.1 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 10.8.2 - /usr/local/bin/npm
pnpm: 8.15.6 - /usr/local/bin/pnpm
npmPackages:
@vitejs/plugin-react: ^5.0.0 => 5.0.2
vite: https://pkg.pr.new/vite@2c47acc => 7.1.5
Used Package Manager
pnpm
Logs
No response
Validations
- Follow our Code of Conduct
- 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.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- 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.
Metadata
Metadata
Assignees
Labels
feat: hmrp2-edge-caseBug, but has workaround or limited in scope (priority)Bug, but has workaround or limited in scope (priority)