Skip to content

Webpack Compilation Error when upgrading @jscutlery/cypress-harness to 0.8.10 #1004

Description

@hassamahmed

After upgrading to @jscutlery/cypress-harness v0.8.10, Webpack 5 fails to compile ESM modules due to missing .js extensions in internal imports.

Module not found: Error: Can't resolve './lib/get-root-harness' in '/agent/_work/1/s/Source/Client/node_modules/@jscutlery/cypress-harness/src'
Did you mean 'get-root-harness.js'?
BREAKING CHANGE: The request './lib/get-root-harness' failed to resolve only because it was resolved as fully specified
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
    at handle (/agent/_work/1/s/Source/Client/node_modules/@cypress/webpack-preprocessor/dist/index.js:296:23)
    at finalCallback (/agent/_work/1/s/Source/Client/node_modules/webpack/lib/Compiler.js:519:32)
    at /agent/_work/1/s/Source/Client/node_modules/webpack/lib/Compiler.js:597:17
    at /agent/_work/1/s/Source/Client/node_modules/webpack/lib/HookWebpackError.js:96:2
    at Hook.eval [as callAsync] (eval at create (/agent/_work/1/s/Source/Client/node_modules/tapable/lib/HookCodeFactory.js:31:10), <anonymous>:6:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/agent/_work/1/s/Source/Client/node_modules/tapable/lib/Hook.js:21:14)
    at Cache.storeBuildDependencies (/agent/_work/1/s/Source/Client/node_modules/webpack/lib/Cache.js:129:37)
    at /agent/_work/1/s/Source/Client/node_modules/webpack/lib/Compiler.js:593:19
    at Hook.eval [as callAsync] (eval at create (/agent/_work/1/s/Source/Client/node_modules/tapable/lib/HookCodeFactory.js:31:10), <anonymous>:6:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/agent/_work/1/s/Source/Client/node_modules/tapable/lib/Hook.js:21:14)
    at /agent/_work/1/s/Source/Client/node_modules/webpack/lib/Compiler.js:589:23
    at Compiler.emitRecords (/agent/_work/1/s/Source/Client/node_modules/webpack/lib/Compiler.js:1067:4)
    at /agent/_work/1/s/Source/Client/node_modules/webpack/lib/Compiler.js:579:11
    at /agent/_work/1/s/Source/Client/node_modules/webpack/lib/Compiler.js:1030:14
    at Hook.eval [as callAsync] (eval at create (/agent/_work/1/s/Source/Client/node_modules/tapable/lib/HookCodeFactory.js:31:10), <anonymous>:6:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/agent/_work/1/s/Source/Client/node_modules/tapable/lib/Hook.js:21:14)
    at /agent/_work/1/s/Source/Client/node_modules/webpack/lib/Compiler.js:1027:27
    at /agent/_work/1/s/Source/Client/node_modules/neo-async/async.js:2818:7
    at done (/agent/_work/1/s/Source/Client/node_modules/neo-async/async.js:3522:9)
    at Hook.eval [as callAsync] (eval at create (/agent/_work/1/s/Source/Client/node_modules/tapable/lib/HookCodeFactory.js:31:10), <anonymous>:6:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/agent/_work/1/s/Source/Client/node_modules/tapable/lib/Hook.js:21:14)
    at /agent/_work/1/s/Source/Client/node_modules/webpack/lib/Compiler.js:856:33
    at /agent/_work/1/s/Source/Client/node_modules/graceful-fs/graceful-fs.js:143:16
    at /home/AzDevOps/.cache/Cypress/14.5.2/Cypress/resources/app/node_modules/@packages/server/node_modules/graceful-fs/graceful-fs.js:143:16
    at /home/AzDevOps/.cache/Cypress/14.5.2/Cypress/resources/app/node_modules/@packages/server/node_modules/graceful-fs/graceful-fs.js:143:16
    at /home/AzDevOps/.cache/Cypress/14.5.2/Cypress/resources/app/node_modules/@packages/server/node_modules/graceful-fs/graceful-fs.js:61:14
    at FSReqCallback.oncomplete (node:fs:186:23)

This occurred while Cypress was compiling and bundling your test code. This is usually caused by:

- A missing file or dependency
- A syntax error in the file or one of its dependencies

Fix the error in your code and re-run your tests.

Workarounds Tried:

  • Setting resolve.fullySpecified = false (Angular CLI ignores custom webpack settings)
  • Setting loader override:
    { test: /@jscutlery\/cypress-harness\/.*\.js$/, type: "javascript/auto" }

Resolution:

  • Downgraded @jscutlery/cypress-harness to 0.7.0

Cypress Version
14.5.4

Node version
22.22.1

Metadata

Metadata

Assignees

No one assigned

    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