-
-
Notifications
You must be signed in to change notification settings - Fork 33
Add luau require mode #290
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Support the latest breaking change to the module require system in Luau. Luau no longers support simple file paths, instead it introduces a new way to require modules using something that could be called 'module paths'. These changes add a new require mode called 'luau' to use this new luau require behavior. For those who prefer regular file paths for their simplicity (they do not need an extra mental model as they map 1:1 to the concrete files) and to avoid breaking existing code, darklua will continue to support the existing file paths in the existing `path` require mode.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #268 Closes #214
This PR adds a completely new require mode called
luau
🚀 This means that you will be able to use the latest require system update that uses the@self
special alias.This has been a fair amount of work to fully support (and test) the new luau require syntax, while still preserving support for the regular paths. If you appreciate the work, please consider giving a tip to my ko-fi or through github sponsors ❤️
Why a new require mode?
For those who prefer regular file paths for their simplicity (they do not need an extra mental model as they map 1:1 to the concrete files) and to avoid breaking existing code, darklua will continue to support the existing file paths in the existing
path
require mode.There is a hidden feature in luau-lsp that lets you use regular path requires. If you use VSCode, you can put an entry in your settings file at
.vscode/settings.json
:darklua now has 3 require mode:
path
luau
roblox
Bonus feature: Inline aliases
This PR also closes #214 because the
path
orluau
require mode can now be used as target modes with theconvert_require
rule. This means that you can use these require modes as source and target and tweak the aliases/sources. Let's say the target mode does not have an alias named@pkg
that the source require mode uses, then darklua will produce a new path that does not use the@pkg
🤯. Example of a config that does that:Checklist