Skip to content

Support requiring native modules#968

Draft
jkelaty-rbx wants to merge 10 commits into
luau-lang:primaryfrom
jkelaty-rbx:native-module-require
Draft

Support requiring native modules#968
jkelaty-rbx wants to merge 10 commits into
luau-lang:primaryfrom
jkelaty-rbx:native-module-require

Conversation

@jkelaty-rbx

@jkelaty-rbx jkelaty-rbx commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

Note: I'm mostly leaving this open for historical context, though I am also happy to revive this PR if there's interest in moving forward with it.

Motivation

Enables users to write C/C++ libraries that extend Lute with native functionality (e.g., bindings to libgit2, SQLite, image processing) without forking Lute. Native modules follow the same luteopen_* convention as built-in @lute/ modules and are loaded through the standard require() path.

Summary

  • Extends require() to load native shared libraries (.dylib, .so, .dll) from disk via uv_dlopen/uv_dlsym
  • Entry point convention: libfoo.dylibextern "C" int luteopen_foo(lua_State* L)
  • Library handles are anchored in a _NATIVELIBS registry table and closed when the lua_State is torn down
  • Includes a working example at examples/native-extension/
  • Type checking is supported via a types file embedded in the shared object

@jkelaty-rbx jkelaty-rbx marked this pull request as ready for review April 10, 2026 22:30
@OMouta OMouta mentioned this pull request May 21, 2026
@jkelaty-rbx jkelaty-rbx marked this pull request as draft June 6, 2026 06:17
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.

1 participant