-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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]: Dynamic Import of ES Module fails in Playwright v1.44.1 and 1.43.1 (works in v1.42.1 and below) #31140
Comments
I'm seeing this error too when upgrading playwright. Given the stack trace, my guess is that #29644 might be the cause of the regression. |
Happy to look into import/require regressions, but looking at the
also it requires a @askoufis do you depend on the same module? |
@mxschmitt Nope. In my case, a dynamic import of an ES Module is being converted into a |
@mxschmitt I've made a reproduction of my specific situation. https://github.com/askoufis/playwright-31140-reproduction Notably, the test file imports from a This used to work on |
It is client side lib but we are using it in node, user agent and platform are mocked by setting those values on global. It's working well up until 1.43 version. I suppose what's used does not really matter, it's just that dynamic imports are converted to require based on error message. @askoufis repro makes more sense. |
Thank you @askoufis as well! Looking at this smaller repro, changing the test file to a normal Node.js script file: const { getFoo } = require("./module1.cjs");
(async () => {
const foo = await getFoo();
console.log({ foo })
})(); shows that its working without Playwright. Playwright should behave always identical to Node.js, in this case it works in Node.js while it doesn't with Playwright. We'll look into it. |
I am facing this issue too. While debugging, I noticed that after this change the code started breaking - b41b802#diff-0f8a2f313f1572108f59a6e84663858ebb4fc455163410526b56878794001103R243 However, I have unblocked myself by doing a yarn patch and by changing back exts for Pirates back to
Waiting for 1.45 Root Cause:
|
Version
1.43.1 - 1.44.1
Steps to reproduce
npm install
npx playwright install
npx playwright test
Expected behavior
Expected tests to pass
Actual behavior
Throws an error
Additional context
While attempting to import the ES Module @braze/web-sdk dynamically in a CommonJS setup, an error is encountered with a specific versions of Playwright. The issue does not occur with older versions of Playwright like 1.42.1 and below.
1.41.1 - works
1.42.1 - works
1.43.1 - error
1.44.1 - error
Environment
The text was updated successfully, but these errors were encountered: