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

refactor(notifications): cleanup notification subpath exports #4650

Merged
merged 2 commits into from
Sep 3, 2024

Conversation

Prithpal-Sooriya
Copy link
Contributor

@Prithpal-Sooriya Prithpal-Sooriya commented Sep 3, 2024

Explanation

This cleans up the notification team packages subpath exports (@metamask/profile-sync-controller & @metamask/notification-services-controller).

Packages will now only export:

  • Main/root (where there is a barrel file containing all files)
  • /mocks for accessing mock data (also available as a named export in root)
  • /ui for some UI/framework files for specific platforms (web vs mobile). This is subject to change (we may have a clearer distinction for platforms, such as a React folder vs ReactNative folder).

We also fix a jest-haste-map silent error that was introduced due to subpath modules.

  • Fix removes the internal subpath package.json names as these are internal only files.
**jest haste map silent error**

This was a silent error (CI still passes)

Screenshot 2024-09-03 at 14 08 44

References

Changelog

@metamask/profile-sync-controller

  • CHANGED: Updated subpath package.json files to be internal only to resolve the jest-haste-map errors.

@metamask/notification-services-controller

  • CHANGED: Updated subpath package.json files to be internal only to resolve the jest-haste-map errors.
  • REMOVED/BREAKING: Removed /types, /processors, /constants subpath exports. These are still accessible through root export.

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've highlighted breaking changes using the "BREAKING" category above as appropriate

Made it so that the critical subpaths are added (mocks and UI), the rest are inside the barrel file.
even thought this does not effect CI and testing, these errors were annoying and were fixed. These subpath package.json files do not require names
@@ -1,6 +1,6 @@
{
"name": "@metamask/notification-services-controller",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Internal subpath exports are using a package.json so this "file path" exists. This is so JS projects are able to resolve the subpath export path (TS projects correctly use the root package.json exports). This pattern was copied from redux-toolkit.

See this comment for more details:
#4604 (comment)

"version": "1.0.0",
"private": true,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added this to explicitly set these internal subpath exports to be private.
This shouldn't cause issues with publishing as these are not specified on root of the workspaces file.

If this does cause issues with publishing, I can revert.

@Prithpal-Sooriya Prithpal-Sooriya marked this pull request as ready for review September 3, 2024 13:17
@Prithpal-Sooriya Prithpal-Sooriya requested a review from a team as a code owner September 3, 2024 13:17
@Prithpal-Sooriya Prithpal-Sooriya added the team-notifications Notification Team changes. https://github.com/orgs/MetaMask/teams/notifications label Sep 3, 2024
Copy link
Contributor

@matteoscurati matteoscurati left a comment

Choose a reason for hiding this comment

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

LGTM

@Prithpal-Sooriya Prithpal-Sooriya merged commit b4d5f3e into main Sep 3, 2024
117 checks passed
@Prithpal-Sooriya Prithpal-Sooriya deleted the refactor-notification-subpath-folders branch September 3, 2024 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-notifications Notification Team changes. https://github.com/orgs/MetaMask/teams/notifications
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants