Skip to content

This is a demo project to show what happens when you have circular dependencies in your project and how to fix them.

Notifications You must be signed in to change notification settings

Maxim-Mazurok/vite-circular-dependency-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vite Circular Dependency Demo

This is a demo project to show what happens when you have circular dependencies in your project and how to fix them.

Getting Started

  1. Clone the repository: git clone https://github.com/Maxim-Mazurok/vite-circular-dependency-demo
  2. cd vite-circular-dependency-demo
  3. (optional) Use appropriate Node.js version: nvm i
  4. Install dependencies: npm ci
  5. Run the tests: npm test

Notes

The idea is pretty simple: you have router, and component. Router imports component (to render it), and component imports router (to get own page URL). This creates a circular dependency.

Check comments in these files for details:

And compare them with the fixed versions:

Another approach is to just extract constants into separate file to avoid circular dependencies.

This can be helpful to detect and fix circular dependencies in your project: https://www.npmjs.com/package/vite-plugin-circular-dependency

About

This is a demo project to show what happens when you have circular dependencies in your project and how to fix them.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published