require
SDK 0.1.0-preview.1 · ExperimentalDownload & release notes ↗
Loads a declared Luau source module. It does not download packages.
Example
Section titled “Example”Where to put it: replace Src/Main.luau in a project created with this SDK. This is the complete entry file.
-- Src/Main.luau; declare both source files in lui.json.local Greeting = require("./Greeting")local Window = Instance.new("Window", {Title = Greeting.Text, Size = UDim2.fromOffset(560, 280)})Window.Visible = trueAlso create Src/Greeting.luau and add it to Modules.Files:
return {Text = "Hello from a module"}Expected result: A window uses the value returned by Greeting.luau. The module is loaded from declared source; require does not install a package.
Full type declaration — for type checking and deeper reference
The declaration is generated from the SDK. Self is supplied by a colon call; read means the field cannot be assigned. See how to read this reference.
declare require: (Request: string) -> unknownSee modules and project structure for the complete manifest and import rules.