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

chore(shared): Eliminate circular dependencies #6743

Open
wants to merge 3 commits into
base: next
Choose a base branch
from

Conversation

SokratisVidros
Copy link
Contributor

@SokratisVidros SokratisVidros commented Oct 22, 2024

What changed? Why was the change needed?

Cause, why not ❓

@novu/shared doesn't have strict conventions regarding its folder structure. As a result, types import entities, dtos import types or entities, and so on. This resulted in a very large number of TS circular imports, causing unexpected issues and TS headaches.

This PR addresses that with the help of madge. 🙌

Consider it, as a first step towards a more structured, treeshakable @novu/shared, that contains meaningful share utility functions and types.

Copy link

netlify bot commented Oct 22, 2024

Deploy Preview for novu-stg-vite-dashboard-poc failed. Why did it fail? →

Name Link
🔨 Latest commit dd3b321
🔍 Latest deploy log https://app.netlify.com/sites/novu-stg-vite-dashboard-poc/deploys/671bf63ae8a3310008b6442c

@@ -1,4 +1,4 @@
import { PreferencesResponseDto, StepResponseDto, WorkflowCommonsFields } from './workflow-commons-fields';
import { PreferencesResponseDto, StepResponseDto, WorkflowCommonsFields } from './workflow-response.dto';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tatarco I think we made the exact parallel change in two PRs. Let's chat tomorrow to see how can we merge, the workflow-response.dtoor workflow-response-dto.

@@ -26,11 +26,12 @@
"format:fix": "prettier --write --ignore-path .gitignore .",
"build": "tsup && pnpm check:circulars",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should remove the addition invocation of check:circulars in build now that we have postbuild

Suggested change
"build": "tsup && pnpm check:circulars",
"build": "tsup",

Copy link
Contributor

@rifont rifont left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹💅🚀 awesome!

Copy link

pkg-pr-new bot commented Oct 23, 2024

Open in Stackblitz

@novu/client

pnpm add https://pkg.pr.new/novuhq/novu/@novu/client@6743

@novu/framework

pnpm add https://pkg.pr.new/novuhq/novu/@novu/framework@6743

@novu/headless

pnpm add https://pkg.pr.new/novuhq/novu/@novu/headless@6743

@novu/js

pnpm add https://pkg.pr.new/novuhq/novu/@novu/js@6743

@novu/nest

pnpm add https://pkg.pr.new/novuhq/novu/@novu/nest@6743

@novu/nextjs

pnpm add https://pkg.pr.new/novuhq/novu/@novu/nextjs@6743

@novu/node

pnpm add https://pkg.pr.new/novuhq/novu/@novu/node@6743

@novu/notification-center

pnpm add https://pkg.pr.new/novuhq/novu/@novu/notification-center@6743

novu

pnpm add https://pkg.pr.new/novuhq/novu@6743

@novu/providers

pnpm add https://pkg.pr.new/novuhq/novu/@novu/providers@6743

@novu/react

pnpm add https://pkg.pr.new/novuhq/novu/@novu/react@6743

@novu/react-native

pnpm add https://pkg.pr.new/novuhq/novu/@novu/react-native@6743

@novu/shared

pnpm add https://pkg.pr.new/novuhq/novu/@novu/shared@6743

@novu/stateless

pnpm add https://pkg.pr.new/novuhq/novu/@novu/stateless@6743

commit: c205d5a

The rule is: Entities depend on DTOs and Types. DTOs depend on Types

Based on that all circular type dependencies under /types are resolved.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants