Closed Bauke closed 1 year ago
Yeah, this is a limitation of cosmiconfig. I'm gonna switch to rc
or run-con
, mainly because it will merge all the config files up to your home directory, which is useful for specifying browser binaries and other defaults for all your projects.
But that will "fix" this by not allowing JS config files at all.
What's your use case?
Edit: I don't like that rc and run-config don't support file extensions, so I might roll my own config loader. It will only support JSON and YML. Maybe I'll try and support JS files, but we'll see.
So before v2 I used webExtConfig
to do browser-specific config based on an environment variable. As webExtConfig
is no longer available in v2 I figured I could just copy and paste the code over to web-ext-config.js
, only to be met with the error above.
I did figure out a different way of doing it though: generate the configuration inside Vite's config (same as v1) and then write it to .web-extrc.json
.
In any case, I've worked out how to migrate everything once v2 releases and I'm looking forward to it.
Sorry I never responded, I'll add the inline config option back. Like you pointed out, sometimes it make sense to commit some config.
Instead of a DIY solution, nuxt uses c12
, and that loads cjs, esm, json, rc files, etc. Seems like that's a good tool that could solve all these issues.
This should be fixed by https://github.com/aklinker1/vite-plugin-web-extension/pull/44/commits/f613684ea46033526c185b883813f46cc504126b. I added back the webExtConfig
option and I added config file support for only YAML and JSON.
I wasn't able to get cosmiconfig
, config
, nor c12
to work exactly how I wanted, so I rolled my own. It's not perfect, but it works exactly how I want it to. I'll need more feedback from people to decide where to go from here.
V2 is almost ready to be released. I published RC1, and I'm about to publish RC2.
This is no longer an issue with v2 or v3, I ended up rolling my own config, and adding the webExtConfig
option back.
Was playing around a bit with v2 and while migrating the web-ext config to
web-ext-config.js
, I found that Cosmiconfig can't load ES modules: