Local context lookup? #82
-
I'm trying to understand some software (solid-calendar-store) that uses components.js, and am reading the components.js documents. I believe I got the basic concepts, but am struggling with some details. What I do not understand and my questionIn the document of components.js, under the section quick start (TypeScript), it creates a local package and then uses a URL on a remote server for it in the context This package is at local filesystem, and therefore the information is not published to a remote server at all. Therefore, the URL should be invalid. However, the document says it works in this way. This makes me very confused. What I understandIt is intuitive if the context document is published on a remote URL, e.g. As I saw from solid-calendar-store, although using some complicated/advanced mechanisms, the I also read #29 #30. But they did not help me eliminate the question. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
When Components.js encounters a context URL such as This local resolution can indeed be done via context overrides in the package.json as you pointed out. However, if you don't define a custom context override, but you add In the initial Components.js version, contexts were always fetched from the URL. But because this slowed down the dependency injection process a lot, we added these local overrides. So if the context is being fetched from the URL instead of the local file system, something is probably going wrong. Does this clarify your question? |
Beta Was this translation helpful? Give feedback.
-
That's a good question!
The version will be determined based on the
Components are JSON-LD representation of your classes and parameters. Contexts just enable the shortening of URLs, so that for example
Components.js will discover packages that expose context files, and only for those, it will use local context lookups instead of remote lookups. |
Beta Was this translation helpful? Give feedback.
When Components.js encounters a context URL such as
https://linkedsoftwaredependencies.org/bundles/npm/my-package/^2.0.0/components/context.jsonld
, it will first try to resolve this context via the installed dependencies within yournode_modules
directory (which can be exposed bymy-package
). Only if it can not resolve this context locally, it will fallback to resolving the context by following the URL.This local resolution can indeed be done via context overrides in the package.json as you pointed out. However, if you don't define a custom context override, but you add
"lsd:module": true
to your package.json, it will by default provide a context override for the context atcomponents/co…