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

#6690: split up brick registry and runtime dependency cycle #6774

Merged
merged 4 commits into from Oct 31, 2023

Conversation

twschiller
Copy link
Contributor

@twschiller twschiller commented Oct 30, 2023

What does this PR do?

  • Part of Untangle known dependency cycles #6690
  • De-couples the brick registry and the runtime
  • I took two different approaches
    • For UserDefinedBrick, I passed the registry into the constructor
    • For ReducePipeline, I'm using a module-level variable that's initialized by the contentScript/testing framework

Remaining Work

Discussion

  • Introducing a class + constructor for ReducePipeline would be a pain. We'd need to start passing a dependency/registry context around nearly every
  • Because the brick registry is a singleton instance, injecting the dependency into the reducePipeline module seemed like the most straightforward approach
  • Splitting up the cycle does not appear to have an impact on bundle size
  • Introducing injectRegistries in the jest setup required me to adjust a few test's mocks/assumptions

Future Work

Checklist

  • Add tests: N/A
  • New files added to src/tsconfig.strictNullChecks.json (if possible): N/A
  • Designate a primary reviewer: @grahamlangford

@twschiller twschiller self-assigned this Oct 30, 2023
@codecov
Copy link

codecov bot commented Oct 30, 2023

Codecov Report

Attention: 12 lines in your changes are missing coverage. Please review.

Comparison is base (953113c) 70.05% compared to head (10af467) 70.04%.
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6774      +/-   ##
==========================================
- Coverage   70.05%   70.04%   -0.01%     
==========================================
  Files        1188     1188              
  Lines       36936    36954      +18     
  Branches     6937     6939       +2     
==========================================
+ Hits        25875    25884       +9     
- Misses      11061    11070       +9     
Files Coverage Δ
src/bricks/registry.ts 96.77% <100.00%> (-0.20%) ⬇️
src/testUtils/loggingMock.ts 100.00% <100.00%> (ø)
src/contentScript/contentScriptCore.ts 0.00% <0.00%> (ø)
src/registry/memoryRegistry.ts 87.09% <71.42%> (-1.04%) ⬇️
src/bricks/transformers/brickFactory.ts 77.31% <75.00%> (+0.38%) ⬆️
src/registry/internal.ts 58.24% <40.00%> (ø)
src/runtime/reducePipeline.ts 84.80% <72.72%> (-0.62%) ⬇️

... and 2 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@fregante
Copy link
Collaborator

Does this also resolve #4896?

@twschiller
Copy link
Contributor Author

twschiller commented Oct 31, 2023

Does this also resolve #4896?

Good point, no it doesn't because the starter bricks are still strongly coupled because of the selectAllBlocks method:

export async function selectAllBlocks(

And also the mergeReaders method:

export async function mergeReaders(

I think the coupling between starter bricks and bricks is less important because IIRC it doesn't introduce a dependency cycle. There's not bricks that reference a starter brick file

@twschiller twschiller changed the title #6690: split up brick registry cycle #6690: split up brick registry and runtime dependency cycle Oct 31, 2023
@github-actions
Copy link

No loom links were found in the first post. Please add one there if you'd like to it to appear on Slack.

Do not edit this comment manually.

@twschiller twschiller merged commit 35fb6a5 into main Oct 31, 2023
14 checks passed
@twschiller twschiller deleted the feature/6690-registry-cycle branch October 31, 2023 01:09
@grahamlangford grahamlangford added this to the 1.8.2 milestone Oct 31, 2023
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.

None yet

3 participants