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] tsconfig-loader tries to load non-existing tsconfig causing the correct config not to be used

See original GitHub issue

Context:

  • Playwright Version: 1.23.1
  • Operating System: Windows 10 x64
  • Node.js version: 16.17.0
  • Browser: All
  • Extra: [any specific details about your environment]

Code Snippet

import { Environment } from '@oas/internal-lib-e2e';

Describe the bug

I’m unable to import my monorepo package using TypeScript paths in the runner’s child process (it works in the main process). image

After a debugging session with myself here: https://github.com/microsoft/playwright/discussions/17466, i have come to the conclusion that the tsconfig-loader (https://github.com/microsoft/playwright/blob/29ff00ead2e79ea9b5374513f98801745e93b80c/packages/playwright-test/src/third_party/tsconfig-loader.ts#L60) is trying to resolve a tsconfig that doesn’t exists and then try to use that instead of the correct one in the package root (process.cwd() in the main process).

So here it is resolving a non-existent tsconfig file: image

And then it’s using that in the child process instead of the correct one with the paths: image

Since the cwd for the child process is the testDir from the config file, and not the package root, no matter what I do, I will have to wrong path since I use ./tsconfig.json as TS_NODE_PROJECT. It will always be resolved to the wrong path. My guess is that you do not want to return a non-existent tsconfig.json or return it but then don’t cache it in loadAndValidateTsconfigForFile here: https://github.com/microsoft/playwright/blob/42491ecc0867129b97fa2fbd4fe9c58ff0d3feff/packages/playwright-test/src/transform.ts#L79

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:18 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
pavelfeldmancommented, Sep 22, 2022

When resolving config for the TypeScript file, resolution is based on the filesystem nesting, so I’m not sure why cwd is used. We are inheriting this logic from tsloader, so we should have probably cleaned it up further.

0reactions
dgozmancommented, Oct 5, 2022

I discussed this issue with the team and we arrived to the following:

  • Removing TS_NODE_XXX env variables support, because we are not following ts-node semantics.
  • Do not respect tsconfig for javascript files as we do today.
  • Recommend a separate tsconfig.json in the tests directory for any test-specific path mappings.

Overall, Playwright assumes that each file is either:

  • A typescript source. In this case Playwright transforms it and respects tsconfig.
  • A javascript file. In this case Playwright assumes it’s ready to load as is.

If you have a question or need help with your setup, please share your repro and we’ll try to help as we can. If you believe there is still a problem, please file a new issue with a repro and link to this one.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Webpack ts-loader : change tsconfig filename - Stack Overflow
In Webpack 4 you need to specify the options into a use object: use: [{ loader: 'ts-loader', options: { configFile: "tsconfig.webpack.json" } }]....
Read more >
TSConfig Reference - Docs on every TSConfig option
The configuration from the base file are loaded first, then overridden by those in the inheriting config file. All relative paths found in...
Read more >
TypeScript errors and how to fix them
Fixed Code ✔️. Solution 1: When “importsNotUsedAsValues” is set to “error” in your “tsconfig.json”, then you have to use the ...
Read more >
Changelog - Cypress Documentation
Cypress component tests now correctly load assets with Angular. ... devServer configuration would cause the specs list to not display in the Cypress...
Read more >
fork-ts-checker-webpack-plugin - npm
If the process exits with the allocation failed error, try to increase this number. configFile, string, 'tsconfig.json', Path to the tsconfig.
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