JavaScript and TypeScript Monorepos

Adding a Scoped Start Script

JavaScript and TypeScript Monorepos

Check out a free preview of the full JavaScript and TypeScript Monorepos course

The "Adding a Scoped Start Script" Lesson is part of the full, JavaScript and TypeScript Monorepos course featured in this preview video. Here's what you'd learn in this lesson:

Mike demonstrates how to add a start script to an application using bash, and how to use Lerna to make starting an application easier.


Transcript from the "Adding a Scoped Start Script" Lesson

>> Let's look at this UI here for a sec. Actually, I can stay at this root level here at the base of my package. This also is, by the way, a really important aspect of these tools. Because you do not even just the act of changing directories and going in and coming back out, that takes time, and it's cumbersome.

So from the outside here, I can just say lerna run dev --scope @slack/ui. Let's see what happens. This should run parcel. Ooh, actually, I wanna cancel this. Want to add this stream argument because I want to see the output from my build tool. Right so it's listening on localhost 1234.

And let's see what that looks like. .And here we are it kind looks like upside down stack app. It's like team, and change channels, etcetera. so this is that React App. and over here we can see like we are receiving API calls, like there is a little express server that's running.

So I can run this. In fact, this command here, I kind of want it to be the like the NPM start for my whole workspace. So I can go up here. I could say start. Script D, And then just create a new workspace level script And I like these little ASCII art things.

They just helped make the output a bit more readable and it helps, helps you have something to spot. That makes it obvious when something's not running at all. So do you favour this or no run dev with a scope over using the yarn workspace command for like the single execution on the package.

I the general solution of Lerner run is very nice. So if I mean you could use either to be honest. And here here's Let me tell you my reasoning for explaining this one. There is no getting away from learner run. Unless you truly want to enter every package, like for things that have to be applied to all packages or a subset of packages, you need to learn how to use learn to run.

And if I don't have to teach you something else, I may avoid teaching you something else. Like that's fewer things for you to remember. That's true that there are alternate ways of doing this. In fact, Right down to, I could literally have done this. Node, packages/ UI/server/server. And this will do exactly the same thing.

In fact, I might prefer this because I get colorized output. Nothing is interfering with the stuff that's coming out. But I do not really see how some of the other yarn stuff that I have not talked about here least the ability to execute something like that. I don't see that that is it is not better than what I just did and.

It's one more thing to know. So you already know how to run something with node and you already have to know how to use Learn, learn how to run, and that is sufficient. Does that rationale make sense?
>> Yes.
>> In fact, I'm gonna switch it out for this.

I kinda like the colorized output. Makes me happy. So now at the root of my project, I can just run, yarn. Start. Ooh, what's wrong? What did I forget? I need to chmod Write was ignored because it is not readable and executable. So basically this is going to be part of your muscle memory, make that script so you can actually run it.

It's not just a text file that contains a bash script it is a runnable thing. Now when I run this, it should work and there it does. And does it actually work? Let's come full circle. And it does. Some of the messages might be duplicates here. There's a bug with maybe there's like no messages for this one channel when it's like.

We can add a little bit but many of them are working

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now