Skip to content

Default --experimental-detect-module to commonjs in require hooks #53016

@avivkeller

Description

@avivkeller

When detect-module is enabled by default (as seen in this image), we're encountering failures in several tests from test/es-module. While most of these failures are expected due to the changes, two of them are not:

These errors seem to be related to how the format context property is defined. We've attempted various solutions, but we're seeking input on the next steps on how to properly define this property.

Some ideas we're considering:

  1. Ensure format is always defined: We could make sure format is never undefined, even if we don't know what it should be.

    • Pros:
      • Eliminates concerns about different edge cases for return types.
      • Avoids the need to redefine format multiple times internally.
    • Cons:
      • If we don't know the format, what value should we set it to?
  2. Distinguish null and undefined formats: Specifically for this use case, we could differentiate between null and undefined formats.

    • Pros:
      • Could work well for our purposes.
      • Requires minimal effort to implement.
    • Cons:
      • Maintenance could be challenging, as future changes would need to understand this distinction.

Do you have any insights or suggestions on these approaches, or perhaps an alternative solution we haven't considered?

Metadata

Metadata

Assignees

No one assigned

    Labels

    loadersIssues and PRs related to ES module loadersmoduleIssues 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