Skip to content

Distributed ESM build is not actually ESM compatible #1306

@adamstoffel

Description

@adamstoffel

Description of the Issue

The code distributed in the lib-esm folder is not actually ES module compatible. It uses the node-specific require() syntax. While many bundlers are compatible with require, it can cause optimization bail-outs.

Looks like this was a regression which started in [email protected] (19.0.0 was using import/export syntax).

Steps to Reproduce

n/a

Expected Behavior

Code in lib-esm should use the import { } from './path' syntax.

Even the code from [email protected] was not fully ESM compatible (it did not include file extensions in import statements). A solution might be to use a rollup config that emits ESM syntax and maintains the existing src folder structure (per the glob-related suggestion in the Rollup guide: https://rollupjs.org/configuration-options/#input).

Error Message, Including Stack Trace

n/a

Screenshots

n/a

Versions Used

Typescript SDK: [email protected]
Platform: Browser
Node.js (if applicable): n/a

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions