Skip to content

Fix - populate separate cache for require(esm) is a breaking change #59868

@alexander-akait

Description

@alexander-akait

Version

24.8.0

Platform

any

Subsystem

No response

What steps will reproduce the bug?

In webpack we cache build dependencies (and nested require in any deps) and use this logic before (sinplified):

const module = require.cache[path];

if (module) { 
  // it is a common js module
  // we go through children and then also for their children and etc
} else if (/\.m?js$/.test(path)) {
  // it is ES modules or something else
  // here we use `es-module-lexer` to get all `import`s
}

Now this logic is broken, not only webpack uses this logic, it can break more tools

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior? Why is that the expected behavior?

This change should be a part of the next major release, not minor

What do you see instead?

Logic is broken

Additional information

Ref - #59679

Metadata

Metadata

Assignees

No one assigned

    Labels

    moduleIssues and PRs related to the module subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions