Skip to content

Conversation

@skanosue
Copy link
Contributor

@skanosue skanosue commented Oct 21, 2025

Implementation of loadbypath in user land using luau.load. Addresses #321 .

@skanosue skanosue self-assigned this Oct 21, 2025
@Vighnesh-V
Copy link
Collaborator

Also will resolve #463

@skberkeley skberkeley assigned skberkeley and unassigned skanosue Oct 22, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements requirebypath (renamed to loadbypath) in userland using luau.load and fixes a bug in the path library where path objects were being mutated during path.join operations.

Key Changes:

  • Added luau.loadbypath function to load and execute Luau scripts by file path
  • Fixed path mutation bug by cloning path objects in path.join for both POSIX and Win32 implementations
  • Updated require statements from @lute/luau to @std/luau across multiple files

Reviewed Changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
lute/std/libs/luau.luau New wrapper module implementing loadbypath and re-exporting types from @lute/luau
lute/std/libs/path/posix.luau Fixed path mutation by cloning path parts before joining
lute/std/libs/path/win32.luau Fixed path mutation by cloning path parts before joining
tests/loadbypath.test.luau Integration test verifying loadbypath functionality
tests/path.posix.test.luau Added assertions to verify original path object remains unchanged after join
tests/path.win32.test.luau Added assertions to verify original path object remains unchanged after join
lute/luau/src/luau.cpp Simplified C++ implementation by removing redundant path manipulation logic
definitions/luau.luau Updated luau.load signature to make chunkname parameter non-optional
tests/testAstSerializer.test.luau Updated imports to use @std/luau
lute/std/libs/syntax/visitor.luau Updated imports to use @std/luau
lute/std/libs/syntax/printer.luau Updated imports to use @std/luau
lute/std/libs/syntax/parser.luau Updated imports to use @std/luau
examples/parsing.luau Updated imports to use @std/luau
examples/linter.luau Updated imports to use @std/luau
examples/compile.luau Updated imports to use @std/luau

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +9 to +153
export type Position = luteLuau.Position
export type Location = luteLuau.Location

export type Whitespace = luteLuau.Whitespace
export type SingleLineComment = luteLuau.SingleLineComment
export type MultiLineComment = luteLuau.MultiLineComment

export type Trivia = luteLuau.Trivia

export type Token<Kind = string> = luteLuau.Token<Kind>

export type Eof = luteLuau.Eof

export type Pair<T, Separator> = luteLuau.Pair<T, Separator>
export type Punctuated<T, Separator = ","> = luteLuau.Punctuated<T, Separator>

export type AstLocal = luteLuau.AstLocal

export type AstExprGroup = luteLuau.AstExprGroup

export type AstExprConstantNil = luteLuau.AstExprConstantNil

export type AstExprConstantBool = luteLuau.AstExprConstantBool

export type AstExprConstantNumber = luteLuau.AstExprConstantNumber

export type AstExprConstantString = luteLuau.AstExprConstantString

export type AstExprLocal = luteLuau.AstExprLocal

export type AstExprGlobal = luteLuau.AstExprGlobal

export type AstExprVarargs = luteLuau.AstExprVarargs

export type AstExprCall = luteLuau.AstExprCall

export type AstExprIndexName = luteLuau.AstExprIndexName

export type AstExprIndexExpr = luteLuau.AstExprIndexExpr

export type AstFunctionBody = luteLuau.AstFunctionBody

export type AstExprAnonymousFunction = luteLuau.AstExprAnonymousFunction

export type AstExprTableItem = luteLuau.AstExprTableItem

export type AstExprTable = luteLuau.AstExprTable

export type AstExprUnary = luteLuau.AstExprUnary

export type AstExprBinary = luteLuau.AstExprBinary

export type AstExprInterpString = luteLuau.AstExprInterpString

export type AstExprTypeAssertion = luteLuau.AstExprTypeAssertion

export type AstExprIfElseIfs = luteLuau.AstExprIfElseIfs

export type AstExprIfElse = luteLuau.AstExprIfElse

export type AstExpr = luteLuau.AstExpr

export type AstStatBlock = luteLuau.AstStatBlock

export type AstStatElseIf = luteLuau.AstStatElseIf

export type AstStatIf = luteLuau.AstStatIf

export type AstStatWhile = luteLuau.AstStatWhile

export type AstStatRepeat = luteLuau.AstStatRepeat

export type AstStatBreak = luteLuau.AstStatBreak

export type AstStatContinue = luteLuau.AstStatContinue

export type AstStatReturn = luteLuau.AstStatReturn

export type AstStatExpr = luteLuau.AstStatExpr

export type AstStatLocal = luteLuau.AstStatLocal

export type AstStatFor = luteLuau.AstStatFor

export type AstStatForIn = luteLuau.AstStatForIn

export type AstStatAssign = luteLuau.AstStatAssign

export type AstStatCompoundAssign = luteLuau.AstStatCompoundAssign

export type AstAttribute = luteLuau.AstAttribute

export type AstStatFunction = luteLuau.AstStatFunction

export type AstStatLocalFunction = luteLuau.AstStatLocalFunction

export type AstStatTypeAlias = luteLuau.AstStatTypeAlias

export type AstStatTypeFunction = luteLuau.AstStatTypeFunction

export type AstStat = luteLuau.AstStat

export type AstGenericType = luteLuau.AstGenericType

export type AstGenericTypePack = luteLuau.AstGenericTypePack

export type AstTypeReference = luteLuau.AstTypeReference

export type AstTypeSingletonBool = luteLuau.AstTypeSingletonBool

export type AstTypeSingletonString = luteLuau.AstTypeSingletonString

export type AstTypeTypeof = luteLuau.AstTypeTypeof

export type AstTypeGroup = luteLuau.AstTypeGroup

export type AstTypeOptional = luteLuau.AstTypeOptional

export type AstTypeUnion = luteLuau.AstTypeUnion

export type AstTypeIntersection = luteLuau.AstTypeIntersection

export type AstTypeArray = luteLuau.AstTypeArray

export type AstTypeTableItem = luteLuau.AstTypeTableItem

export type AstTypeTable = luteLuau.AstTypeTable

export type AstTypeFunctionParameter = luteLuau.AstTypeFunctionParameter

export type AstTypeFunction = luteLuau.AstTypeFunction

export type AstType = luteLuau.AstType

export type AstTypePackExplicit = luteLuau.AstTypePackExplicit

export type AstTypePackGeneric = luteLuau.AstTypePackGeneric

export type AstTypePackVariadic = luteLuau.AstTypePackVariadic

export type AstTypePack = luteLuau.AstTypePack

export type ParseResult = luteLuau.ParseResult

export type Bytecode = luteLuau.Bytecode
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all of these should become luacase ultimately, but it's okay if that doesn't happen in this PR.

@Vighnesh-V
Copy link
Collaborator

I don't want to be annoying lol, but I think i'm going to ask that we separate the path.join fix since it's affecting at least a few lute users and we should deliver that faster (it's also uncontroversial).

@skberkeley skberkeley requested review from aatxe and vrn-sn October 24, 2025 19:05
Copy link
Member

@vrn-sn vrn-sn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, I would just be sure to rename the PR title and description with the new API name.

@skberkeley skberkeley changed the title stdlib: requirebypath stdlib: loadbypath Oct 28, 2025
@skberkeley skberkeley merged commit 0ccff12 into primary Oct 28, 2025
10 checks passed
@skberkeley skberkeley deleted the skanosue/requirebypath branch October 28, 2025 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

6 participants