[Feature]: Resolve Node.js subpath imports (package.json "imports") to TypeScript sources
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 57/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- node.js, playwright, typescript
Línea de trabajo
Start by comparing Playwright’s TypeScript path alias resolution with Node.js package.json "imports" resolution; the issue gives a minimal project layout and failing import in src/tests/get-env.test.ts. Run npx playwright test with the provided repro and confirm the test file loads when the alias is configured through "imports". Done when that import resolves to the TypeScript source and the test passes.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
🚀 Feature Request
Playwright resolves TypeScript path aliases from tsconfig.json (paths), but not the Node.js subpath imports mechanism (the package.json "imports" field) when the targets are TypeScript sources.
Re-filing with a concrete use case after the closure of #40062 (part of the P3-collecting-feedback cleanup described in #43813). Reproduced and verified against the latest version, @playwright/[email protected].
Two minimal, otherwise-identical projects demonstrate the inconsistency: the only difference between them is the resolution mechanism.
Project layout (both variants):
├── package.json
├── playwright.config.ts
├── tsconfig.json
└── src/
├── utils/env.ts
└── tests/get-env.test.ts
src/utils/env.ts:
export function getEnv(name: string): string {
const value = process.env[name];
if (value === undefined) {
throw new Error(`Missing environment variable: ${name}`);
}
return value;
}
src/tests/get-env.test.ts:
import { test, expect } from "@playwright/test";
import { getEnv } from "#/utils/env";
test("getEnv resolves a variable via the subpath import", () => {
process.env.PW_REPRO_VAR = "playwright";
expect(getEnv("PW_REPRO_VAR")).toBe("playwright");
});
playwright.config.ts:
import { defineConfig } from '@playwright/test';
export default defineConfig({
testDir: './src/tests',
});
Variant A — works (tsconfig.json path alias):
{
"compilerOptions": {
"paths": { "#/*": ["./src/*"] }
}
}
Variant B — fails (package.json subpath imports, same tsconfig.json minus paths):
{
"type": "module",
"imports": {
"#/*": ["./src/*", "./src/*.ts", "./src/*/index.ts"]
}
}
Run npx playwright test in each variant. Variant B fails when loading the test file:
Error: Cannot find module 'C:\path\to\repro\src\utils\env' imported from C:\path\to\repro\src\tests\get-env.test.ts
at eval (<anonymous>:1:1)
Error: No tests found
Both repro projects are attached as a zip archive.
Environment: @playwright/[email protected] (latest), Node.js v24.22.1, Windows.
Example
A project aliases its imports via the package.json "imports" field:
{
"type": "module",
"imports": {
"#/*": ["./src/*", "./src/*.ts", "./src/*/index.ts"]
}
}
The same specifier #/utils/env resolves fine with tsc and at runtime under Node, but npx playwright test fails with Cannot find module '...\src\utils\env' before any test runs.
Motivation
Today, the same import specifier resolves or fails depending on whether it goes through tsconfig.json paths or package.json imports. Supporting imports to TypeScript sources would make Playwright's resolver consistent with the Node.js and TypeScript ecosystems.
- Lenguaje dominante
- TypeScript
- Estrellas
- 99.1k
- Forks
- 6.8k
- Merge medio
- 17 h 6 min
- PR fusionados (30 d)
- 306
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de microsoft/playwright
-
Dificultad 3/5 1-2 días Aptitud para principiantes 76/100
microsoft/playwright#43987 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 72/100
microsoft/playwright#43986 ·
Los mantenedores suelen responder en 1 día
-
[Bug]: Embedded number/range inputs contribute their `value` attribute, not their current value, to accessible namesPosiblemente ocupada @lazerg la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 35/100
microsoft/playwright#43984 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 64/100
microsoft/playwright#43983 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
microsoft/playwright#43981 ·
Los mantenedores suelen responder en 1 día
Todos los issues de microsoft/playwright
Issues similares
-
FR: Support CJK brackets, symbols and full-width markers in footnoteHeuristics (EBPAJ support)Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
readest/readest#7413 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
content triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
eliasstravik/herdr-projects#788 ·
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Ability to edit tagsAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
Los mantenedores suelen responder en 1 día