Skip to content

Module System

ES module import/export syntax compiles to Luau require() calls and module returns, with Rojo-aware path resolution.

TypeScriptLuau
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
  • File naming follows Rojo conventions: index.tsx becomes init.luau.
  • Package imports resolve to ReplicatedStorage.Packages.<PackageName>.
  • Rojo-aware path resolution reads default.project.json for alias mapping, so source directories map to the correct game:GetService(...) require paths.

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.