Skip to content

ESM builds in packages do not fully specify imports #73362

@anomiex

Description

@anomiex

ESM requires that relative imports be fully specified. For example, these are not allowed:

import stuff from './subdir';
import otherStuff from './a-file';

Instead these must be written like this:

import stuff from './subdir/index.js';
import otherStuff from './a-file.js';

Some tooling is lenient in this respect, while other tooling requires it. Webpack, for example, enforces this when the file is supposed to contain ESM code (but not when it’s supposed to be CommonJS even though Webpack accepts ESM content, which is why you’re not seeing this already, but that’s a different bug).

Let's stick to ESM-compliant code so packages can be consumed in an environment-agnostic setup without special configuration.

In the meantime, people using Webpack to consume these packages can set resolve.fullySpecified to work around this. There may be similar workarounds available for other bundlers.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions