question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if youā€™re still stuck at the end, weā€™re happy to hop on a call to see how we can help out.

Support scoped packages?

See original GitHub issue

cosmiconfig 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 a barrc 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:closed
  • Created 5 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
olsonpmcommented, Jan 23, 2019

Sorry - I meant I liked

moduleName should only contain characters that are allowed in a file name.

0reactions
davidtheclarkcommented, Jan 26, 2019

I agree that documentation about this makes sense šŸ‘

Read more comments on GitHub >

github_iconTop Results From Across the Web

scope
Scoped packages can be published and installed as of npm@2 and are supported by the primary npm registry. Unscoped packages can depend on...
Read more >
npm-scope - Scoped packages
Scoped packages are supported by the public npm registry. The npm client is backwards-compatible with un-scoped registries, so it can be used to...
Read more >
Scoped registries
Scoped registries allow Unity to communicate the location of any custom package registry server to the Package Manager so that the user has...
Read more >
npm-scope
You can publish and install some scoped packages as of npm@2 and these are supported by the npm registry. An unscoped package can...
Read more >
"scoped" packages Ā· Issue #5239 Ā· npm/npm
We can then also scope auth info to each registry, and voila, we have multiple registry support that works, doesn't conflict with anythingĀ ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found