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

Circular dependency when bundling #4329

Closed
falfab opened this issue Apr 1, 2022 · 4 comments
Closed

Circular dependency when bundling #4329

falfab opened this issue Apr 1, 2022 · 4 comments
Labels
bug Something isn't working

Comments

@falfab
Copy link

falfab commented Apr 1, 2022

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
@falfab falfab added the to triage Waiting to be triaged by a member of the team label Apr 1, 2022
@darrachequesne
Copy link
Member

There is indeed a circular dependency between the source files. Let's fix that.

@darrachequesne darrachequesne added bug Something isn't working and removed to triage Waiting to be triaged by a member of the team labels Apr 5, 2022
@steffenraubvogel
Copy link

I am getting the same warning for my application. Is this a problem when running the bundled js with nodejs? I have not seen any a errors in runtime so far.

dzad pushed a commit to dzad/socket.io that referenced this issue May 29, 2023
@b1lly
Copy link

b1lly commented Dec 10, 2023

has this been resolved at all? i'm on 4.7.2 and still see this issue.

vanquisher0411 added a commit to vanquisher0411/socketio_project that referenced this issue Feb 29, 2024
@darrachequesne darrachequesne added this to the socket.io@next milestone Sep 19, 2024
@darrachequesne
Copy link
Member

For future readers:

This should be fixed by 19c48a4, included in socket.io@4.8.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants