Skip to content

[Regression]: ESM Directory Import is not working anymore with Playwright's ESM Loader activated #31811

@mxschmitt

Description

@mxschmitt

Last Good Version

1.42

First Bad Version

1.43

Steps to reproduce

Repo + Reproduction steps are in the repository: https://github.com/schickling-test/2024-playwright-esm-repro

Expected behavior

Works

Actual behavior

Error: Directory import '/Users/maxschmitt/Developer/tmp/2024-playwright-esm-repro/packages/@acme/lib' is not supported resolving ES modules imported from /Users/maxschmitt/Developer/tmp/2024-playwright-esm-repro/packages/@acme/tests/src/hello.test.ts

Additional context

We run into this if for the directory import:

and then pass the directory as a file:// URL to the defaultResolver which breaks.

I throws here: https://github.com/nodejs/node/blob/e192a32c27f223e7a3dcb43134fd891dd8ded760/lib/internal/modules/esm/resolve.js#L254

Workaround, add a check like !require('fs').statSync(resolved).isDirectory().

Environment

N/A

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions