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.

Guidance on current usage with Lerna and Yarn Workspaces?

See original GitHub issue

I am currently setting up a fresh monorepo structure using Lerna and TSDX to build out a component library.

I have read and followed the various links related to #122 but wanted to check if there is anything to consider when using TSDX inside a lerna monorepo before some kind of official monorepo template (might) land.

My current thinking is to:

  1. Setup the monorepo via lerna as normal
  2. Setup the yarn workspaces integration with lerna
  3. Add tsdx as a devDependency at the root level
  4. Run npx tsdx create mylib-package-a for each package inside the packages/* folder
  5. Add npm scripts at the root level that use lerna run [flags] to either start, watch, test or build each individual package folder as one command.

Is that roughly the right approach for using TSDX inside a monorepo structure?

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:5
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
pcowgillcommented, Nov 22, 2019

I think there’s room for a separate init config for tsdx that configures a lerna-friendly version of a tsdx project. lerna and monorepos are common enough that a feature like this will help a lot with adoption of this lib.

I’ve been following roughly this approach, but needing to remember to modify a few of the instructions given that I’m using tsdx rather than tsc directly. And doing this much tsconfig wrangling sort of defaults the purpose of using tsdx.

1reaction
slorbercommented, Apr 6, 2020

Hey,

To me, the best is to build once, and then run watch in --parallel with the --noClean option.

Problem is that currently, the watcher is only looking for changes in ./src, so your symlinks will not be watched (+ they might be hoisted).

https://github.com/jaredpalmer/tsdx/blob/b21d7af1ae87f3f1f1324e7ad07671dde630fed0/src/index.ts#L328

Will see if I can send a PR for that, but was not very successful with patch-package 😕

Read more comments on GitHub >

github_iconTop Results From Across the Web

A Beginner's Guide to Lerna with Yarn Workspaces | by jsilvax
It allows us to easily release dependencies on NPM with a single command, automatically updates the package.
Read more >
Monorepo Javascript Projects with Yarn Workspaces and Lerna
Yarn workspaces are used to optimize dependency management. When we use yarn workspaces, all project dependencies are installed in one go. Tools ...
Read more >
Why Lerna and Yarn Workspaces is a Perfect Match for ...
For this approach, you do not require lerna. yarn workspaces come with built-in Mono-Repo capabilities. To use yarn workspaces you need yarn ...
Read more >
Monorepos: Yarn Workspaces and Lerna for beginners!
Let's discover how to handle monorepos with multiple packages using Yarn Workspaces and LernaJS. We're going to discuss Yarn Workspaces ...
Read more >
Getting Started | Lerna
When running lerna init , Lerna configures the workspace to use NPM/YARN/PNPM workspaces, the built-in solution for local referencing of packages. In this ......
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