Skip to content

@cypress/webpack-preprocessor is incorrectly detecting exports-loader as ts-loader and adding a compilerOptions config option #32265

@brunolemos

Description

@brunolemos

Current behavior

After upgrading @cypress/webpack-preprocessor from 6.0.2 to 6.0.3 cypress fails with a webpack error with invalid compilerOptions field.

exports-loader ends with ts-loader which causes this issue.

This is the line of code: https://github.com/cypress-io/cypress/blame/f000167e8f4cc5cc83bbf1ad18675dd0d37cd73f/npm/webpack-batteries-included-preprocessor/index.js#L25

The following change fixes the issue for me:

-loader.includes('ts-loader')
+loader === 'ts-loader'

Possibly related: #31590

cc @chrisbreiding @AtofStryker


Error: Webpack Compilation Error
Module build failed (from ./node_modules/exports-loader/dist/cjs.js):
ValidationError: Invalid options object. Exports Loader has been initialized using an options object that does not match the API schema.
 - options has an unknown property 'compilerOptions'. These properties are valid:
   object { exports, type? }
    at handle (project/packages/editor/node_modules/@cypress/webpack-preprocessor/dist/index.js:296:23)

Desired behavior

No response

Test code to reproduce

Similar to https://github.com/cypress-io/cypress/blob/develop/system-tests/projects/webpack-preprocessor-webpack-5/cypress.config.js

But with a loader called exports-loader.

Cypress Version

14.5.4

Node version

v22.18.0

Operating System

macOS 15.6

Debug Logs

cypress:webpack ts-loader detected: overriding tsconfig to use sourceMap:true, inlineSourceMap:false, inlineSources:false, downlevelIteration:true +0ms
ValidationError: Invalid options object. Exports Loader has been initialized using an options object that does not match the API schema.
 - options has an unknown property 'compilerOptions'. These properties are valid:
   object { exports, type? } +0ms

Other

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions