-
Notifications
You must be signed in to change notification settings - Fork 198
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
feat(compiler): multi-file Wing applications #3512
Conversation
@MarkMcCulloh raised an important issue which is that before shipping this, we should aim to have a solution which prevents imports from having side effects. For example, with this PR the following code would be valid: // file1.w
bring "./file2.w" as file2;
// file2.w
bring cloud;
let global_bucket = new cloud.Bucket();
class B {
// uses global_bucket
} However, notice that bringing file2.w into the first file has the side effect of creating a bucket in the user's application, even though no classes from that module actually gets constructed (such as B). In some past discussions it's been brought up that only the entrypoint Wing file should have an implicit scope, so I'd like to see if there's a way to incorporate that here. |
Totally. We discussed this a few times. Non-entrypoint files should not allow any root-level statements, only type declarations ( In the future (let's open a tracking issue) we want to support constants as root level statements in non-entrypoint files - I think we can do this as a quick follow up to this PR if it gets hairy, but let's make sure to prioritize it. |
Signed-off-by: monada-bot[bot] <[email protected]>
Signed-off-by: monada-bot[bot] <[email protected]>
Signed-off-by: monada-bot[bot] <[email protected]>
Signed-off-by: monada-bot[bot] <[email protected]>
Signed-off-by: monada-bot[bot] <[email protected]>
Signed-off-by: monada-bot[bot] <[email protected]>
Signed-off-by: monada-bot[bot] <[email protected]>
Signed-off-by: monada-bot[bot] <[email protected]>
Thank you for contributing! Your pull request will be updated from dev and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
This is incredible! So needed... |
Congrats! 🚀 This was released in Wing 0.24.41. |
Introduce a basic form of multi-file Wing projects through the
bring
keyword. To use classes, interfaces, enums, or structs from another Wing file, bring a file with a path that ends in.w
, and assign it to an alias:This initial implementation follows a (naive) strategy of recursively instantiating the parser to create a large AST. This has some limitations -- for example it's not possible for two Wing files to reuse the same third Wing file -- but this still gives users a lot more refactoring power for building Wing apps. #3511 is the main follow-up issue for addressing this.
Closes #476
Follow up:
Checklist
pr/e2e-full
label if this feature requires end-to-end testingBy submitting this pull request, I confirm that my contribution is made under the terms of the Monada Contribution License.