Skip to content

ESM-only #20585

@tay1orjones

Description

@tay1orjones

require(esm) has shipped in node and been backported without a flag all the way to node 20 (currently maintenance). I don't believe we're using top level await, so this should give us the ability to explore dropping the commonjs builds. Our packages are primarily targeted at the browser and consumers use a bundler(we should keep in mind SSR though).

There's a very small chance backwards compatibility is great enough via export { Foo as 'module.exports' } for us to do this as semver-minor and ship it in v11. Otherwise we'll need to wait for v12.

The first task here is to make sure the codebase is fully esm. Then explore an esm-only build and test it against an array of projects to assess impact. The benefits for both consumers and maintainers need to be quantified - bundle size, reduced module duplication, build system simplification, etc.

Worth noting that node 18 has EOL and we could/should bump engines to 20 before looking at this.

Resources

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    🪆 Needs Refined

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions