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

View Parser Plugin Decomposition #413

Merged
merged 2 commits into from
Jul 29, 2024
Merged

Conversation

mrigankmg
Copy link
Contributor

@mrigankmg mrigankmg commented Jul 5, 2024

This PR refactors the view parser so that parseLocalObject does not contain code to parse specific nodes, but rather delegates that functionality to plugins.

resolves #373
resolves #412

Change Type (required)

Indicate the type of change your pull request is:

  • patch
  • minor
  • major

Does your PR have any documentation updates?

  • Updated docs
  • No Update needed
  • Unable to update docs

Version

Published prerelease version: 0.8.0-next.5

Changelog

Release Notes

Update to use TypeScript 5.5 and enable isolatedDeclarations (#431)

Update to use TypeScript 5.5 and enable isolatedDeclarations

bump js rules, use node 20 (#430)

Use Node 20 for builds

JS Package Cleanup (#442)

Fix migration issues in JS packages

Does your PR have any documentation updates?

  • Updated docs
  • No Update needed
  • Unable to update docs

Bazel 6 Migration (#252)

Swaps the repo internals to use bazel@6, rules_js, bazel modules, vitest and tsup for the core + plugin builds


🚀 Enhancement

🐛 Bug Fix

🏠 Internal

📝 Documentation

🔩 Dependency Updates

Authors: 11

@mrigankmg mrigankmg changed the title Refactored a bit View arser-plugin-decomposition Jul 8, 2024
@mrigankmg mrigankmg changed the title View arser-plugin-decomposition View Parser Plugin Decomposition Jul 8, 2024
@mrigankmg mrigankmg force-pushed the view-parser-plugin-decomposition branch 11 times, most recently from 08cb60a to b5b47ae Compare July 17, 2024 16:33
@mrigankmg mrigankmg changed the base branch from bazel-6 to main July 17, 2024 17:19
@mrigankmg mrigankmg changed the base branch from main to bazel-6 July 17, 2024 17:23
@mrigankmg mrigankmg changed the base branch from bazel-6 to main July 17, 2024 17:34
@mrigankmg mrigankmg force-pushed the view-parser-plugin-decomposition branch 4 times, most recently from 67ed64a to b806e58 Compare July 19, 2024 20:04
@mrigankmg mrigankmg marked this pull request as ready for review July 23, 2024 13:50
@mrigankmg mrigankmg requested a review from hborawski July 23, 2024 13:50
@mrigankmg mrigankmg force-pushed the view-parser-plugin-decomposition branch 6 times, most recently from 29767b0 to 0aad1eb Compare July 23, 2024 19:32
@mrigankmg mrigankmg force-pushed the view-parser-plugin-decomposition branch from 0aad1eb to 19bb017 Compare July 23, 2024 20:10
Copy link

codecov bot commented Jul 23, 2024

Codecov Report

Attention: Patch coverage is 96.33508% with 14 lines in your changes missing coverage. Please review.

Project coverage is 91.93%. Comparing base (81061cf) to head (6b54598).

Files Patch % Lines
core/player/src/view/plugins/applicability.ts 92.30% 3 Missing ⚠️
core/player/src/view/plugins/asset.ts 92.85% 3 Missing ⚠️
core/player/src/view/plugins/multi-node.ts 97.26% 2 Missing ⚠️
core/player/src/view/plugins/switch.ts 97.53% 1 Missing and 1 partial ⚠️
core/player/src/view/plugins/template.ts 94.73% 2 Missing ⚠️
plugins/async-node/core/src/index.ts 93.54% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #413      +/-   ##
==========================================
+ Coverage   91.84%   91.93%   +0.08%     
==========================================
  Files         338      340       +2     
  Lines       26831    26826       -5     
  Branches     1941     1942       +1     
==========================================
+ Hits        24644    24663      +19     
+ Misses       2173     2149      -24     
  Partials       14       14              

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

@mrigankmg mrigankmg force-pushed the view-parser-plugin-decomposition branch 4 times, most recently from 8940520 to 3183681 Compare July 24, 2024 14:36
@mrigankmg mrigankmg force-pushed the view-parser-plugin-decomposition branch 2 times, most recently from dd3b0fc to 60535ed Compare July 24, 2024 16:46
@mrigankmg mrigankmg force-pushed the view-parser-plugin-decomposition branch 2 times, most recently from 4c37617 to 96863cd Compare July 24, 2024 21:11
@@ -34,6 +39,7 @@ test("uses the exact same object if nothing changes", () => {
);

new StringResolverPlugin().apply(view);
new AssetPlugin().apply(view);
Copy link
Contributor

Choose a reason for hiding this comment

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

a lot of these tests have these new plugins added in, it's because these (Multinode + Asset) used to come for free with the parser, right?
Is there appetite in consolidating them to some test util to some default plugin setup like DefaultViewPlugin to avoid having to remember which ones you need to apply in every test

Copy link
Contributor Author

@mrigankmg mrigankmg Jul 25, 2024

Choose a reason for hiding this comment

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

Do we need to create a separate test util plugin? Could we not use the DefaultViewPlugin itself?

Copy link
Contributor

Choose a reason for hiding this comment

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

ya that's possibly fine, it's probably registering more plugins than you need for a lot of tests that are very targeted.
Maybe @KetanReddy can chime in here

core/player/src/view/parser/utils.ts Show resolved Hide resolved
@@ -245,21 +248,26 @@ describe("applicability", () => {
});
});

it("determines if nodeType is applicability", () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

i know we removed the determineNodeType hook, but should we still do some similar type checking by indirectly testing private isApplicability(obj: any)?

Copy link
Contributor Author

@mrigankmg mrigankmg Jul 25, 2024

Choose a reason for hiding this comment

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

How would we test a private function?

Copy link
Contributor

Choose a reason for hiding this comment

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

you'd call the hook that calls the private function, then verify the side effects of the private function

Copy link
Contributor

Choose a reason for hiding this comment

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

as discussed in slack, these tests might not be relevant anymore since the result being returned -> isApplicability returned true, as long as we have a test for negative case as well, this is fine

core/player/src/view/plugins/switch.ts Show resolved Hide resolved
plugins/async-node/core/src/index.test.ts Outdated Show resolved Hide resolved
@mrigankmg mrigankmg force-pushed the view-parser-plugin-decomposition branch 2 times, most recently from e8b8f0d to 0508ecf Compare July 25, 2024 17:58
@mrigankmg mrigankmg force-pushed the view-parser-plugin-decomposition branch from 0508ecf to 6b54598 Compare July 26, 2024 14:10
Copy link
Contributor

@hborawski hborawski left a comment

Choose a reason for hiding this comment

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

🚀 This is a huge refactor, glad to see it fitting properly into the plugin architecture!

@mrigankmg mrigankmg merged commit b2d782d into main Jul 29, 2024
11 checks passed
@mrigankmg mrigankmg deleted the view-parser-plugin-decomposition branch July 29, 2024 17:19
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.

Error thrown from applicability when a dataset has null item [Core] View Parser Plugin Decomposition
4 participants