Docs on package.json vs project/foo/package.json (and their lockfiles) #43058
Labels
comp: docs
Anything related to doc content, incl guides, API reference, tutorial, web content
docsarea: library-or-schematics
Use only with "comp: docs". Applies to doc about creating and using libraries or schematics.
Milestone


Description
The Creating Library guide is totally absent any information on package.json and dependencies.
Currently the library creation guide advocates creating a workspace for every library.
ng new my-workspace --create-application=false cd my-workspace ng generate library my-libThis will give you two package.json files, and also two lockfiles
my-workspace/package.jsonmy-workspace/projects/my-lib/package.jsonThere is no information differentiating these two.
On StackOverflow there is advice to put in dependencies that people have to have to use your library in the
my-workspace/projects/my-lib/package.jsonunder the projects directory, and to put the dependencies that you need to develop the library in./package.json, but this doesn't explicitly address how you can ever have one and not the other in tested functionality.More succiently, if a user needs a library to run the library in
my-workspace/projects/my-lib/package.jsonwon't the developer also need it inmy-workspace/package.jsonso it can be available tong build, andng test? Do we have to manually keep these in sync? Is there ever a reason to have a dependency inmy-workspace/projects/my-lib/package.jsonbut not inmy-workspace/package.json? Isnpm install --savenot useful for Angular libraries (it only adds to thepackage.jsonin the toot of the repo and leaves the files in packages/ out of sync).My experience with this workspace structure leads me to believe a greater discussion should be had about whether or not this is even good idea. It's very confusing to have reputable tools like
@semantic-release(which seem even semi-official) not even support multiple libraries in one workspace when the cli and docs make this sound like a routine practice. It also feels like the cli should be updated to make single-library-per-repo the default, and to restructure this such that there is only ever one package.json and one package in the default configuration.What is the affected URL?
https://angular.io/guide/creating-libraries
The text was updated successfully, but these errors were encountered: