Let's continue doing a little bit of set up between our Seelie and local API packages.
We're going to start to add in some code to both our Seelie and the local API.
We're then going to link them together using Lernout.
But here's the goal.
Inside of our local API, we're going to create an index JS file inside there.
We're going to export a simple function.
Whenever that thing gets called, we're going to do a simple console log of server started.
Then inside of our packages on file, we'll make sure that we add in a main property of indexer.
Remember what this main property does inside of eight packages on file.
We spoke about this property much earlier inside the course when we were discussing bundling.
This tells all other packages that are trying to use local API with the main entry file is for this
package.
So a main of index, James says that if you ever try to require in local API, you're going to get back
index.
Then over inside of our Seelie, we're going to make sure that we tell llena that these two packages
are somehow linked, so we're going to add in local API as a dependency to our project.
Then inside the index, his file, we'll add in a require statement or that serve function.
We're going to try to require it from local API and then finally, we will try manually calling the
search function, which could end up giving us that log of server started.
This diagram is really showing everything we need, we have to make sure the package is on file inside
of me or inside of local API has this main property.
We have to create an index JS file inside of both packages, and then we have to set up a link between
them using llena.
So let's get to it back at my code editor.
I'll first begin inside of my local API.
I'm going to find the package JSON file.
It looks like there's already an option in here of main index, so that has been taken care of for us.
Next up, inside of local API, I will make a new file of index dogs.
Inside of here, I'll do a module, exports of a function, and whenever it gets cold, we'll do a console
log of server started.
All right, let's believe it or not, pretty much all we have to do right now inside a local API.
So now next up, we're going to form this link between Seelie and local API.
And for that, we are once again going to use that llena add command.
So back at our terminal.
Inside of any folder, inside of our overall project, we will run llena add.
Local AP, we want to add this package to another package inside of our project, and we want to be
very explicit about which package we are adding this to.
So we're going to add on that dash dash scope command and we will add in Seelie.
That means find the package and make sure it gets linked somehow to the local AP package.
Now, Seelie will be depending upon local API, so I'm going to run that.
And very quickly, we just got kicked right back over.
Next up inside of our zeolite directory, we're going to create this indexed JS file where we will attempt
to require in the local API package.
Let's go back inside my editor once again, I will find Seelie.
I will make an index just file inside of that.
At the top, I'm going to require serve.
From local API.
And then I will call serve like so.
And that's it, everything should now be linked up, as a matter of fact, if we open up our node modules
directory inside of Seelie, you'll now notice that we've got local API right here.
So there is our dependency inside the folder.
Now, let's try running the Seeley's Index JS file from our terminal, we're going to execute that thing
manually and we should see a console log of server started.
All right, so back at my terminal.
I will change back over to our Seelie directory.
There's the index JS file, so I will do Noad Index.
And sure enough, there's our council log.
Perfect.
Now, remember, one of those key things I mentioned around Lliana is that we should be able to make
changes at will to our dependency and immediately see those changes show up inside of whatever project
or whatever other package is requirement in.
So in this case, we're going to try making a change to local API instead of doing a log of server started
will change that to server is listening.
We're going to only update that file right there, and we're going to expect to see that update reflected
over inside of Seelie the next time we run this package.
So let's go back over to our local API indexed JS file.
We will update the council, log to server is listening.
Save this.
And now, once again, if we go over to our terminal.
And run note index dogs inside of our Seelie directory, we now see server is listening perfect.
So this is pretty much it.
This is a demonstration of exactly the behavior we want to learn.
We can change all these different packages as much as we want in the development environment and instantly
see all these changes reflected inside of our other projects.
So that means that we skip that entire process of having to republish this thing off to NPM, get a
new version number for it, and then have to update the local version used by Seelie.
We don't have to go through that process, which is what we would potentially have to do if we were
not making use of a tool like Lernout.
This looks pretty good now that we've got this kind of baseline set up, we can start to dive a little
bit more into some of the internals, the implementation of our Seelie and local API projects.