New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Regression in 1.27 for ESM file extensions #18077
Comments
Things work for me using exact import from your example.
Note that since you do not specify "type": "module", you are running in the CJS mode, tsconfig has no control over the Node runtime. So your TS imports are converted into the requires. |
Yes we probably should change to I do have workarounds such as using |
There were subtle changes to the resolver/loader, they could have affected things. In either case, if you have a small repro where |
Sure! I was able to create a fairly-simple repro: https://github.com/drwpow/playwright-import-repro/. Curious if this is just something weird on my machine or if you see the error too here. |
Awesome, thanks, I can repro it. I just could not add 2 + 2 in your original description - now that I read it, it explains the use case very well. // example.test.ts
import { gimmeAOne } from "./playwright-utils.js"; // playwright-utils.ts
export function gimmeAOne() {
return 1;
} does not work in Playwright v1.27 in non-ESM mode. |
Context:
Code Snippet
Trying to import
test-utils.ts
in a Playwright test:Describe the bug
When trying to import
.ts
files, ESM requires an extension. This was working in version1.26
. However, when upgrading to1.27
, the “Cannot find module
” error occurs. Downgrading back to1.26
again fixes the problem and the file is imported just fine.Worth highlighting that
test-utils.ts
(TypeScript) is the extension, not.js
, but following convention.js
is preferred.Also worth noting that my repo is not
"type": "module"
which may be causing an issue (but we are using ESM throughout and are using"module": "ESNext"
in TSConfig).The text was updated successfully, but these errors were encountered: