Skip to content
This repository was archived by the owner on Sep 2, 2023. It is now read-only.
This repository was archived by the owner on Sep 2, 2023. It is now read-only.

Module Interop (CommonJS resources from ESModules) #10

@MylesBorins

Description

@MylesBorins

Kicking off this thread to discuss interop, specifically getting CommonJS (cjs) resources from inside of an ESModule(esm)

We currently have a transparent interop. .js is reserved for cjs and .mjs is reserved for esm. When you import, statically or dynamically, the file extension is used to determine the resource type.

There is a pull request to introduce modes which would change the behavior regarding file extensions depending on meta data in the package.json

There are two other proposals for how to get cjs resources that are non transparent, and would be necessary to if .js were to be aliased to esm

  • import.meta.require
  • import {require} from 'nodejs'

There has also been a suggestion of offering scoped variables in esm, similar to what we currently do with cjs.

What do people think?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions