-
-
Notifications
You must be signed in to change notification settings - Fork 932
feat(transformer): add ES2026 target for explicit resource management #14330
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
graphite-app
merged 1 commit into
main
from
feat/move-explicit-resource-management-to-es2026
Oct 5, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
File renamed without changes.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| use oxc_ast::ast::*; | ||
| use oxc_traverse::Traverse; | ||
|
|
||
| use crate::{ | ||
| context::{TransformCtx, TraverseCtx}, | ||
| state::TransformState, | ||
| }; | ||
|
|
||
| mod explicit_resource_management; | ||
| mod options; | ||
|
|
||
| use explicit_resource_management::ExplicitResourceManagement; | ||
| pub use options::ES2026Options; | ||
|
|
||
| pub struct ES2026<'a, 'ctx> { | ||
| explicit_resource_management: Option<ExplicitResourceManagement<'a, 'ctx>>, | ||
| } | ||
|
|
||
| impl<'a, 'ctx> ES2026<'a, 'ctx> { | ||
| pub fn new(options: ES2026Options, ctx: &'ctx TransformCtx<'a>) -> Self { | ||
| let explicit_resource_management = if options.explicit_resource_management { | ||
| Some(ExplicitResourceManagement::new(ctx)) | ||
| } else { | ||
| None | ||
| }; | ||
| Self { explicit_resource_management } | ||
| } | ||
| } | ||
|
|
||
| impl<'a> Traverse<'a, TransformState<'a>> for ES2026<'a, '_> { | ||
| fn enter_program(&mut self, program: &mut Program<'a>, ctx: &mut TraverseCtx<'a>) { | ||
| if let Some(explicit_resource_management) = &mut self.explicit_resource_management { | ||
| explicit_resource_management.enter_program(program, ctx); | ||
| } | ||
| } | ||
|
|
||
| fn enter_for_of_statement( | ||
| &mut self, | ||
| for_of_stmt: &mut ForOfStatement<'a>, | ||
| ctx: &mut TraverseCtx<'a>, | ||
| ) { | ||
| if let Some(explicit_resource_management) = &mut self.explicit_resource_management { | ||
| explicit_resource_management.enter_for_of_statement(for_of_stmt, ctx); | ||
| } | ||
| } | ||
|
|
||
| fn exit_static_block(&mut self, block: &mut StaticBlock<'a>, ctx: &mut TraverseCtx<'a>) { | ||
| if let Some(explicit_resource_management) = &mut self.explicit_resource_management { | ||
| explicit_resource_management.exit_static_block(block, ctx); | ||
| } | ||
| } | ||
|
|
||
| fn enter_function_body(&mut self, body: &mut FunctionBody<'a>, ctx: &mut TraverseCtx<'a>) { | ||
| if let Some(explicit_resource_management) = &mut self.explicit_resource_management { | ||
| explicit_resource_management.enter_function_body(body, ctx); | ||
| } | ||
| } | ||
|
|
||
| fn enter_statement(&mut self, stmt: &mut Statement<'a>, ctx: &mut TraverseCtx<'a>) { | ||
| if let Some(explicit_resource_management) = &mut self.explicit_resource_management { | ||
| explicit_resource_management.enter_statement(stmt, ctx); | ||
| } | ||
| } | ||
|
|
||
| fn enter_try_statement(&mut self, node: &mut TryStatement<'a>, ctx: &mut TraverseCtx<'a>) { | ||
| if let Some(explicit_resource_management) = &mut self.explicit_resource_management { | ||
| explicit_resource_management.enter_try_statement(node, ctx); | ||
| } | ||
| } | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| use serde::Deserialize; | ||
|
|
||
| #[derive(Debug, Default, Clone, Copy, Deserialize)] | ||
| #[serde(default, rename_all = "camelCase", deny_unknown_fields)] | ||
| pub struct ES2026Options { | ||
| #[serde(skip)] | ||
| pub explicit_resource_management: bool, | ||
| } |
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,3 @@ | ||
| mod explicit_resource_management; | ||
| mod options; | ||
|
|
||
| pub use explicit_resource_management::ExplicitResourceManagement; | ||
| pub use options::ProposalOptions; |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,5 @@ | ||
| #[derive(Debug, Clone, Copy)] | ||
| #[expect(clippy::empty_structs_with_brackets)] | ||
| #[derive(Debug, Clone, Copy, Default)] | ||
| pub struct ProposalOptions { | ||
| pub explicit_resource_management: bool, | ||
| } | ||
|
|
||
| impl Default for ProposalOptions { | ||
| fn default() -> Self { | ||
| Self { explicit_resource_management: true } | ||
| } | ||
| // Currently no proposals are configured here. | ||
| } |
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.