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.

Feature: Transparent interoperability for ESM importing CommonJS #100

@GeoffreyBooth

Description

@GeoffreyBooth
  • ESM files can import CommonJS files and packages using full ES2015 syntax, the same as if the module to be imported was ESM.
  • ESM importing a member of a CommonJS module is understood by bundlers for the purpose of tree-shaking.
  • A CommonJS module that does things that are impossible in ESM (assuming there still are any such things) can still be imported by an ESM file.
// a.js
module.exports = { b: 10 };

// b.js
import { b } from './a.js';
console.log(b); // 10

Use cases 8, 10, 12, 18, 39, 20, 40, 41, 42, 47, 48.

I know this is a rather huge feature, so it’s probably best to break out the components that make it up into issues of their own.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions