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 #206

Closed
3 tasks done
JobaerAhamed opened this issue Apr 19, 2022 · 6 comments

Comments

@JobaerAhamed
Copy link

Checklist

  • I can reproduce this issue when running this plugin on its own.
    Other plugins, such as node-resolve are known to cause issues.
  • I am running this plugin on .d.ts files generated by TypeScript.
    The plugin can consume .ts and even .js files (with allowJs: true), but this is known to cause issues.
  • This issue is not related to rolling up @types.
    The plugin ignores these by default, unless respectExternal is set. @types can contain hand-crafted code which is known to cause issues.

Code Snipped

Here is a repo to reproduce the issue : https://github.com/JobaerAhamed/dts-issue. It has more info on repo readme
In short, with a config as provided below, it produces warning. If we don't import ttypescript, it does not produce warnings.

versions:

> node -v
v16.14.2
> npm -v
8.5.0
> npx tsc -v
Version 4.6.3
> npx rollup -v
rollup v2.70.2

input file: my-input/index.d.ts'

export interface Something {
    thing: string;
}
/**
 * Just importing the ttypescript.
 * Not using anywhere
 */
import ttypescript from "ttypescript";
import dts from "rollup-plugin-dts";

let config = [{
  input: 'my-input/index.d.ts',
  output: [
    {
      file: 'dist/my-library.d.ts',
      format: "esm",
    },
  ],
  plugins: [
    dts(),
  ],
}];

export default config;

Error Message

> npx rollup -c rollup.config-with-issue.js
loaded rollup.config-with-issue.js with warnings
(!) Unused external imports
default imported from external module "ttypescript" but never used in "rollup.config-with-issue.js"

my-input/index.d.ts → dist/my-library.d.ts...
(node:56289) Warning: Accessing non-existent property 'tracing' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
(node:56289) Warning: Accessing non-existent property 'tracing' of module exports inside circular dependency
(node:56289) Warning: Accessing non-existent property 'tracing' of module exports inside circular dependency
(node:56289) Warning: Accessing non-existent property 'tracing' of module exports inside circular dependency
(node:56289) Warning: Accessing non-existent property 'tracing' of module exports inside circular dependency
(node:56289) Warning: Accessing non-existent property 'tracing' of module exports inside circular dependency
(node:56289) Warning: Accessing non-existent property 'tracing' of module exports inside circular dependency
(node:56289) Warning: Accessing non-existent property 'tracing' of module exports inside circular dependency
(node:56289) Warning: Accessing non-existent property 'tracing' of module exports inside circular dependency
(node:56289) Warning: Accessing non-existent property 'tracing' of module exports inside circular dependency
(node:56289) Warning: Accessing non-existent property 'tracing' of module exports inside circular dependency
(node:56289) Warning: Accessing non-existent property 'tracing' of module exports inside circular dependency
created dist/my-library.d.ts in 38ms

with tracing (1 of many):

(node:56215) Warning: Accessing non-existent property 'tracing' of module exports inside circular dependency
    at emitCircularRequireWarning (node:internal/modules/cjs/loader:707:11)
    at Object.get (node:internal/modules/cjs/loader:721:5)
    at Object.createSourceFile (/<user>/dts-issue/node_modules/typescript/lib/typescript.js:30658:35)
    at parse (/<user>/dts-issue/node_modules/rollup-plugin-dts/dist/rollup-plugin-dts.cjs:1414:35)
    at Object.renderChunk (/<user>/dts-issue/node_modules/rollup-plugin-dts/dist/rollup-plugin-dts.cjs:1491:28)
    at /<user>/dts-issue/node_modules/rollup/dist/shared/rollup.js:22823:37
@JobaerAhamed
Copy link
Author

JobaerAhamed commented Apr 19, 2022

I apologise if the issue is not appropriate. I am using dts with multi entry and its driving me nuts with all the warnings.
Now, I don't understand when I am giving a specific file as input, why would it conflict with ttypescript.

Thank you for looking into this. Let me know If I can help with anything.

@Swatinem
Copy link
Owner

loaded rollup.config-with-issue.js with warnings

I think those warnings come from your rollup config file. Rollup itself uses rollup to load the config file, essentially inlining all import directives. So I think this is rather a problem with ttypescript, and something thats independent from my plugin.

@JobaerAhamed
Copy link
Author

loaded rollup.config-with-issue.js with warnings

I think those warnings come from your rollup config file. Rollup itself uses rollup to load the config file, essentially inlining all import directives. So I think this is rather a problem with ttypescript, and something thats independent from my plugin.

Thank you for the response. I was looking into it and found the the dist file node_modules/rollup-plugin-dts/dist/rollup-plugin-dts.cjs has var ts = require('typescript');

if we have ttypescript imported, and I make it var ts = require('ttypescript'); then there is no warning.

I will look a bit more and may reach out to ttypescript to understand this better. Will close this issue with whatever I find.

@IsaacMcIntyre
Copy link

IsaacMcIntyre commented Feb 14, 2023

Hey @JobaerAhamed, I've just been coming across all the errors that you have been when setting up jest transformer to be compiled with ttypescript. Did you end up finding much from ttypescript? Many thanks!

Apologies unrelated to rollup-plugin

@JobaerAhamed
Copy link
Author

@IsaacMcIntyre Yeah, I was able to resolve it by importing ttypescript after other import. Seems like import order matters here.
Example:

import dts from 'rollup-plugin-dts';
// other imports...
import ttypescript from 'ttypescript';

Let me know if it works for you as well.

@JobaerAhamed
Copy link
Author

importing ttypescript after rollup-plugin-dts solves it. Closing the issue.

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

3 participants