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 (or document) projects that use lerna

See original GitHub issue

Lerna is awesome and allows us to create reusable components across a suite of angular applications without all the overhead of repository and version management.

It would be great if this generator could be updated to support the patterns supported by lerna, specifically linking at the root package level.

Currently I think this involves either modifications to the root package.json to reference the src or dist folder or the addition of an index.ts in the root folder so that you can link the root folder instead of needing to link either the dist or src folders depending on your use case.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
jdjuancommented, May 10, 2017

Thanks @mattnathan for this research! I never heard of Lerna before, now I am diving into it 💪

Do we need two package.json after all? 🤔 🤔

@jvandemo now that @mattnathan mentions it, do we have a strong reason to have two package.json? Technically we could use just one, it would force our users to install devDependencies even when they just want to use the library (not develop over it), but that wouldn’t be much of a problem since it would still be local. In general terms one package.json is simpler than two. What do you think?

What is each package.json? FYI: @mattnathan

  • root/package.json: Used for development, has the devDependencies needed to develop the library.
  • dist/package.json: Used for publishing. It has the dependencies for production.
  • src/package.json: This is just the package that is copied and pasted to the dist folder
1reaction
mattnathancommented, May 10, 2017

@jvandemo After a few hours trying different combinations of settings for the package.json I was unable to come up with a solution to this that solved the issue without a fairly major workaround.

Effectively Lerna assumes that if it finds a package.json then that is the project and location where publishing/versioning/running/linking should happen. Unfortunately this is incompatible with the way this generator works where these concerns are expected to be run from different locations within the project. My understanding is that

  • publishing- happen from dist/package.json
  • running - happen from the root package.json
  • linking - depending on the compiled vs .ts requirement either src/package.json or dist/package.json
  • versioning - happens in src/package.json
  • app dependencies - not entirely sure where this should be yet

For my case (and because this is the best generator I’ve found for ng libs so far) I’ve configured Lerna to do all operations on the src/package.json (using "packages": ["components/**/src"] in lerna.json) and will have to add tooling to support publishing/etc that is more aware of this generators structure.

If I come up with a better solution that satisfies more of the use-cases than just linking then I’d be happy to write a guide if that’s still something you want me to do.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Lerna: Documentation
Lerna is a fast modern build system for managing and publishing multiple JavaScript/TypeScript packages from the same repository.
Read more >
How To Manage Monorepos With Lerna
Lerna is a tool for managing JavaScript projects with multiple packages. Lerna manages monorepos, which can hold projects containing multiple ...
Read more >
Setting up a monorepo with Lerna for a TypeScript project
Lerna is a popular and widely used tool written in JavaScript for setting and managing multi-package repositories for Node.js projects with npm ...
Read more >
JavaScript Monorepos with Lerna
Lerna is a monorepo manager for JavaScript projects. It helps you take a large codebase and split it into independently deployable packages.
Read more >
Lerna is a fast, modern build system for managing and ...
Lerna is a fast modern build system for managing and publishing multiple JavaScript/TypeScript packages from the same repository.
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