question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Regression in 1.27 for ESM file extensions

See original GitHub issue

Context:

  • Playwright Version: 1.27.1
  • Operating System: macOS
  • Node.js version: 18.10
  • Browser: N/A
  • Extra: N/A

Code Snippet

Trying to import test-utils.ts in a Playwright test:

// App.test.ts
import { setupTest } from './test-utils.js';

// Error: Cannot find module './test-utils.js'

Describe the bug

When trying to import .ts files, ESM requires an extension. This was working in version 1.26. However, when upgrading to 1.27, the “Cannot find module” error occurs. Downgrading back to 1.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).

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
pavelfeldmancommented, Oct 20, 2022

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.

0reactions
drwpowcommented, Oct 20, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

rollup changelog
The file structure of Rollup's ESM builds has changed: The main ESM entry point is now at rollup/dist/es/rollup.js instead of rollup/dist/rollup ...
Read more >
griebnitz/node_modules/rollup/CHANGELOG.md - GitLab
The file structure of Rollup's ESM builds has changed: The main ESM entry point is now at rollup/dist/es/rollup.js instead of rollup/dist/rollup.
Read more >
BusyBox
Bug fix release. 1.27.2 has fixes for svc (work correctly with more than one option specified), unzip (big-endian fix), shuf (was always ...
Read more >
What is Regression Testing? Definition, Tools, Method, and ...
Regression testing is a type of testing that is done to verify that a code change in the software does not impact the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found