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

Document how to incorporate in a plugin #34

Open
danyill opened this issue Jun 27, 2023 · 3 comments
Open

Document how to incorporate in a plugin #34

danyill opened this issue Jun 27, 2023 · 3 comments
Labels
documentation Improvements or additions to documentation

Comments

@danyill
Copy link
Collaborator

danyill commented Jun 27, 2023

It's not altogether obvious how to incorporate this in a plugin, partly because we use import.meta.url to fetch the nsd JSON file. If this is not handled correctly, it causes a load error.

So in an open-scd-core plugin which uses this library, it is important that these statement are correctly translated so that the paths are correct.

If using rollup, the plugin, "Import Meta Assets" does this very easily and is likely useful for other reasons as well.

https://modern-web.dev/docs/building/rollup-plugin-import-meta-assets/

I've incorporated this into my oscd-subscriber-later-binding plugin in the following commit: danyill/oscd-subscriber-later-binding@f101019

We should document what is required for new users of this library.

@danyill danyill added the documentation Improvements or additions to documentation label Jun 27, 2023
@trusz
Copy link

trusz commented Jul 8, 2023

I feel like a library like this should not really load files itself.
I assume we talk about this spot:

new URL("../foundation/nsd.json", import.meta.url)

The client should be able to decide when and how it loads these files.

@danyill
Copy link
Collaborator Author

danyill commented Jul 17, 2023

The client should be able to decide when and how it loads these files.

Shouldn't the client just use the functions? If a file is required to use this library, I'd normally be happy to bundle it into my dependencies and tree-shake it as required... ⁉️

@trusz
Copy link

trusz commented Jul 17, 2023

The problem is that you are making assumptions of the client's capabilities.
Usually it falls to the client to orchestrate its libraries. Which one does what, and when.
I usually do not like if libraries do something without me knowing it or having the ability to control it.

I think libraries should be configured and framework should work with conventions.

I would do something along these lines:

const nsd1 = await fetch(nsd1URL)
const nsd2 = await loadFromDB(nsd2URL)
const scl = new SCL(document, [nsd1,nsd2])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants