Skip to content

TS5011: rootDir error with TypeScript 6 in e2e tests — ts-loader 9.5.2 still bundled in 15.14.1 #33648

@pauljohnberry

Description

@pauljohnberry

Current behavior

Running Cypress 15.14.1 e2e tests with TypeScript 6 produces:

Error: Webpack Compilation Error
[tsl] ERROR
      TS5011: The common source directory of 'tsconfig.json' is './e2e'. The 'rootDir' setting must be explicitly set to handle the input files.

This occurs despite tsconfig.json having "rootDir": ".." explicitly set. TypeScript 6 strict rootDir enforcement is triggered because the bundled ts-loader@9.5.2 calls transpileModule with rootDir: undefined, overriding the tsconfig. See: TypeStrong/ts-loader#1678. Fixed in ts-loader 9.5.7. The pin lives in npm/webpack-batteries-included-preprocessor/package.json"ts-loader": "9.5.2".

Note: This is distinct from #33385 (TS5101/TS5107 deprecated options). Component tests are unaffected; only the e2e webpack preprocessor is impacted.

Desired behavior

e2e specs compile without error when using TypeScript 6.

Test code to reproduce

  1. Create a project with Cypress 15.14.1 and TypeScript 6
  2. Add any e2e spec in e2e
  3. Set "typescript": "^6.0.0" in package.json
  4. Run npx cypress run --e2e

Minimal reproduction: add "rootDir": ".." to tsconfig.json — the error persists because ts-loader ignores it.

Cypress Version

15.14.1

Debug Logs

cypress:webpack-batteries-included-preprocessor found user tsconfig.json at <project>/cypress/tsconfig.json with compilerOptions: {"rootDir":"..","skipLibCheck":true,...}
cypress:webpack ts-loader detected: overriding tsconfig to use sourceMap:true, inlineSourceMap:false, inlineSources:false (TypeScript 6.0.3)
cypress:webpack typescript version 6.0.3 is not supported for monkey-patching
cypress:webpack stats had error(s) [{
  moduleIdentifier: '.../ts-loader/index.js??ruleSet[1].rules[3].use[0]!/path/to/cypress/e2e/mytest.cy.ts',
  message: '[tsl] ERROR\n      TS5011: The common source directory of \'tsconfig.json\' is \'./e2e\'. The \'rootDir\' setting must be explicitly set to this or another path to adjust your output\'s file layout.\n  Visit https://aka.ms/ts6 for migration information.',
  stack: 'Error: [tsl] ERROR\n      TS5011: ...\n    at getTranspilationEmit (.../ts-loader/dist/index.js:428:49)\n    at successLoader (.../ts-loader/dist/index.js:38:11)\n    at Object.loader (.../ts-loader/dist/index.js:23:5)'
}]

Other

Expected fix: bump ts-loader from 9.5.2>=9.5.7 in npm/webpack-batteries-included-preprocessor/package.json.

see: https://github.com/TypeStrong/ts-loader/releases/tag/v9.5.7

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions