Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
173 changes: 165 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,8 @@ swc_ecma_ast = "19.0"
swc_ecma_visit = "19.0"
swc_common = "18.0"
swc_ecma_codegen = "21.0"
swc_bundler = "37.0"
swc_ecma_loader = "18.0"
swc_ecma_transforms_base = "32.0"
swc_ecma_transforms_react = "35.0"
swc_ecma_transforms_typescript = "35.0"
Expand Down
7 changes: 7 additions & 0 deletions changelog.d/9602-bun-runtime-compiler.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
### Added

- Added the native `Bun.Transpiler` and in-memory `Bun.build` subsets used by
runtime hook modules, including TypeScript/JSX lowering, import scanning,
external modules, and `onResolve`/`onLoad` plugin hooks. Build failures now
return useful filename and source-position logs instead of terminating the
process. (#9602)
7 changes: 7 additions & 0 deletions crates/perry-api-manifest/src/entries/part_4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1100,6 +1100,13 @@ pub(crate) const API_MANIFEST_PART_4: &[ApiEntry] = &[
// (Zig-std wyhash, BigInt result), and the module-level
// `pathToFileURL` / `fileURLToPath` aliases of node:url.
// Implementation: perry-runtime `bun_compat`.
class("bun", "Transpiler"),
method("bun", "Transpiler", false, None),
method("bun", "build", false, None),
method("bun", "transformSync", true, Some("Transpiler")),
method("bun", "transform", true, Some("Transpiler")),
method("bun", "scanImports", true, Some("Transpiler")),
method("bun", "scan", true, Some("Transpiler")),
method("bun", "stringWidth", false, None),
method("bun", "hash", false, None),
method("bun", "file", false, None),
Expand Down
3 changes: 3 additions & 0 deletions crates/perry-codegen/src/ext_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,9 @@ const EXT_PREFIX_REGISTRY: &[(&str, &str)] = &[
("js_node_forge_", "node-forge"),
// Native runtime TypeScript transpilation subset (#8511).
("js_typescript_", "typescript"),
// Bun runtime transpilation/build subset shares the pinned SWC wrapper.
("js_bun_transpiler_", "typescript"),
("js_bun_build", "typescript"),
("js_qs_", "qs"),
];

Expand Down
9 changes: 9 additions & 0 deletions crates/perry-codegen/src/lower_call/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ pub(super) fn lower_builtin_new<'a>(
"Decimal" => Some(&["decimal.js"]),
"RateLimiterMemory" => Some(&["rate-limiter-flexible"]),
"CronJob" => Some(&["cron", "node-cron"]),
"Transpiler" => Some(&["bun"]),
_ => None,
};
if let Some(sources) = required_sources {
Expand All @@ -133,6 +134,14 @@ pub(super) fn lower_builtin_new<'a>(
}
}
match class_name {
"Transpiler" => {
let options = adopt_leading_arg_discard_rest(ctx, args, group)?;
ctx.pending_declares
.push(("js_bun_transpiler_new".to_string(), I64, vec![DOUBLE]));
let block = ctx.block();
let handle = block.call(I64, "js_bun_transpiler_new", &[(DOUBLE, &options)]);
Ok(Some(nanbox_pointer_inline(block, &handle)))
}
"Resolver"
if import_src.is_some_and(|source| {
matches!(
Expand Down
Loading
Loading