Skip to content

Lazy compilation + FS cache = incorrect export X (imported as X) was not found in ... #21318

Description

@Knagis

Have you used AI?

No

Bug Description

Sometimes lazy compilation loads cached compilation data and incorrectly states that a module does not have exports that it definitely does have (probably because the exports were dropped as unused in the previous run)

export 'useLocalObservable' (imported as 'useLocalObservable') was not found in 'mobx-react' (possible exports: MobXProviderContext, PropTypes, Provider, disposeOnUnmount, inject, observer)

Issue happens on development build.

Link to Minimal Reproduction and step to reproduce

Once I will get more info, or actual reproduction, I will add it to the issue. So far I haven't encountered this myself, but multiple colleagues have run into the exact same issue, unfortunately no one has figured out the repro steps.

Expected Behavior

no such error is thrown

Actual Behavior

compilation fails

Environment

webpack 5.108.3
node 24.13.0

Is this a regression?

Yes (please specify version below)

Last Working Version

5.106 (we didn't use 5.107 due to other issues so don't know about it)

Additional Context

custom settings that could be even remotely related:

experiments.cacheUnaffected: true
lazyCompilation.imports: false
lazyCompilation.entries: true
cache.type: filesystem
cache.memoryCacheUnaffected: true
optimization.removeAvailableModules: false
optimization.innerGraph: true

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions