-
Notifications
You must be signed in to change notification settings - Fork 12
Yarn dependency resolution
It is possible to use Yarn to add, remove and configure dependencies.
All dependencies are installed to a node_modules folder which should be added to .gitignore if being used.
All dependency information is stored in package.json and yarn.lock which will be used if a collaborator wants to install all the dependencies you used. So this will need to be included with a project.
Command | Description |
---|---|
yarn add <package-name> |
Adds a package from NPMJS or another registered repo. |
yarn remove <package-name> |
Removes a package. |
yarn upgrade <package>@latest |
Upgrades a package to the latest version. |
yarn |
Install all dependencies specified in yarn.lock or package.json . |
Yarn is also able to add github repos as modules.
yarn add <githubusername>/<githubrepo>
This means, if a Lua library you want to use is on GitHub, you can add it to this dependency resolution system. However you'll have to be considerate about how to hook this up.
If using a conf.ts file, since this will be executed first, you can add the following code to tell Lua about another directory to check for modules.
package.path += "./node_modules/?/?.lua";
Then TypeScript will have to be told that this module is now available in any .d.ts or .ts file in the project.
/** @noResolution */
declare module "lurker";
Members can be added to the module to reveal the contents of "lurker" for better type safety.
And now you can import it in TS code. However it is only determined at runtime if Lua will pick up the module in question to clarify if this has been set up correctly.
import * as lurker from "lurker";