Module System
ES module import/export syntax compiles to Luau require() calls and module returns,
with Rojo-aware path resolution.
| TypeScript | Luau |
|---|---|
import React from "react" | local React = require(...) |
import { useState } from "react" | local useState = React.useState |
import { Players } from "@rbx-services" | local Players = game:GetService("Players") |
import Card from "./Card" | local Card = require(script.Parent.Card) |
import * as Utils from "./utils" | local Utils = require(script.Parent.utils) |
import styles from "./Card.module.css" | local styles = require(script.Parent["Card.style"]) |
export default function App() | return App |
export function helper() | return { helper = helper } |
export { X } from "./module" | Re-export handling |
Path resolution
Section titled “Path resolution”- File naming follows Rojo conventions:
index.tsxbecomesinit.luau. - Package imports resolve to
ReplicatedStorage.Packages.<PackageName>. - Rojo-aware path resolution reads
default.project.jsonfor alias mapping, so source directories map to the correctgame:GetService(...)require paths.
Roblox services
Section titled “Roblox services”The @rbx-services virtual module maps named imports to game:GetService():
import { Players, RunService } from "@rbx-services";local Players = game:GetService("Players")local RunService = game:GetService("RunService")See Roblox Integration for more on services and the Instance API.