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

Summaries: Why is a component's 'pkg' serialized as an array? #2250

Closed
DLehenbauer opened this issue May 20, 2020 · 5 comments
Closed

Summaries: Why is a component's 'pkg' serialized as an array? #2250

DLehenbauer opened this issue May 20, 2020 · 5 comments
Labels
area: runtime Runtime related issues question Further information is requested resolution: by design

Comments

@DLehenbauer
Copy link
Contributor

DLehenbauer commented May 20, 2020

While helping the Sharepoint team parse summaries, I noticed the following oddity:

In a Fluid summary file:

  • There is a 'foo/.component' entry for each component in the tree.
  • The 'foo/.component' entry contains the SHA hash of a blob.
  • The blob contains the pkg & version for the component.

A typical blob looks like this:

{
  "pkg": "[\"@ms/scriptor\"]",
  "snapshotFormatVersion": "0.1"
}

I noted that:

  1. The pkg field has been double-stringified.
  2. The pkg field contains an array instead of a string (i.e.,["@ms/scriptor"] instead of "@ms/scriptor").

I assume both are unintentional?

@DLehenbauer DLehenbauer added question Further information is requested area: runtime Runtime related issues labels May 20, 2020
@ghost ghost added the triage label May 20, 2020
@curtisman
Copy link
Member

#2 is intentional to support scoped registry where a component bring it only component registry to create and not force the "parent" to include it with them.

The entries in the array is basically the path of registries.
Don't know why it is double stringified though @anthony-murphy @jatgarg

@jatgarg
Copy link
Contributor

jatgarg commented May 22, 2020

So IComponentAttributes has pkg of type string:
const componentAttributes: IComponentAttributes = {
pkg: JSON.stringify(pkg),
snapshotFormatVersion: currentSnapshotFormatVersion,
};
and then when we make it a blob we again serialize it. When I implemented it, the pkg was either string or array of string. So it needs to be like it. I don't know about the current state of affairs after @agarwal-navin worked on it. Feels like it is always an array now.

@agarwal-navin
Copy link
Contributor

I did not change the format of pkg in ComponentContext or in IComponentAttributes.

The change that I made exposed this pkg on IComponentContext as packagePath - #1220.

There was this other change I made which changed the pkg type in createComponent from string | string[] to string. But even that one did not change the internal structure of the data - #1188

@danielroney
Copy link
Contributor

@DLehenbauer we want to discourage issues as questions. Is any work falling out of this thread? I am going to remove the "question" tag from the repo.

@ghost
Copy link

ghost commented Sep 7, 2020

Because this issue is marked as "by design" and has not had activity for over 3 days, we're automatically closing it for house-keeping purposes.

@ghost ghost closed this as completed Sep 7, 2020
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: runtime Runtime related issues question Further information is requested resolution: by design
Projects
None yet
Development

No branches or pull requests

5 participants