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

fix: Resolve tsconfig.json for plugins file from the plugins directory #8377

Merged
merged 11 commits into from
Aug 24, 2020

Conversation

chrisbreiding
Copy link
Contributor

User facing changelog

  • Cypress now resolves and loads tsconfig.json for TypeScript projects starting from the plugins directory

Additional details

ts-node resolves the tsconfig.json starting from the current working directory (cwd) by default. This means using cypress/tsconfig.json won't work to specify TypeScript config for Cypress.

In reality, this only affected a couple options in tsconfig.json because only a couple options (e.g. "esModuleInterop", "downlevelIteration") affect the runtime. Any non-runtime options would take affect in a user's IDE because it would resolve the tsconfig.json starting from the directory of the opened file.

This PR changes it so ts-node will now start looking for the tsconfig.json from the plugins directory. That is cypress/plugins by default or the dirname of the plugins file path if a custom one is provided. For example, if the "pluginsFile" is set to <project root>/some/other/path/to/plugins.js, it will start looking in <project root>/some/other/path/to.

How has the user experience changed?

Users will now see runtime options in cypress/tsconfig.json take effect, whereas before they were ignored.

PR Tasks

  • Have tests been added/updated?
  • Has the original issue been tagged with a release in ZenHub?

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Aug 21, 2020

Thanks for taking the time to open a PR!

@cypress
Copy link

cypress bot commented Aug 21, 2020



Test summary

8137 0 108 3


Run details

Project cypress
Status Passed
Commit dc25751
Started Aug 24, 2020 8:32 PM
Ended Aug 24, 2020 8:38 PM
Duration 05:55 💡
OS Linux Debian - 10.2
Browser Multiple

View run in Cypress Dashboard ➡️


This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

@chrisbreiding chrisbreiding requested a review from kuceb August 21, 2020 17:21
- no longer register ts-node it in the parent process, only in the child process
- DRYed up resolving typescript path
- added test for not registering ts-node more than once
@chrisbreiding chrisbreiding requested a review from kuceb August 21, 2020 18:59
Copy link
Contributor

@kuceb kuceb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 IRTC (I ran the code)

Copy link
Member

@jennifer-shehane jennifer-shehane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example from the original issue still fails within this PR. It is a different error however, so just want to double check if this is a separate issue. #8359 (comment)

Screen Shot 2020-08-24 at 2 10 29 PM

@chrisbreiding
Copy link
Contributor Author

@jennifer-shehane That error occurs because Node doesn't support the import syntax in .js files. It has to be .ts with TypeScript set up or be .mjs for Node to natively handle it. This PR fixes TypeScript support, so it will only affect a .ts plugins file.

@chrisbreiding chrisbreiding changed the title fix: Resolve tsconfig.json for plugins process from the plugins directory fix: Resolve tsconfig.json for plugins file from the plugins directory Aug 24, 2020
@chrisbreiding chrisbreiding merged commit 383fa22 into develop Aug 24, 2020
@chrisbreiding chrisbreiding deleted the issue-8359-esmoduleinterop branch April 5, 2022 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cypress doesn't evaluate "esModuleInterop": true in cypress/tsconfig.json?
3 participants