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

Unable to supply own ts-node ignore values in tsconfig.json #26606

Open
spiltcoffee opened this issue Apr 27, 2023 · 2 comments
Open

Unable to supply own ts-node ignore values in tsconfig.json #26606

spiltcoffee opened this issue Apr 27, 2023 · 2 comments
Labels
E2E Issue related to end-to-end testing Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team.

Comments

@spiltcoffee
Copy link

spiltcoffee commented Apr 27, 2023

Current behavior

I have a bit of a strange project setup, but this was working prior to 12.10.0, so I think it's worthy of listing as a bug as maybe you guys might see it as a regression? Let's see what you guys think.

So, I have a monorepo of packages using Yarn workspaces. In this, I have a number of projects which have their own TypeScript files. So, let's say I have package @spiltcoffee/a that uses package @spiltcoffee/b, and there's TypeScript in b that is being used by a. To get this to work, I've been setting the ts-node ignore to something like the following in my tsconfig.json:

{
  "ts-node": {
    "ignore": ["(?:^|/)node_modules(?!/@spiltcoffee)"]
  }
}

Due to some additional project layout that I won't get into, I also needed to use NODE_OPTIONS=--preserve-symlinks, which means that even though Yarn has setup a folder node_modules/@spiltcoffee/b as a symbolic link, the script isn't allowed to resolve that link to it's underlying folder. If I didn't need to use --preserve-symlinks, the above ignore would not be required.

As part of 12.10.0, it appears that Cypress has become opinionated about the ignore, so the above configuration is blown away by this:

ignore: [
// default ignore
'(?:^|/)node_modules/',
// do not transpile cypress resources
// getIgnoreRegex({ configDir: dir, currentFileDir: __dirname, sep: path.sep }),
// This is not ideal, We are transpiling any pre-built cypress code along with the config file
// Ideally we'd only transpile the config file but deriving the correct has proven to be tricky
// due to differences between dev and prod, and quirks of ts-node's path handling
// We do not want to ignore too much or too little
// So for now we are only ignoring the explicit file that has issues
'/packages/telemetry/dist/span-exporters/ipc-span-exporter',
],

As a result, I cannot run my Cypress project anymore in 12.10.0 or higher, as my cypress.config.ts makes a reference to a TypeScript file in @spiltcoffee/b:

Your configFile is invalid: <snip>\@spiltcoffee\a\cypress.config.ts

It threw an error when required, check the stack trace below:

TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for <snip>\@spiltcoffee\a\cypress.config.ts
    at new NodeError (node:internal/errors:399:5)
    at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:79:11)
    at defaultGetFormat (node:internal/modules/esm/get_format:121:38)
    at defaultLoad (node:internal/modules/esm/load:81:20)
    at nextLoad (node:internal/modules/esm/loader:163:28)
    at ESMLoader.load (node:internal/modules/esm/loader:605:26)
    at ESMLoader.moduleProvider (node:internal/modules/esm/loader:457:22)
    at new ModuleJob (node:internal/modules/esm/module_job:64:26)
    at ESMLoader.#createModuleJob (node:internal/modules/esm/loader:480:17)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:434:34)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)

Desired behavior

That my ts-node ignore value is respected or merged into the ignore value Cypress sets.

Test code to reproduce

See https://github.com/spiltcoffee/cypress-ts-node-ignore-bug

Cypress Version

12.10.0

Node version

v18.16.0

Operating System

Windows 10.0.19045

Debug Logs

No response

Other

No response

@warrensplayer
Copy link
Contributor

@spiltcoffee Sorry for the delay in looking at this. Looking at it now.

@warrensplayer
Copy link
Contributor

@spiltcoffee I have replicated your problem in the latest version of Cypress and will forward this ticket to the appropriate team. They will soon evaluate the priority of this ticket and consider their capacity to pick it up. Please note that this does not guarantee that this issue will be resolved. The ticket will indicate status changes during evaluation, so we ask that you please refrain from asking for updates. Thanks!

@warrensplayer warrensplayer added E2E Issue related to end-to-end testing Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team. labels Jun 12, 2023
@warrensplayer warrensplayer removed their assignment Jun 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E2E Issue related to end-to-end testing Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team.
Projects
None yet
Development

No branches or pull requests

3 participants