Skip to content
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

es-next/compiler.js fails to resolve module after typescript successfully resolves and compiles it #7436

Closed
cdaringe opened this issue Dec 22, 2022 · 11 comments
Labels
FREQUENCY: level 1 STATE: Stale An outdated issue that will be automatically closed by the Stale bot. TYPE: bug The described behavior is considered as wrong (bug).

Comments

@cdaringe
Copy link

What is your Scenario?

I want to:

  • use typescript
  • use tsconfig::compilerOptions::paths (and tsconfig::extends, but not related to this issue)
  • use testcafe

What is the Current behavior?

Internally, the typescript compiler compiles page.test.ts fine. A downstream es-next compiler cannot resolve a module that the typescript compiler resolved.

What is the Expected behavior?

Either not use the es-next compiler, or extend es-next compiler module resolution with paths as used from the typescript compiler.

What is your public website URL? (or attach your complete example)

tiny, minimal reproduction posted here: https://github.com/cdaringe/testcafe-path-resolution-typescript

What is your TestCafe test code?

// test/page.test.ts
import { foo } from "foo";
import { ClientFunction } from "testcafe";

fixture`foo`.page("http://localhost:3333");

const log = ClientFunction(() => console.log("sup"));

test("bar", async (t) => {
  foo();
  await log();
  await t.debug();
});
// src/foo.ts
export const foo = () => "bar";

Your complete configuration file

none, cli only.

DEBUG=testcafe* testcafe --compiler-options='typescript.configPath=tsconfig.json' chrome test/

Your complete test report

n/a

Screenshots

Error: Cannot find module 'foo'
Require stack:
- /demo/test/page.test.ts
- /demo/node_modules/.pnpm/[email protected]/node_modules/testcafe/lib/compiler/test-file/formats/es-next/compiler.js
- /demo/node_modules/.pnpm/[email protected]/node_modules/testcafe/lib/compiler/compilers.js
- /demo/node_modules/.pnpm/[email protected]/node_modules/testcafe/lib/compiler/index.js
- /demo/node_modules/.pnpm/[email protected]/node_modules/testcafe/lib/runner/bootstrapper.js
- /demo/node_modules/.pnpm/[email protected]/node_modules/testcafe/lib/runner/index.js
- /demo/node_modules/.pnpm/[email protected]/node_modules/testcafe/lib/testcafe.js
- /demo/node_modules/.pnpm/[email protected]/node_modules/testcafe/lib/index.js
- /demo/node_modules/.pnpm/[email protected]/node_modules/testcafe/lib/cli/cli.js
- /demo/node_modules/.pnpm/[email protected]/node_modules/testcafe/lib/cli/index.js

Steps to Reproduce

run the reproduction

TestCafe version

2.2.0-rc.1

Node.js version

18.4.0

Command-line arguments

testcafe --compiler-options='typescript.configPath=tsconfig.json' chrome test/

Browser name(s) and version(s)

chrome

Platform(s) and version(s)

macos 12.6.1

Other

n/a

@cdaringe cdaringe added the TYPE: bug The described behavior is considered as wrong (bug). label Dec 22, 2022
@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Dec 22, 2022
@Aleksey28
Copy link
Collaborator

Hi @cdaringe,

You cannot override the target compiler option in the TypeScript configuration file. However, there is PR that supports native ESM. You can use it once it is merged and published.

@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label Dec 23, 2022
@cdaringe
Copy link
Author

hey @Aleksey28 , thx for the reply. i've dropped target from the demo so as to keep this bug report focused on the resolution issue. indeed, i don't need that target, i just used a bunch of the defaults from tsc --init, but i appreciate the tip/ref regardless!

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Dec 23, 2022
@Aleksey28
Copy link
Collaborator

Hi @cdaringe,

You're welcome. I'll close the issue. Feel free to contact us if you have further questions.

@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label Dec 26, 2022
@cdaringe
Copy link
Author

@Aleksey28 forgive me—the issue should not be closed. The issue should remain open. My above remark was politely stating that your suggestion is not relevant to this specific problem

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Dec 26, 2022
@Aleksey28
Copy link
Collaborator

Ok. In this case, please update your example so that I can run it and reproduce this error.

@Aleksey28 Aleksey28 reopened this Dec 27, 2022
@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label Dec 27, 2022
@cdaringe
Copy link
Author

@Aleksey28, the example is updated and runnable, with instructions in the repo. thanks!

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Dec 27, 2022
@Aleksey28
Copy link
Collaborator

I managed to reproduce the issue. We will update this thread once we have any news.

@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label Dec 30, 2022
@hendriku
Copy link

Thanks for providing a minimal example; I've already spent hours on debugging that in our project. Are there any known workarounds or versions where this bug is not present in?

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Mar 27, 2023
@Klaster1
Copy link

@hendriku #4144

@miherlosev miherlosev removed the STATE: Need response An issue that requires a response or attention from the team. label Mar 28, 2023
Copy link

This issue has been automatically marked as stale because it has not had any activity for a long period. It will be closed and archived if no further activity occurs. However, we may return to this issue in the future. If it still affects you or you have any additional information regarding it, please leave a comment and we will keep it open.

@github-actions github-actions bot added the STATE: Stale An outdated issue that will be automatically closed by the Stale bot. label Mar 16, 2024
Copy link

We're closing this issue after a prolonged period of inactivity. If it still affects you, please add a comment to this issue with up-to-date information. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FREQUENCY: level 1 STATE: Stale An outdated issue that will be automatically closed by the Stale bot. TYPE: bug The described behavior is considered as wrong (bug).
Projects
None yet
Development

No branches or pull requests

6 participants