Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion packages/vite/src/node/plugins/importAnalysis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,17 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin {
!imports.length &&
!(this as unknown as TransformPluginContext)._addedImports
) {
importerModule.isSelfAccepting = false
Copy link
Member

Choose a reason for hiding this comment

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

I guess we need to keep this line. What was the reason to remove this line?

const prunedImports = await moduleGraph.updateModuleInfo(
importerModule,
new Set(),
null,
new Set(),
null,
false,
)
if (prunedImports) {
handlePrunedModules(prunedImports, environment)
}
debug?.(
`${timeFrom(msAtStart)} ${colors.dim(
`[no imports] ${prettifyUrl(importer, root)}`,
Expand Down
7 changes: 0 additions & 7 deletions playground/hmr/prune/dep1.js
Copy link
Member

Choose a reason for hiding this comment

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

Would you add a separate test for the previous one so that we have a test that covers the non-early-return path?

Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
import './dep2.js'

// TODO: https://github.com/vitejs/vite/issues/20781
// currently we need one more `import` in this module
// to trigger prune for depending module `dep2.js` since
// the prune event logic is skipped when `es-module-lexer`
// detects `imports.length === 0`
import './dep2-other.js'
Empty file removed playground/hmr/prune/dep2-other.js
Empty file.