Skip to content

Create content loaders#354

Merged
jeparlefrancais merged 4 commits into
mainfrom
content-loaders
Jun 2, 2026
Merged

Create content loaders#354
jeparlefrancais merged 4 commits into
mainfrom
content-loaders

Conversation

@jeparlefrancais

@jeparlefrancais jeparlefrancais commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

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.

  • 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.

Todo:

  • add entry to the changelog
  • update documentation

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.
@nnullcolumn

nnullcolumn commented Jun 1, 2026

Copy link
Copy Markdown

what kind of types will the data loaders emit? If I have a string in a json file, will it be "str" :: "str" (singleton) or will it be string? personally i would prefer the former since type functions can convert it to the latter, but i'd assume the latter has been done by default.

edit: it says Lua module, so i'd assume just Lua. Luau mode would be cool tho

@jeparlefrancais

Copy link
Copy Markdown
Contributor Author

what kind of types will the data loaders emit? If I have a string in a json file, will it be "str" :: "str" (singleton) or will it be string? personally i would prefer the former since type functions can convert it to the latter, but i'd assume the latter has been done by default.

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 convert command would give today. The extension is configurable though

@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown

Coverage after merging content-loaders into main will be

85.06%

Coverage Report for Changed Files
FileStmtsBranchesFuncsLinesUncovered Lines
src/frontend
   configuration.rs80.95%100%79.37%81.23%114–117, 121–125, 129–132, 136–140, 143–146, 149–154, 157–159, 241–260, 262–263, 339–343, 81–83, 94–97
   content_loader.rs95.35%100%90%95.80%231, 238–239, 83
   error.rs62.62%100%62.86%62.59%125–130, 136–141, 143–145, 147–149, 188, 196, 202, 209, 234–236, 238–242, 244–252, 263–267, 269, 271, 275–280, 293–298, 302–307, 311–316, 320–325, 337–339, 341, 343, 345–346, 357, 359–360, 362–363, 380, 389, 422, 424, 429–430, 437, 442–443, 445–447, 449–450, 452–453
   mod.rs100%100%100%100%
   resources.rs66.67%100%66.67%66.67%120–128, 130, 133, 135–138, 140–148, 150, 153, 158, 160–162, 165, 167, 172–178, 180, 188–191, 214, 216, 221, 225–226, 228, 241–242, 244, 251–252, 254, 304–306, 354–359, 361–363, 386–388, 390–395, 397–402, 64–66, 88
   work_item.rs91.41%100%91.67%91.35%107–109, 150, 155–158, 166
   worker.rs79.17%100%80%79.11%100, 103, 108, 112–114, 136, 150–151, 180–181, 189–190, 194, 196, 198–199, 207, 241, 250–252, 254, 278–281, 288, 290–291, 293, 295–299, 322, 339, 349, 357, 359, 361–362, 381, 432, 451–452, 46, 468, 53, 81, 93, 95–99
   worker_tree.rs48.73%100%45.45%49.06%112–113, 123, 151, 163, 166, 171, 177, 180, 184, 195–196, 199, 234, 236–237, 239–249, 251–253, 255, 258, 284, 294, 301–305, 308–313, 316–317, 319–328, 330–332, 335–336, 338–343, 345–348, 351–352, 354–358, 360–363, 365, 367–368, 370, 372–375, 377, 379, 381–387, 391–392, 395–398, 401–402, 404, 406–411, 430–431, 433–437, 439–443, 445, 447, 468, 471, 473–479, 481, 483, 50, 52, 54, 61, 63, 65, 76, 78–79, 82
src/nodes/expressions
   mod.rs80.47%100%96.88%77.60%111–121, 123–129, 131–133, 140–144, 146–150, 152–156, 221–223, 381
src/rules
   mod.rs86.91%100%80.39%87.76%166–168, 189–191, 206, 235, 237, 239–240, 285–287, 305–308, 310–314, 316–319, 321–325, 459, 491, 532, 545–547, 576, 586, 596, 603–606, 626
src/rules/bundle
   mod.rs87.12%100%85.71%87.39%120–124, 134–136, 138–140, 40–41, 46
src/rules/bundle/path_require_mode
   mod.rs87.44%100%93.33%86.98%112–113, 117, 119, 121, 171, 184, 191, 208–209, 220–221, 275–276, 282–285, 287–288, 299, 309–310, 93–94
src/rules/convert_require
   mod.rs92.93%100%91.30%93.17%117–119, 157, 167–168, 49, 72–73
src/utils
   filter_pattern.rs84.62%100%75%87.10%24–26
   mod.rs96.48%100%96%96.58%63–64, 71
   serde_vec_of_pairs.rs81.82%100%71.43%83.78%31–33, 36–38

@jeparlefrancais jeparlefrancais merged commit 40464a1 into main Jun 2, 2026
6 checks passed
@jeparlefrancais jeparlefrancais deleted the content-loaders branch June 2, 2026 15:02
@jeparlefrancais jeparlefrancais mentioned this pull request Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Content Loaders

2 participants