Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: ts-jest[ts-compiler] (WARN) Unable to process '/node_modules/.pnpm/[email protected][email protected]/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/[email protected][email protected]/node_modules/wouter/esm/index.js from transformation or make sure that outDir in your tsconfig is neither '' or '.' #4575

Open
Grsz opened this issue Oct 6, 2024 · 4 comments

Comments

@Grsz
Copy link

Grsz commented Oct 6, 2024

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/[email protected][email protected]/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/[email protected][email protected]/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/[email protected][email protected]/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
Copy link

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'

@thlmenezes
Copy link

This issue seems related to #4561

Are you using typescript version 5.6?

cc: @jklepek-vendavo @Grsz

@jklepek-vendavo
Copy link

Yes, I am using version 5.6.2. But I solved the issue by migrating from jest to vitest.

@noudadrichem
Copy link

+1 on this issue with TS 5.6.3 initialising ts-jest using the command: npx ts-jest config:init

This is my tsconfig:

{
    "compilerOptions": {
        "esModuleInterop": true,
        "skipLibCheck": true,
        "target": "es2022",
        "allowJs": true,
        "resolveJsonModule": true,
        "moduleDetection": "force",
        "isolatedModules": true,
        "strict": true,
        "noUncheckedIndexedAccess": true,
        "moduleResolution": "NodeNext",
        "module": "NodeNext",
        "outDir": "dist",
        "sourceMap": true,
        "lib": ["es2022"]
    },
    "exclude": ["node_modules", "dist"]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants