Repository navigation
Create content loaders - #354
Conversation
Add content loaders that can be mapped to files using globs/patterns in the config file. - luau: parses files as Luau (the default for .luau/.lua) - copy: simply copies files - skip: ignore files - string: create a Lua module that returns the content as a string. - buffer: create a Lua module that returns the content as a buffer. - bytes: create a Lua module that returns the content as a bytes array. - data loaders (json, toml, yaml): converts data to a Lua module.
|
what kind of types will the data loaders emit? If I have a string in a json file, will it be edit: it says Lua module, so i'd assume just Lua. Luau mode would be cool tho |
Right now it converts data files into Lua modules that don't have any type annotations at all. Same output as the |
darklua 0.19.0
Created-by: HarmonybrewBot
Commit-by: HarmonybrewBot
Merged-by: HarmonybrewBot
Description: Created by `brew bump`
---
Created with `brew bump-formula-pr`.<details>
<summary>release notes</summary>
<pre>The big change is **content loaders**. darklua now accepts glob patterns that map to configurable loaders in your config file. Most loaders are already there by default, but you can override or extend them:
```json5
{
generator: "retain_lines",
rules: [
// ...
],
loaders: {
"**/*.model.json": "copy",
"**/*.json": "json",
"**/*.md": "string",
},
}
```
This solves a few issues I know people had and it opens up new possibilities too:
- Rojo model files can now be copied when processing files (no more manual `cp` workaround) with the `copy` loader
- when bundling, darklua could already load data files (json, toml, yaml) and inline the converted data as Lua code, **but now** there are actual loaders to make that work in the regular `process` flow too
- there is now a path to support more Lua parsers, since there is a way to add loaders like a future `lua53` loader. (this is not currently planned, but it could be sponsored)
Available loaders: `luau`, `copy`, `skip`, `string`, `buffer`, `bytes`, data loaders (`json`, `json_lines`, `toml`, `yaml`), and encoding variants for embedding content (`/base64`, `/zstd`, `/gzip`, `/zlib`)
Other changes:
- `const` declarations are now supported, with a new `make_assignment_local` rule to convert them to `local` assignments
- type instantiation prefixes and methods are now supported (e.g. `func<<string>>()`)
- the `rename_variables` rule can now detect globals automatically and avoid renaming them
---
## What's Changed
* Support type instantiation prefixes and methods by @jeparlefrancais in seaofvoices/darklua#345
* Add `make_assignment_local` rule by @notpoiu in seaofvoices/darklua#346
* Add `detect_globals` parameter to `rename_variables` rule by @jeparlefrancais in seaofvoices/darklua#348
* Fix file watcher to handle rename events by @jeparlefrancais in seaofvoices/darklua#351
* Create content loaders by @jeparlefrancais in seaofvoices/darklua#354
* Support infinity for generators `column_span` parameter by @jeparlefrancais in seaofvoices/darklua#355
* Add content loader for json-lines and `ztsd`, `gzip` and `zlib` encoding by @jeparlefrancais in seaofvoices/darklua#356
## New Contributors
* @notpoiu made their first contribution in seaofvoices/darklua#346
**Full Changelog**: https://github.com/seaofvoices/darklua/compare/v0.18.0...v0.19.0</pre>
<p>View the full release notes at <a href="https://github.com/seaofvoices/darklua/releases/tag/v0.19.0">https://github.com/seaofvoices/darklua/releases/tag/v0.19.0</a>.</p>
</details>
<hr>
See merge request: Harmonybrew/homebrew-core!11206
Closes #352
For more information about content loaders, read the related issue #352.
Add content loaders that can be mapped to files using globs/patterns in the config file.
Todo: