Skip to content

feat(config): add imports for files loaded without an fxmanifest entry - #6

Merged
ChatDisabled merged 2 commits into
Qbox-project:mainfrom
loaf-scripts:main
Sep 30, 2026
Merged

ChatDisabled merged 2 commits into
Qbox-project:mainfrom
loaf-scripts:main

Conversation

@loaf-scripts

@loaf-scripts loaf-scripts commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Changes

Some resources run code from another resource without an fxmanifest.lua entry, for example a shared library whose loader calls load(LoadResourceFile(...)) for each of its files. The linter cannot follow that, so every global those files define is reported as undefined-global in the resources that use them. Listing them under globals means naming each one by hand and losing the client/server checks.

imports lists those files as @resource/path patterns, grouped by the side they run on. Each resource then sees their globals as if its manifest imported them:

[imports]
shared = ["@my_lib/shared/**.lua"]
client = ["@my_lib/client/**.lua"]
server = ["@my_lib/server/**.lua", "@oxmysql/lib/MySQL.lua"]

# Or only for some resources: an override's imports apply to each resource
# whose fxmanifest.lua its `files` patterns match
[[overrides]]
files = ["resources/[[]my_lib[]]/**"]

[overrides.imports]
shared = ["@my_lib/shared/**.lua"]
  • Patterns follow fxmanifest globs: * stays within a folder, ** crosses folders, and case is ignored.
  • Server scripts do not see the globals of client imports, and client scripts do not see those of server imports.
  • Well-known imports such as @oxmysql/lib/MySQL.lua keep their built-in globals when the resource is not installed. Any other pattern that matches no file is reported like an unresolved manifest import.
  • A pattern that is not an @resource/path Lua pattern stops the config from loading, with an error naming it.
  • Documented under "Runtime imports" in docs/reference.md; examples/qbxlint.toml shows the new table.

Implementation:

  • resource_imports (manifest plus configured imports) and ResourceEnv::add_import in project.rs replace the add_import free function. qbx-lua-ls uses them too, so both build the same environment; only resolving a pattern to files differs (disk here, the index there).
  • ResourceLocator keeps each imported file's parsed summary, so a library imported by many resources is parsed once per run.
  • Side effect: manifest imports with globs, such as @res/client/*.lua, are now followed instead of reported as unresolved.

Language server support: Qbox-project/qbx-lua-ls#6

Checks

  • cargo fmt --check, cargo clippy --all-targets (no warnings) and cargo test pass on Windows. Not run on Linux locally.
  • New tests: parsing, validation and override matching in config.rs; an end-to-end CLI test in tests/cli.rs covering sides and a resource the override does not match.
  • On a 25-resource server whose shared library is loaded through load(LoadResourceFile(...)), undefined-global went from 349 to 25 with the same run time (about 0.5 s). The remaining reports come from escrowed resources and unrelated third-party code.

Generated with Claude Code

@ChatDisabled
ChatDisabled merged commit 6cdc955 into Qbox-project:main Sep 30, 2026
2 checks passed
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.

2 participants