open-wc / custom-elements-manifest

Custom Elements Manifest is a file format that describes custom elements in your project.
https://custom-elements-manifest.open-wc.org/
226 stars 37 forks source link

Option to create own context #228

Closed nnaydenow closed 1 month ago

nnaydenow commented 5 months ago

Currently, you can only use --dev flag to set dev context. Please provide option to set custom defined context like test or anything else.

thepassle commented 1 month ago

Can you elaborate on how exactly you'd like to use this feature and what you're trying to achieve?

nnaydenow commented 1 month ago

Hi @thepassle,

Currently in the browser usage version you can change the context from dev to non dev using the boolean flag. In the cli you can also use the ---dev flag which will change the context. I have my own custom plugin where I have 3 contexts - public (used by users) / internal (with additional information to fulfil automatically generation of our documentation) / dev (using extra logs provided by you and some additional linters added by us that validates the custom element documentation to our case). I want to be able create my own context so I can read and use in the plugins using the context object inside hooks.

thepassle commented 1 month ago

It's still not entirely clear to me what is preventing you from doing that, especially if you're using the analyzer programmatically, you can just pass in your own context: https://github.com/open-wc/custom-elements-manifest/blob/a61e373ffcadd2632119c0f396150da2437d61bd/packages/analyzer/src/create.js#L11C1-L12C1

e.g.:

create({modules, context: {dev: false, foo: 'bar'}});
nnaydenow commented 1 month ago

I'm trying to do this with the cli API. Seems like I need to to a little restructuring and I'll be able to achieve what I'm trying. Thanks!