Skip to content

Commit aa8dea1

Browse files
committed
Add Lua require mode docs, integrate feedback.
1 parent 1f2be29 commit aa8dea1

5 files changed

Lines changed: 103 additions & 63 deletions

File tree

site/content/docs/config/index.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ Any missing field will be replaced with its default value.
5858

5959
// Configure how requires are interpreted
6060
require_mode: {
61-
// Currently, the only supported require mode is `path`
6261
name: "path",
6362

6463
// When requiring folders, require the file named like this value inside of it
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
title: Lua Require Mode
3+
description: How lua (and darklua) understands require calls
4+
group: Configuration
5+
order: 6
6+
---
7+
8+
This require mode is used for lua programs outside of the Luau ecosystem, including PUC lua, luajit, and most other plain lua
9+
implementations that include a require function.
10+
For more information, please refer to the documentation for [package.searchpath at lua.org](https://lua.org/manual/5.5/manual.html#pdf-package.searchpath).
11+
12+
## Bundling Support
13+
14+
It can be configured in the **bundle** part of the configuration file. For a quick overview of the bundling configuration, see [the documentation page](../bundle/).
15+
16+
## Configuration
17+
18+
The lua require mode uses the environment variable `LUA_PATH` by default as the search path,
19+
but it can be configured to either use a different environment variable, just use the default search path, or
20+
to use a string from the configuration file.
21+
Lua's require does not support aliases or hierarchy beyond the filesystem, so there is no configuration for them.
22+
Note that despite lua's require not supporting embedding text, JSON, TOML, and YAML files, you may do so with darklua,
23+
as long as it is present in the search string.
24+
25+
### Example
26+
```json5
27+
{
28+
bundle: {
29+
require_mode: {
30+
name: "lua",
31+
env: "DARKLUA_PATH",
32+
// Path takes priority over env when provided. In the search string,
33+
// order is important.
34+
path: "./?.luau;./?/init.luau;./res/?.json;./res/?.toml"
35+
}
36+
}
37+
}
38+
```

0 commit comments

Comments
 (0)