-
-
Notifications
You must be signed in to change notification settings - Fork 159
feat(compat): add native TypeScript transpileModule subset #8535
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
Closed
proggeramlug
wants to merge
3
commits into
PerryTS:main
from
proggeramlug:fix/8511-typescript-transpile-module
Closed
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
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| ### Added | ||
|
|
||
| - OpenCode Code Mode can use its audited `typescript` runtime surface through | ||
| a native SWC-backed `transpileModule` provider, including TS/TSX lowering, | ||
| compiler enum constants, and diagnostic formatting, without embedding the | ||
| upstream TypeScript compiler or a JavaScript engine. |
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
24 changes: 24 additions & 0 deletions
24
crates/perry-codegen/src/lower_call/native_table/typescript.rs
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,24 @@ | ||
| use super::*; | ||
|
|
||
| /// Native TypeScript runtime-transpilation subset used by OpenCode Code Mode | ||
| /// (#8511). The compiler enums are folded by HIR and therefore need no rows. | ||
| pub(super) const TYPESCRIPT_ROWS: &[NativeModSig] = &[ | ||
| NativeModSig { | ||
| module: "typescript", | ||
| has_receiver: false, | ||
| method: "transpileModule", | ||
| class_filter: None, | ||
| runtime: "js_typescript_transpile_module", | ||
| args: &[NA_STR, NA_F64], | ||
| ret: NR_OBJ_FROM_JSON_STR, | ||
| }, | ||
| NativeModSig { | ||
| module: "typescript", | ||
| has_receiver: false, | ||
| method: "flattenDiagnosticMessageText", | ||
| class_filter: None, | ||
| runtime: "js_typescript_flatten_diagnostic_message_text", | ||
| args: &[NA_F64, NA_STR, NA_F64], | ||
| ret: NR_STR, | ||
| }, | ||
| ]; |
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,26 @@ | ||
| [package] | ||
| name = "perry-ext-typescript" | ||
| version.workspace = true | ||
| edition.workspace = true | ||
| license.workspace = true | ||
| description = "Native TypeScript transpileModule compatibility subset for Perry" | ||
|
|
||
| [lints] | ||
| workspace = true | ||
|
|
||
| [lib] | ||
| crate-type = ["staticlib", "rlib"] | ||
|
|
||
| [dependencies] | ||
| perry-ffi.workspace = true | ||
| serde.workspace = true | ||
| serde_json.workspace = true | ||
| swc_common.workspace = true | ||
| swc_ecma_ast.workspace = true | ||
| swc_ecma_codegen.workspace = true | ||
| # Keep this aligned with the parser generation used by the SWC transform | ||
| # crates below so native applications do not link two parser copies. | ||
| swc_ecma_parser = "29.0" | ||
| swc_ecma_transforms_base.workspace = true | ||
| swc_ecma_transforms_react.workspace = true | ||
| swc_ecma_transforms_typescript.workspace = true |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Bump the workspace patch version.
Update
[workspace.package].versionand the**Current Version:**line above it before merge. This change adds a new native runtime module.As per coding guidelines, “Increment patch in
[workspace.package].versioninCargo.tomland the**Current Version:**line above.”🤖 Prompt for AI Agents
Source: Coding guidelines