Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/seaofvoices/npmluau
A utility package to use npm for Luau projects
https://github.com/seaofvoices/npmluau
Last synced: 3 months ago
JSON representation
A utility package to use npm for Luau projects
- Host: GitHub
- URL: https://github.com/seaofvoices/npmluau
- Owner: seaofvoices
- License: mit
- Created: 2023-10-05T17:52:13.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-01T20:16:11.000Z (about 1 year ago)
- Last Synced: 2024-09-30T15:13:12.350Z (3 months ago)
- Language: JavaScript
- Size: 29.3 KB
- Stars: 15
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# npmluau
This utility can be used to allow Luau projects to use npm as a package manager. It lets your projects use string requires: use relative file paths for the project's files or prefix your dependency names with `@pkg` to use them.
If you are developing on a platform that does not support requires with, you can use a tool like [darklua](https://github.com/seaofvoices/darklua) to automatically convert requires into your platform specific implementation.
## How to use
Add `npmluau` in your dev-dependencies:
```bash
yarn add --dev npmluau
```Or if you are using `npm`:
```bash
npm install --save-dev npmluau
```In your Luau project `package.json` file, add a `prepare` script to run `npmluau`:
```json
"scripts": {
"prepare": "npmluau",
}
```## How it works
This utility will generate a folder named `.luau-aliases` inside `node_modules` after installing your dependencies that contains module links to each dependency.
**[Luau-lsp](https://github.com/JohnnyMorganz/luau-lsp)**:
If you using the VS code extension, you can define a directory alias in your workspace settings:
```json
{
"luau-lsp.require.directoryAliases": {
"@pkg": "node_modules/.luau-aliases"
}
}
```If you are also running `luau-lsp` from the command line interface, you can provide the directory aliases within a configuration file and pass it to the `--settings` argument:
```json
{
"luau-lsp.require.mode": "relativeToFile",
"luau-lsp.require.directoryAliases": {
"@pkg": "node_modules/.luau-aliases"
}
}
```