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

Warning: Accessing non-existent property 'tracing' of module exports inside circular dependency" when using ttypescript as compiler for ts-jest #141

Open
IsaacMcIntyre opened this issue Feb 14, 2023 · 2 comments

Comments

@IsaacMcIntyre
Copy link

Apologies if this repo is not the right place to post, I wasn't quite sure to post this under ttypescript, or to have it under ts-jest.

I have an issue in where I am seeing many warnings upon running my jest unit tests for my Vue3 project only when ttypescript has been setup as the compiler for ts-jest.
"^.+\\.ts$": ["ts-jest", { compiler: "ttypescript" }],

However, when ttypescript as compiler is removed from jest.config.js (which defaults to typescript instead), the tests mention no warnings. However, in my project I am having to use ts-auto-mock, which requires ttypescript to be used as the ts-jest compiler see here. I have also noticed this only seems to be happening on first run, unless jest cache is disabled.

I have created a barebones Vue3 project with ttypescript setup as ts-jest compiler here to demonstrate the warnings.

While looking into this, I also stumbled onto this discussion which seemed to point the same issue at ttypescript #Swatinem/rollup-plugin-dts#206.

The warning with stacktrace is as follows:

(node:22331) Warning: Accessing non-existent property 'tracing' of module exports inside circular dependency
at emitCircularRequireWarning (node:internal/modules/cjs/loader:719:11)
at Object.get (node:internal/modules/cjs/loader:735:5)
at Object.emit (/Users/isaac.mcintyre/Documents/ttypescript-error-proof/node_modules/typescript/lib/typescript.js:117510:39)
at Object.transpileModule (/Users/isaac.mcintyre/Documents/ttypescript-error-proof/node_modules/typescript/lib/typescript.js:145681:17)
at Object.process (/Users/isaac.mcintyre/Documents/ttypescript-error-proof/node_modules/@vue/vue3-jest/lib/transformers/typescript.js:17:28)
at processScriptSetup (/Users/isaac.mcintyre/Documents/ttypescript-error-proof/node_modules/@vue/vue3-jest/lib/process.js:68:30)
at Object.module.exports [as process] (/Users/isaac.mcintyre/Documents/ttypescript-error-proof/node_modules/@vue/vue3-jest/lib/process.js:168:29)
at ScriptTransformer.transformSource (/Users/isaac.mcintyre/Documents/ttypescript-error-proof/node_modules/@jest/transform/build/ScriptTransformer.js:542:31)
at ScriptTransformer._transformAndBuildScript (/Users/isaac.mcintyre/Documents/ttypescript-error-proof/node_modules/@jest/transform/build/ScriptTransformer.js:671:40)
at ScriptTransformer.transform (/Users/isaac.mcintyre/Documents/ttypescript-error-proof/node_modules/@jest/transform/build/ScriptTransformer.js:723:19)
at Runtime.transformFile (/Users/isaac.mcintyre/Documents/ttypescript-error-proof/node_modules/jest-runtime/build/index.js:1565:53)
at Runtime._execModule (/Users/isaac.mcintyre/Documents/ttypescript-error-proof/node_modules/jest-runtime/build/index.js:1497:34)
at Runtime._loadModule (/Users/isaac.mcintyre/Documents/ttypescript-error-proof/node_modules/jest-runtime/build/index.js:1122:12)
at Runtime.requireModule (/Users/isaac.mcintyre/Documents/ttypescript-error-proof/node_modules/jest-runtime/build/index.js:982:12)
at Runtime.requireModuleOrMock (/Users/isaac.mcintyre/Documents/ttypescript-error-proof/node_modules/jest-runtime/build/index.js:1148:21)
at Object. (/Users/isaac.mcintyre/Documents/ttypescript-error-proof/src/components/HelloWorld.test.ts:3:1)
at Runtime._execModule (/Users/isaac.mcintyre/Documents/ttypescript-error-proof/node_modules/jest-runtime/build/index.js:1539:24)
at Runtime._loadModule (/Users/isaac.mcintyre/Documents/ttypescript-error-proof/node_modules/jest-runtime/build/index.js:1122:12)
at Runtime.requireModule (/Users/isaac.mcintyre/Documents/ttypescript-error-proof/node_modules/jest-runtime/build/index.js:982:12)
at jestAdapter (/Users/isaac.mcintyre/Documents/ttypescript-error-proof/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:77:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at runTestInternal (/Users/isaac.mcintyre/Documents/ttypescript-error-proof/node_modules/jest-runner/build/runTest.js:367:16)
at runTest (/Users/isaac.mcintyre/Documents/ttypescript-error-proof/node_modules/jest-runner/build/runTest.js:444:34)
PASS src/components/HelloWorld.test.ts
HelloWorld component
✓ renders (13 ms)

Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 2.348 s

Notes:

  • Jest cache needs to be cleared
@malinkie
Copy link

I get this on ttsc --watch with a generic custom transformer plugin

import * as ts from 'typescript';

export default function transformer() {
    return (_: ts.TransformationContext) => {
        return (source: ts.SourceFile) => {
            return source
        };
    };
}

@malinkie
Copy link

malinkie commented Feb 14, 2023

Also added a barebones repo that can reproduce the issue:

https://github.com/malinkie/circular-dep

If you change the transformer to javascript rather than typescript. it works with no errors

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

No branches or pull requests

2 participants