Skip to content

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

@spiltcoffee

Description

@spiltcoffee

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    E2EIssue related to end-to-end testingTriagedIssue has been routed to backlog. This is not a commitment to have it prioritized by the team.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions