Support scoped packages?
See original GitHub issuecosmiconfig requires a moduleName
: https://github.com/davidtheclark/cosmiconfig#modulename
Some NPM packages are scoped, so the name field of package.json will be in the format @foo/bar
. The latest version of cosmiconfig doesnāt seem to support using the actual name of a scoped package as the moduleName. Hereās what happened when I tried:
- Adding a
"@foo/bar"
config section to package.json worked successfully - Canāt add a
.@foo/barrc
file, since slashes are not allowed in filenames. Creating a folder.@foo
with abarrc
file inside doesnāt seem to be picked up by cosmiconfig
Typescript had a similar issue with scoped packages, since type definitions for package foo
were published under @types/foo
. If the package being typed is scoped, there was no valid way to publish a type definition package for it (@types/@foo/bar
is invalid, both because it has two @ signs and because it has two slashes), so they translate @foo/bar
to foo__bar
, publishing the types under @types/foo__bar
in this example. Cosmiconfig could follow Typescriptās example here - if the moduleName
is scoped, it could search for package.jsonās "foo__bar"
, .foo__barrc
, .foo__barrc.json
, etcā¦
Alternatively, since cosmiconfig doesnāt actually check that moduleName
matches package.jsonās name field exactly, cosmiconfig could make no code changes and just add some documentation in README.md about the limitations of moduleName
and suggest a standard way of converting scoped module names to cosmiconfig-compatible module names.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (4 by maintainers)
Top GitHub Comments
Sorry - I meant I liked
I agree that documentation about this makes sense š