确定控制台中循环依赖警告的来源

Determine where circular dependency warning in console is coming from

当我构建我的 React/TypeScript 组件库时,Rollup 构建报告循环依赖:

yarn run v1.22.10
$ yarn clean && rollup -c
$ rimraf dist

./src/index.ts → ./dist/index.esm.js, ./dist/index.js...
(!) Circular dependency
src/index.ts -> src/components/index.ts -> src/components/Compound/index.ts -> src/components/Compound/Compound.tsx -> src/index.ts
created ./dist/index.esm.js, ./dist/index.js in 4.3s
Done in 5.66s.

我正在尝试弄清楚警告来自哪里。打字稿?卷起? 在我知道这一点之后,我可能能够配置它,因此它实际上会失败构建。

我已经搜索并搜索了我的 node_modules,但似乎无法找到警告的来源。

rollup.config.js:

import typescript from 'rollup-plugin-typescript2';
import postcss from 'rollup-plugin-postcss';
import pkg from './package.json';
import ts from 'typescript';

export default {
  input: './src/index.ts',
  external: [...Object.keys(pkg.dependencies || {}), ...Object.keys(pkg.peerDependencies || {})],
  output: [
    {
      file: `./dist/${pkg.module}`,
      format: 'es',
      sourcemap: true,
    },
    {
      file: `./dist/${pkg.main}`,
      format: 'cjs',
      sourcemap: true,
    },
  ],
  plugins: [
    postcss(),
    typescript({
      typescript: ts,
      tsconfig: 'tsconfig.json',
      tsconfigDefaults: {
        exclude: [
          '**/*.spec.ts',
          '**/*.test.ts',
          '**/*.stories.ts',
          '**/*.spec.tsx',
          '**/*.test.tsx',
          '**/*.stories.tsx',
          'node_modules',
          'bower_components',
          'jspm_packages',
          'dist',
        ],
        compilerOptions: {
          sourceMap: true,
          declaration: true,
        },
      },
    }),
  ],
};

tsconfig.json:

{
  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "declaration": true,
    "esModuleInterop": true,
    "experimentalDecorators": true,
    "jsx": "react",
    "lib": ["dom", "es5"],
    "module": "esNext",
    "moduleResolution": "node",
    "noImplicitAny": false,
    "noImplicitReturns": true,
    "noUnusedLocals": true,
    "noUnusedParameters": false,
    "outDir": "./dist",
    "pretty": true,
    "sourceMap": true,
    "strict": true,
    "target": "es5"
  },
  "exclude": ["node_modules",],
  "include": ["./src"]
}

所以,我的问题不是如何修复报告的循环依赖,而是控制台输出中的循环依赖警告来自哪里?

Node v14.18.2、TypeScript 3.9.10、React 16.14.0、Rollup 2.70.0

最终在 Rollup 代码中找到了警告 here 的来源。

找不到它是因为我没有考虑到他们会处理“依赖”与“依赖”的措辞刘海撞墙