Skip to content

Conversation

@almadoro
Copy link

@almadoro almadoro commented Nov 9, 2025

Trigger prune event when the last import of a module is removed.

Fixes #20781

Since imports.length is 0, there are no imported, accepted, or statically imported modules. Therefore, moduleGraph.updateModuleInfo is called with empty sets to get the prunedImports and trigger the event.

!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?

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?

@sapphi-red sapphi-red added feat: hmr p2-edge-case Bug, but has workaround or limited in scope (priority) labels Dec 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat: hmr p2-edge-case Bug, but has workaround or limited in scope (priority)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

prune event is not triggered when removing the last import of the parent module

2 participants