kulshekhar / ts-jest

A Jest transformer with source map support that lets you use Jest to test projects written in TypeScript.
https://kulshekhar.github.io/ts-jest
MIT License
6.95k stars 451 forks source link

[Bug]: ts-jest[ts-compiler] (WARN) Unable to process '/node_modules/.pnpm/wouter@3.3.1_react@18.3.1/node_modules/wouter/esm/index.js', falling back to original file content. You can also configure Jest config option `transformIgnorePatterns` to ignore /node_modules/.pnpm/wouter@3.3.1_react@18.3.1/node_modules/wouter/esm/index.js from transformation or make sure that `outDir` in your tsconfig is neither `''` or `'.'` #4575

Open Grsz opened 3 weeks ago

Grsz commented 3 weeks ago

Version

29.2.5

Steps to reproduce

Clone https://github.com/Grsz/ts-jest-repro Run pnpm i Run pnpm test

Expected behavior

It should transform the js file from wouter using import.

Actual behavior

/node_modules/.pnpm/wouter@3.3.1_react@18.3.1/node_modules/wouter/esm/index.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){import { parse } from 'regexparam';
                                                                                      ^^^^^^

    SyntaxError: Cannot use import statement outside a module
ts-jest[ts-compiler] (WARN) Unable to process 'node_modules/.pnpm/wouter@3.3.1_react@18.3.1/node_modules/wouter/esm/index.js', falling back to original file content. You can also configure Jest config option `transformIgnorePatterns` to ignore node_modules/.pnpm/wouter@3.3.1_react@18.3.1/node_modules/wouter/esm/index.js from transformation or make sure that `outDir` in your tsconfig is neither `''` or `'.'`

Debug log

Too long, github doesn't let submit it.

Additional context

No response

Environment

System:
    OS: macOS 14.2.1
    CPU: (10) arm64 Apple M2 Pro
  Binaries:
    Node: 20.16.0 - ~/.nvm/versions/node/v20.16.0/bin/node
    Yarn: 1.22.22 - ~/.nvm/versions/node/v20.16.0/bin/yarn
    npm: 10.8.1 - ~/.nvm/versions/node/v20.16.0/bin/npm
    pnpm: 9.6.0 - ~/Library/pnpm/pnpm
  npmPackages:
    jest: 29.7.0 => 29.7.0
jklepek-vendavo commented 3 weeks ago

I have the same problem, since updating to 29.2.5 running tests with jest fails on: /node_modules/react-dnd/dist/index.js:2 export * from './core/index.js'; ^^^^^^

SyntaxError: Unexpected token 'export'