Closed balazStefan closed 11 months ago
I am using inside package.json "type":"module" ,... The problem is when I remove type:module everything is working ..
And you have "module": "commonjs",
in your tsconfig which sounds wrong. Folding this into https://github.com/microsoft/playwright/issues/23662
no, I do not in both I have type: module
System info
Source code
I got problem with playwright inside rush js monorepo . I got different modules each module should have own folder testing, and inside it there should be place for a tests , testcases etc. NO own playwright.config.ts , I am using inside package.json "type":"module" , and using in script section like this : "test:rendering": "cross-env NODE_ENV=test playwright test --config=../../../framework/e2e-tests/playwright/playwright.config.ts modules/gallery/rendering-page/e2e/rendering/", but it returns error like this on photo . The problem is when I remove type:module everything is working , but I need to have inside tsconfing.json this configuration : In order for TypeScript to work with ESM properly (type module in the package.json) it needs certain values set for moduleResolution . For server/NodeJS code: moduleResolution: NodeNext For frontend/bundled code: moduleResolutiion: Bundler (same as NodeNext but doesn’t require file extension in imports, which NodeJS needs in ESM mode) Those settings will enable Typescript reading the exports field in the package.jsons and also enable certain CJS/ESM compatibility things. One thing to take away from this: We are using moduleResolution: Node or Node10 in a lot of places. Wherever you see this, we should update to the values above (depending on whether it’s bundled code or NodeJS code). This will make switching on type: module easier in the future.
Config file
Steps
Expected
I am able to run tests from independent module and it can find configuration, problem , is for playwright it transform it like this { "compilerOptions": { "target": "ESNext", "module": "commonjs", "moduleResolution": "Node", "sourceMap": true, "outDir": "../tests-out", } }
Actual behavior is on photo