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 .luau support to RojoResolver #496

Merged
merged 5 commits into from
Sep 10, 2024

Conversation

osyrisrblx
Copy link
Member

@osyrisrblx osyrisrblx commented Jul 3, 2024

Converts input paths from .lua -> .luau internally to better handle results of PathTranslator.getImportPath().

Copy link
Contributor

@sasial-dev sasial-dev left a comment

Choose a reason for hiding this comment

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

Should we use this PR to also support the others file extensions rojo supports natively?
I believe only .toml is missing, as YAML support is in another PR (rojo-rbx/rojo#913) that we can do later.

@osyrisrblx
Copy link
Member Author

osyrisrblx commented Sep 10, 2024

.toml is an interesting thought.. however, TypeScript doesn't have built-in support for this like it does for JSON files, so I'm not sure it would do you a ton of good.

You could potentially make a .d.ts file with:

declare module "*.toml" {
	const value: unknown;
	export default value;
}

This would allow you to import any .toml file, but the import would just be unknown.

I don't think that gives you much value. You could just require() the rojo-made ModuleScript and get the same thing.

Alternatively, you might be able to use a TypeScript plugin like:
https://github.com/sapphi-red/typescript-plugin-toml

This seems to work okay for me in the editor, but the compiler throws an error saying it can't find the module. We'd probably need to add support for these plugins somehow.

@osyrisrblx osyrisrblx merged commit a863d6f into master Sep 10, 2024
3 checks passed
@osyrisrblx osyrisrblx deleted the Add-.luau-support-to-RojoResolver 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.

2 participants