Skip to content

fix(imports): count @ox_core/lib/init.lua as loading @ox_lib/init.lua - #22

Merged
ChatDisabled merged 1 commit into
mainfrom
fix/ox-core-import-loads-ox-lib
Oct 26, 2026
Merged

ChatDisabled merged 1 commit into
mainfrom
fix/ox-core-import-loads-ox-lib

Conversation

@ChatDisabled

Copy link
Copy Markdown
Member

Closes #19

@ox_core/lib/init.lua runs @ox_lib/init.lua itself when lib is not defined yet, so a resource that imports it has lib, cache and the other ox_lib globals at runtime. The linter and the language server only knew the ox_core import for Ox, and fivem/import-not-declared asked for an @ox_lib/init.lua entry that is redundant at runtime.

Resulting behaviour

  • A known import can name the imports it runs itself (KnownImport::loads); @ox_core/lib/init.lua loads @ox_lib/init.lua.
  • resource_imports adds those on the side of the import that runs them, unless the manifest or the configured imports already load them there. Both tools build the resource environment from it, so the ox_lib globals, the ox_lib table and math extensions, qbox/prefer-cache and provider-scoped definition files follow an ox_core import. ox_core's own lib/init.lua sees lib in the resources that run it, too.
  • The language server indexes ox_lib next to the workspace when only ox_core is imported, so lib.notify resolves to ox_lib's definition, and definition files in a library folder named ox_lib reach those resources.
  • manifest/missing-dependency treats a resource that an import loads like one the manifest imports directly.
  • Listing @ox_lib/init.lua as well keeps working and adds nothing twice.

Tests

  • qbx_lua_analysis: unit test for the expansion, including sides and imports already listed.
  • qbx_lint: the ox_core import on each side, with the wrong-side cases still reported, and an installed ox_core with the manifest shape its build generates.
  • qbx_lua_ls: ox_lib indexed and lib.notify resolved through the ox_core import; an ox_lib definition folder reaching importers of ox_core only.

Checks

  • cargo fmt --all --check
  • cargo clippy --workspace --all-targets --locked -- -D warnings
  • cargo test --workspace --locked

@ChatDisabled
ChatDisabled merged commit 1de69ca into main Oct 26, 2026
2 checks passed
@ChatDisabled
ChatDisabled deleted the fix/ox-core-import-loads-ox-lib branch October 26, 2026 20:30
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.

qbx-lua-ls: false positive "lib comes from @ox_lib/init.lua" when the manifest loads @ox_core/lib/init.lua

1 participant