Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for emitting .luau files #2

Merged
merged 8 commits into from
Sep 10, 2024

Conversation

osyrisrblx
Copy link
Member

@osyrisrblx osyrisrblx commented Aug 29, 2024

Temporarily behind a flag because the compiler will have a --luau flag which defaults to true. Users will be able to do --luau=false if emitting .luau files breaks their workflows.

Fixes #1

src/PathTranslator.ts Outdated Show resolved Hide resolved
@@ -193,7 +209,7 @@ export class PathTranslator {
pathInfo.fileName = INIT_NAME;
}

pathInfo.exts.push(LUA_EXT); // push .lua
pathInfo.exts.push(this.getLuauExt()); // push .luau

Choose a reason for hiding this comment

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

This is not backwards compatible. Packages that still use .lua would not be resolved correctly.

Copy link
Member Author

Choose a reason for hiding this comment

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

I believe it is.

getImportPath() is only ever used "virtually". This is because it needs to understand files which don't exist yet (i.e. outDir hasn't been created).

The result is passed into RojoResolver to figure out the RbxPath of the file without ever looking at the filesystem itself.

Copy link
Member Author

Choose a reason for hiding this comment

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

A realization I had while writing this:

RojoResolver stores references to .lua file paths exactly if a $path points to a .lua file. Will need to find a solution here.

Copy link

@Dionysusnu Dionysusnu left a comment

Choose a reason for hiding this comment

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

This implementation does not cover converting .lua input file paths to .luau when copying them from src to out (which goes via getOutputPath). Do we want to do that?

@osyrisrblx
Copy link
Member Author

This implementation does not cover converting .lua input file paths to .luau when copying them from src to out (which goes via getOutputPath). Do we want to do that?

I don't think we should. This feels a bit too magic. The compiler should just copy your non-compiled files as-is.

src/PathTranslator.ts Outdated Show resolved Hide resolved
@osyrisrblx osyrisrblx merged commit fd36c80 into master Sep 10, 2024
3 checks passed
@osyrisrblx osyrisrblx deleted the Add-support-for-emitting-.luau-files branch September 10, 2024 19:37
osyrisrblx added a commit to roblox-ts/roblox-ts that referenced this pull request Sep 10, 2024
Depends on:
- roblox-ts/path-translator#2
- roblox-ts/rojo-resolver#496

Allows for both emitting .luau files to `outDir` and importing packages
contain `.luau` files (or `.lua` for backwards compatibility).

Unit tests pass with the above two PR branches installed locally.
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.

Add support for .luau
2 participants