playwright icon indicating copy to clipboard operation
playwright copied to clipboard

[Bug]: Cannot import `.ts` files from packages linked with the `file:` protocol using `pnpm`

Open giacomoran opened this issue 1 year ago • 1 comments

Version

1.48.0

Steps to reproduce

  1. Clone repo containing two packages at https://github.com/giacomoran/playwright-loader-ts. The package package-ts exports src/index.ts directly; the package package-playwright depends on package-ts, the dependency is specified with the file: protocol.
  2. cd package-playwright
  3. pnpm install
  4. pnpm playwright test
  5. An error should come up

Expected behavior

The tests should run successfully.

Actual behavior

Playwright ESM loader fails to load .ts files from package-ts, which is linked with the file: protocol. The following error comes up:

TypeError: Unknown file extension ".ts" for /Users/giacomoran/Tmp/playwright-loader-ts/package-playwright/node_modules/.pnpm/package-ts@file+..+package-ts/node_modules/package-ts/src/index.ts

The error does not come up by installing the packages with npm instead of pnpm (repo commit https://github.com/giacomoran/playwright-loader-ts/tree/6195d7b3247596b2bdb65995af79c9669bd164cc).

The error does not come up by running npx tsx test.ts, which contains the same import from package-ts as tests/example.spec.ts.

Additional context

Our current workaround is to run:

NODE_OPTIONS="--import tsx" PW_DISABLE_TS_ESM=true pnpm playwright test

Environment

System: OS: macOS 14.6.1 CPU: (12) arm64 Apple M2 Max Memory: 11.26 GB / 96.00 GB Binaries: Node: 20.12.2 - ~/.asdf/installs/nodejs/20.12.2/bin/node Yarn: 1.22.22 - ~/.asdf/installs/nodejs/20.12.2/bin/yarn npm: 10.8.2 - ~/.asdf/plugins/nodejs/shims/npm pnpm: 9.5.0 - ~/.asdf/installs/nodejs/20.12.2/bin/pnpm IDEs: VSCode: 1.90.2 - /opt/homebrew/bin/code Languages: Bash: 5.2.26 - /opt/homebrew/bin/bash

giacomoran avatar Oct 10 '24 07:10 giacomoran

File protocol + pnpm + esm + ts export would be a very narrow use case for us to prioritize. I'll leave it as P3, but it is likely to self-close in 6 months due to lack of interest.

pavelfeldman avatar Oct 10 '24 19:10 pavelfeldman

Why was this issue closed?

Thank you for your contribution to our project. This issue has been closed due to its limited upvotes and recent activity, and insufficient feedback for us to effectively act upon. Our priority is to focus on bugs that reflect higher user engagement and have actionable feedback, to ensure our bug database stays manageable.

Should you feel this closure was in error, please create a new issue and reference this one. We're open to revisiting it given increased support or additional clarity. Your understanding and cooperation are greatly appreciated.

pavelfeldman avatar Sep 04 '25 01:09 pavelfeldman