Skip to content

Misguiding document on authoring libraries #6896

Open
@ziofat

Description

@ziofat

In the document Authoring libraries, it's mentioned to install lodash as a devDependency, since we don't want to bundle it together. Also, it's suggested to list it as a peerDependency and put it in the external option. I believe this is a misguidance.

Firstly, if lodash is used within a library, there would be require('lodash') or import from 'lodash' statements, which clearly indicate a direct dependency. Therefore, it should be listed in dependencies.

If users use a bundler to package their own applications, once your library is installed, lodash will also be installed and can be deduplicated with the lodash versions depended on by other libraries used by users. In this case, all you need to do is put ALL dependencies into the external option.

If users are importing your library through a script tag, bundling utility libraries like lodash isn't necessarily a bad practice.

Regardless, lodash should never be listed as a peerDependency or a devDependency.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions