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(tasks, comments): core plugins #6333

Merged
merged 12 commits into from
Apr 17, 2024
Merged

Conversation

ricokahler
Copy link
Contributor

@ricokahler ricokahler commented Apr 11, 2024

Description

The following PR:

  • Moves Tasks and Comments into core to and makes them default/core plugins that are added to every sanity config.
  • Decouples Tasks and Comments from structure. This was done to preserve the seperation of core and structure. Since Tasks and Comments are now part of core, if this decoupling was not done, then much the structure tool would get imported due to the default plugins of tasks and comments.
  • Removes the sanity/_internalBrowser entry point. The reasoning for this is that we already export a lot of internal code via the main export and it seems like we should either move all internals to that entry point or just remove it completely. The decision was to remove it since that's the easiest option that prevents the least amount of breakage.

Some important notes:

Regarding default plugins

When testing this, I ran into a new bug that came as a result from making the tasks() and comments() plugins added by default. Certain context values were not present (<CommentsEnabledProvider/> and <TasksEnabledProvider />) which caused the useCommentsEnabled() and useTasksEnabled() hooks to throw. To prevent this issue, I gave these context values default values that have the contexts set to enabled: false. This is so that if there is no context provider (as in the case of the task's FormBuilder) for these use*Enabled() hooks, the feature will be assumed to be disabled instead of throwing.

Decoupling Comments from structure

Though not ideal, the path I went down for decoupling Comments from structure was to invert the dependnecies and export the CommentProvider from core and import it into structure. From there I was able to provide all the dependencies from structure that comments needed without having to import structure-only dependencies like usePaneRouter and useDocumentPane.

In the future, we'd like to separate the concept of "the document" from structure and offer more document primitives available in core that are separate from structure. For now we may have to deal with structure depending on the CommentsProvider and comments populating it's document needs via useDocumentPane etc.

Decoupling Tasks from structure

Decoupling Tasks from Structure has a similar story to decoupling Comments from Structure. The only dependency Tasks has toward structure is just const {isLast} = usePane() so this was hoisted into a somewhat awkward <IsLastPaneProvider /> . This is also a temporary thing and will be considered for those said primitive document APIs once we get some roadmap time. (cc @rexxars).

Circular imports and barrel files

These are the bane of my existence. While moving these, I tried my best to make them consistent but I'd rather just remove them. They cause a lot of issues and I think we should invest some time in removing them. There were some interesting work arounds I had to do and I really don't have an explanation for why some of them work.

Some of the circular imports cause issues with the monorepo dev command, some of them cause issues with random jest tests, and others cause issues with vite in dev mode. The build is typically fine and rollup (as part of vite) usually knows how to deal with them but doesn't mean the rest of our tooling does 😅.

What to review

  • Is everything in the right place?
  • Are all tests passing?
  • Did I rebase correctly?
  • Do the new providers and their new locations make sense?

Testing

Tested manually and made sure all almost all CI passed and reviewed much of this large PR myself but definitely could use a lot of eyes on this one.

Notes for release

N/A

Copy link

vercel bot commented Apr 11, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
performance-studio ✅ Ready (Inspect) Visit Preview Apr 17, 2024 6:17pm
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 17, 2024 6:17pm
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Visit Preview Apr 17, 2024 6:17pm

Copy link
Contributor

No changes to documentation

Copy link
Contributor

github-actions bot commented Apr 11, 2024

Component Testing Report Updated Apr 17, 2024 6:23 PM (UTC)

File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 36s 15 0 0
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 6s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ✅ Passed (Inspect) 26s 6 0 0
formBuilder/inputs/PortableText/copyPaste/CopyPaste.spec.tsx ✅ Passed (Inspect) 13s 4 2 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 13s 6 0 0
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 34s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 1m 3s 14 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 1m 1s 18 0 0
formBuilder/inputs/PortableText/RangeDecoration.spec.tsx ✅ Passed (Inspect) 13s 6 0 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 14s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ✅ Passed (Inspect) 21s 9 0 0

Copy link

socket-security bot commented Apr 17, 2024

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@babel/[email protected] environment, filesystem, unsafe +34 4.56 MB nicolo-ribaudo
npm/@babel/[email protected] None +6 893 kB nicolo-ribaudo
npm/@babel/[email protected] Transitive: environment +19 2.85 MB nicolo-ribaudo
npm/@babel/[email protected] environment +3 2.5 MB nicolo-ribaudo
npm/@types/[email protected] None +1 9.65 kB types
npm/[email protected] environment, filesystem +13 358 kB paulmillr
npm/[email protected] environment, filesystem 0 79.1 kB motdotla
npm/[email protected] environment, filesystem, network, shell 0 135 kB evanw
npm/[email protected] None 0 20.8 kB lydell
npm/[email protected] Transitive: environment, filesystem, unsafe +26 1.03 MB jounqin
npm/[email protected] environment 0 118 kB gnoff
npm/[email protected] filesystem Transitive: environment, eval +106 6 MB ljharb
npm/[email protected] Transitive: eval, filesystem +14 4.56 MB odspnpm
npm/[email protected] environment, filesystem Transitive: eval, shell, unsafe +74 9.87 MB eslintbot
npm/[email protected] environment, filesystem, shell 0 3.61 kB typicode
npm/[email protected] filesystem Transitive: environment +3 25.6 kB sindresorhus
npm/[email protected] Transitive: environment +23 478 kB sindresorhus
npm/[email protected] None +1 13.3 kB sindresorhus
npm/[email protected] None 0 21 kB sindresorhus
npm/[email protected] Transitive: environment, eval, filesystem +28 1.17 MB zkochan
npm/[email protected] None +1 15.6 kB sindresorhus
npm/[email protected] environment +3 4.62 MB gnoff
npm/[email protected] environment +2 337 kB gnoff
npm/[email protected] None +1 4.59 MB blesh
npm/[email protected] environment, filesystem +7 355 kB isaacs
npm/[email protected] None 0 30.6 kB turbobot
npm/[email protected] environment, filesystem +15 635 kB oss-bot

🚮 Removed packages: npm/@juggle/[email protected], npm/[email protected], npm/[email protected], npm/[email protected]

View full report↗︎

@ricokahler ricokahler added this pull request to the merge queue Apr 17, 2024
Merged via the queue into next with commit 3c917d2 Apr 17, 2024
37 checks passed
@ricokahler ricokahler deleted the refactor/core-plugins branch April 17, 2024 18:48
jordanl17 pushed a commit that referenced this pull request Apr 19, 2024
* refactor: load comments + tasks as default plugins

* refactor(tasks): flatten folder structure

* refactor(comments): flatten folder structure, move out of structure

* refactor(comments): hoist inspector constant out of structure

* refactor(tasks, comments): move into core

* refactor: re-export comments from structure for backwards compatibility

* refactor: fix build issues due to circular imports

* refactor(core): consistent barrel exports

* refactor(core): remove _internalBrowser

* refactor(comments): hoist provider and decouple from structure

* refactor(tasks): decouple from structure via IsLastPaneContext

* test(e2e): fix e2e build by reverting relative imports

---------

Co-authored-by: Espen Hovlandsdal <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants