Skip to content

Circular dependency when bundling #4329

@falfab

Description

@falfab

Description
I am trying to bundle my library which has Socket.IO as a dependency.
I am using rollup.js as a module bundler.
When bundling it gives me the following error:

(!) Circular dependencies
node_modules/socket.io/dist/socket.js -> node_modules/socket.io/dist/broadcast-operator.js -> node_modules/socket.io/dist/socket.js
node_modules/socket.io/dist/socket.js -> node_modules/socket.io/dist/broadcast-operator.js -> <my_library_path>/node_modules/socket.io/dist/socket.js?commonjs-proxy -> node_modules/socket.io/dist/socket.js

To Reproduce

Socket.IO version: 4.4.1

Currently using this rollup config file:

import resolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import typescript from '@rollup/plugin-typescript'
import dts from 'rollup-plugin-dts'
import postcss from 'rollup-plugin-postcss'
import { terser } from 'rollup-plugin-terser'
import peerDepsExternal from 'rollup-plugin-peer-deps-external'
import json from '@rollup/plugin-json'

const packageJson = require('./package.json')

export default [
  {
    input: 'src/index.ts',
    output: [
      {
        file: packageJson.main,
        format: 'cjs',
        sourcemap: true,
      },
      {
        file: packageJson.module,
        format: 'esm',
        sourcemap: true,
      },
    ],
    plugins: [
      peerDepsExternal(),
      resolve(),
      commonjs(),
      typescript({ tsconfig: './tsconfig.json' }),
      postcss(),
      terser(),
      json({compact: true}),
    ],
  },
  {
    input: 'dist/esm/types/index.d.ts',
    output: [{ file: 'dist/index.d.ts', format: 'esm' }],
    plugins: [dts()],
    external: [/\.(css|less|scss)$/, 'websocket'],
  },
]

The warning message shows when executing:

npx rollup -c

Expected behavior
No warning is shown

Platform:

  • OS: Ubuntu 20.04

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions