From 32f2ef795447e97d48d8d7b28cf5fd36ef2389dc Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 28 Oct 2024 00:16:21 +0800 Subject: [PATCH] chore(deps): update rust crates (#13) --- Cargo.lock | 288 +++++++++++++++++++++++++++------- Cargo.toml | 15 +- napi/transform/Cargo.toml | 1 + napi/transform/src/lib.rs | 56 +++---- napi/transform/src/options.rs | 12 +- 5 files changed, 270 insertions(+), 102 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1ef7bf7..9d4482d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -59,6 +59,12 @@ dependencies = [ "rustc-demangle", ] +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + [[package]] name = "base64-simd" version = "0.8.0" @@ -75,6 +81,15 @@ version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + [[package]] name = "bumpalo" version = "3.16.0" @@ -128,12 +143,37 @@ dependencies = [ "unicode-segmentation", ] +[[package]] +name = "cow-utils" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "417bef24afe1460300965a25ff4a24b8b45ad011948302ec221e8a0a81eb2c79" + +[[package]] +name = "cpufeatures" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" +dependencies = [ + "libc", +] + [[package]] name = "crossbeam-utils" version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + [[package]] name = "ctor" version = "0.2.8" @@ -152,13 +192,13 @@ checksum = "63b7ef7a4be509357f4804d0a22e830daddb48f19fd604e4ad32ddce04a94c36" [[package]] name = "dashmap" -version = "6.0.1" +version = "6.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "804c8821570c3f8b70230c2ba75ffa5c0f9a4189b9a432b6656c536712acae28" +checksum = "5041cc499144891f3790297212f32a74fb938e5136a14943f338ef9e0ae276cf" dependencies = [ "cfg-if", "crossbeam-utils", - "hashbrown", + "hashbrown 0.14.5", "lock_api", "once_cell", "parking_lot_core", @@ -173,6 +213,16 @@ dependencies = [ "powerfmt", ] +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", +] + [[package]] name = "either" version = "1.13.0" @@ -191,6 +241,16 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + [[package]] name = "gimli" version = "0.29.0" @@ -203,14 +263,20 @@ version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +[[package]] +name = "hashbrown" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" + [[package]] name = "indexmap" -version = "2.2.6" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" dependencies = [ "equivalent", - "hashbrown", + "hashbrown 0.15.0", ] [[package]] @@ -280,7 +346,7 @@ dependencies = [ "owo-colors", "textwrap", "thiserror", - "unicode-width", + "unicode-width 0.1.13", ] [[package]] @@ -428,9 +494,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.19.0" +version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "outref" @@ -440,15 +506,15 @@ checksum = "4030760ffd992bef45b0ae3f10ce1aba99e33464c90d14dd7c039884963ddc7a" [[package]] name = "owo-colors" -version = "4.0.0" +version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "caff54706df99d2a78a5a4e3455ff45448d81ef1bb63c22cd14052ca0e993a3f" +checksum = "fb37767f6569cd834a413442455e0f066d0d522de8630436e2a1761d9726ba56" [[package]] name = "oxc-browserslist" -version = "1.0.1" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d67676f247b63c0f6a8ed20f6c1faa39ff5e0e4af923284a0857623eec5ab14" +checksum = "50b5ad390a7cf69d5f574ea41eada88a7c0947272647703fe1ec6ce23bfe1714" dependencies = [ "nom", "rustc-hash", @@ -469,6 +535,7 @@ dependencies = [ "oxc_allocator", "oxc_codegen", "oxc_parser", + "oxc_semantic", "oxc_sourcemap", "oxc_span", "oxc_syntax", @@ -478,9 +545,9 @@ dependencies = [ [[package]] name = "oxc_allocator" -version = "0.22.1" +version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d13ede3c9a61af2e332001f8e67be54b7607df9c373996c94da6976efba49122" +checksum = "b5c86018e4c158687698514494cb02b48b0367fd63e463c7b3846e565df53f46" dependencies = [ "allocator-api2", "bumpalo", @@ -488,32 +555,41 @@ dependencies = [ [[package]] name = "oxc_ast" -version = "0.22.1" +version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5046087d4fab69a6fc1f15668186b391a1387f207557d38dd6881eb12660c269" +checksum = "761ab257d19f07de7f91bab40fd7b232e6e0c68164b9086434f416e960f28149" dependencies = [ "bitflags", "num-bigint", "oxc_allocator", "oxc_ast_macros", + "oxc_estree", + "oxc_regular_expression", "oxc_span", "oxc_syntax", ] [[package]] name = "oxc_ast_macros" -version = "0.22.1" +version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d7b8dbb7a3c8b5b7900aec7d108fe5d0343466e8329173c93af9321ab84fb9a" +checksum = "a58d52ec144ec10c6c890a5356f7859510aa37e3e2839abd91e419969628302e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] [[package]] name = "oxc_cfg" -version = "0.22.1" +version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9a7b81fdb8e1f2af4c63b6702d4f6ebb208b56cbc578867141765c5644e974a" +checksum = "ef63e4a5b26bbc51cae765e1ee2d882f9f8e1e70c1675d28ac264575962b4eb5" dependencies = [ "bitflags", "itertools", + "nonmax", + "oxc_index", "oxc_syntax", "petgraph", "rustc-hash", @@ -521,15 +597,19 @@ dependencies = [ [[package]] name = "oxc_codegen" -version = "0.22.1" +version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9deac95708228d42a22c974eb1f854f6e28e0da8a4d2f8303cbcdc638f9e11d2" +checksum = "56b92d5e14118de64196e8e8557aad2bf5ff6fca36e8cd723409fcbaf1d40710" dependencies = [ + "assert-unchecked", "bitflags", + "cow-utils", "daachorse", + "nonmax", "once_cell", "oxc_allocator", "oxc_ast", + "oxc_index", "oxc_mangler", "oxc_sourcemap", "oxc_span", @@ -537,29 +617,58 @@ dependencies = [ "rustc-hash", ] +[[package]] +name = "oxc_data_structures" +version = "0.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5151a87b8bb4b6ea4110b37b2737ab10bdd1012ea8a1600e07a45e4069465c05" +dependencies = [ + "assert-unchecked", +] + [[package]] name = "oxc_diagnostics" -version = "0.22.1" +version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48bff61a24cf90580dece1f2d004bd76cfcf37745035950ba0d9a5c7608bb68c" +checksum = "980c673834c9b2fa15eb2692d418df45c84294771fd364ab53f9abdf4d3e874b" dependencies = [ "miette", "owo-colors", + "rustc-hash", "textwrap", - "unicode-width", + "unicode-width 0.2.0", +] + +[[package]] +name = "oxc_ecmascript" +version = "0.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20243d6de6301a5265c85d9d8007bf3044be5311906ba1686570de67743904a3" +dependencies = [ + "num-bigint", + "num-traits", + "oxc_ast", + "oxc_span", + "oxc_syntax", ] +[[package]] +name = "oxc_estree" +version = "0.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c30428989d3af8c8d868ec5fdd3e227865bbf7bc875e47785de368968282234" + [[package]] name = "oxc_index" -version = "0.22.1" +version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25d04d5746cd2616b79ea741cc5a695ac1b797bb2e576fcc044f5cda9ba314cd" +checksum = "2c33b9c780ed9ea47548248450b04da65b1e4e8023157403c37407a3210b675a" [[package]] name = "oxc_mangler" -version = "0.22.1" +version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5e8492b398709a6ab6fca6e062a0d4d06bc7ae42231d9a86771c1904ae95c86" +checksum = "a175f7b6873f7fd9df0de6fe11e5769622f8b8dacc31f9a92339208a0b804934" dependencies = [ "itertools", "oxc_ast", @@ -570,29 +679,48 @@ dependencies = [ [[package]] name = "oxc_parser" -version = "0.22.1" +version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dba92420b066218b244f2856af5af8aa4ba215a5780105915ecf0f5b88bb2ea7" +checksum = "22251ed2d64a743481450f64e5d279193165b637dc3dce6f5eaa3eeb494d470b" dependencies = [ "assert-unchecked", "bitflags", + "cow-utils", "memchr", "num-bigint", "num-traits", "oxc_allocator", "oxc_ast", "oxc_diagnostics", + "oxc_ecmascript", + "oxc_regular_expression", "oxc_span", "oxc_syntax", "rustc-hash", "seq-macro", ] +[[package]] +name = "oxc_regular_expression" +version = "0.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbd944dbd4a2b479bda4e29472e1489bb3abd9efbf8a84397fbe3259944b39b4" +dependencies = [ + "oxc_allocator", + "oxc_ast_macros", + "oxc_diagnostics", + "oxc_estree", + "oxc_span", + "phf", + "rustc-hash", + "unicode-id-start", +] + [[package]] name = "oxc_semantic" -version = "0.22.1" +version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16da734c361ac978deeb27ce43050774a92468c8e9699c0732f398d518434259" +checksum = "7693d8e4f47f3b9346dc828fc0ac2f2cc0c795efc633d3c9516981e689c8c655" dependencies = [ "assert-unchecked", "indexmap", @@ -601,6 +729,7 @@ dependencies = [ "oxc_ast", "oxc_cfg", "oxc_diagnostics", + "oxc_ecmascript", "oxc_index", "oxc_span", "oxc_syntax", @@ -610,12 +739,13 @@ dependencies = [ [[package]] name = "oxc_sourcemap" -version = "0.22.1" +version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e2d56cf04135d358d7a786415f315d2bb06c1d8bac367f2b4d526f3e8130a75" +checksum = "6e5eac041bff0e4392790431f54fc9bf8f0d37de68c22cac52f05219dd466d70" dependencies = [ "base64-simd", "cfg-if", + "cow-utils", "rustc-hash", "serde", "serde_json", @@ -623,24 +753,30 @@ dependencies = [ [[package]] name = "oxc_span" -version = "0.22.1" +version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "390f25de067cef1c993dedc5deefaa7f20acd9cac73a50f3744c8f68ad779218" +checksum = "74ea8734bdf818608fe5b92322ef1ad56c56896d83052b5d477f0197d09e7f15" dependencies = [ "compact_str", "miette", "oxc_allocator", + "oxc_ast_macros", + "oxc_estree", ] [[package]] name = "oxc_syntax" -version = "0.22.1" +version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe2f97996eb9126d75242aeda761640407497925107d09c9872aa92c6c5566de" +checksum = "14ecf5a5134b738088f1a56fbae78aa4e478b07f27b5f4db3c07734e0c9e005a" dependencies = [ + "assert-unchecked", "bitflags", "dashmap", "nonmax", + "oxc_allocator", + "oxc_ast_macros", + "oxc_estree", "oxc_index", "oxc_span", "phf", @@ -651,16 +787,23 @@ dependencies = [ [[package]] name = "oxc_transformer" -version = "0.22.1" +version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a33bf7e9bb3b5f711d626088d828428d0754d14a79629f27f3c5fc9035be447b" +checksum = "0cb03752e690f591d438c3b579e8db4add14251381168d6d9800076fa3044b84" dependencies = [ + "base64", + "cow-utils", "dashmap", "indexmap", + "itoa", "oxc-browserslist", "oxc_allocator", "oxc_ast", + "oxc_data_structures", "oxc_diagnostics", + "oxc_ecmascript", + "oxc_parser", + "oxc_regular_expression", "oxc_semantic", "oxc_span", "oxc_syntax", @@ -669,21 +812,26 @@ dependencies = [ "rustc-hash", "serde", "serde_json", + "sha1", ] [[package]] name = "oxc_traverse" -version = "0.22.1" +version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd175c87038baaad470973416ae9a271be36f6c0f8dffe76c0410838dabe5eda" +checksum = "30936f5767aecd22718c2fe2346d5a332fae9bbfbc6cc23ee62042e5ede57ca4" dependencies = [ "compact_str", + "itoa", "memoffset", "oxc_allocator", "oxc_ast", + "oxc_data_structures", + "oxc_ecmascript", "oxc_semantic", "oxc_span", "oxc_syntax", + "rustc-hash", ] [[package]] @@ -894,18 +1042,18 @@ checksum = "a3f0bf26fd526d2a95683cd0f87bf103b8539e2ca1ef48ce002d67aad59aa0b4" [[package]] name = "serde" -version = "1.0.203" +version = "1.0.213" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +checksum = "3ea7893ff5e2466df8d720bb615088341b295f849602c6956047f8f80f0e9bc1" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.203" +version = "1.0.213" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +checksum = "7e85ad2009c50b58e87caa8cd6dac16bdf511bbfb7af6c33df902396aa480fa5" dependencies = [ "proc-macro2", "quote", @@ -914,15 +1062,27 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.118" +version = "1.0.132" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d947f6b3163d8857ea16c4fa0dd4840d52f3041039a85decd46867eb1abef2e4" +checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] +[[package]] +name = "sha1" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + [[package]] name = "siphasher" version = "0.3.11" @@ -955,9 +1115,9 @@ checksum = "e9557cb6521e8d009c51a8666f09356f4b817ba9ba0981a305bd86aee47bd35c" [[package]] name = "syn" -version = "2.0.68" +version = "2.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "901fa70d88b9d6c98022e23b4136f9f3e54e4662c3bc1bd1d84a42a9a0f0c1e9" +checksum = "5023162dfcd14ef8f32034d8bcd4cc5ddc61ef7a247c024a33e24e1f24d21b56" dependencies = [ "proc-macro2", "quote", @@ -972,7 +1132,7 @@ checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" dependencies = [ "smawk", "unicode-linebreak", - "unicode-width", + "unicode-width 0.1.13", ] [[package]] @@ -1016,14 +1176,20 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "tokio" -version = "1.39.2" +version = "1.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daa4fb1bc778bd6f04cbfc4bb2d06a7396a8f299dc33ea1900cedaa316f467b1" +checksum = "145f3413504347a2be84393cc8a7d2fb4d863b375909ea59f2158261aa258bbb" dependencies = [ "backtrace", "pin-project-lite", ] +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + [[package]] name = "unicode-id-start" version = "1.1.2" @@ -1054,6 +1220,18 @@ version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" +[[package]] +name = "unicode-width" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + [[package]] name = "vsimd" version = "0.8.0" diff --git a/Cargo.toml b/Cargo.toml index 6a0528b..92d84c9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,13 +11,14 @@ license = "MIT" rust-version = "1.77" [workspace.dependencies] -oxc_allocator = { version = "0.22.0" } -oxc_codegen = { version = "0.22.0" } -oxc_parser = { version = "0.22.0" } -oxc_sourcemap = { version = "0.22.0" } -oxc_span = { version = "0.22.0" } -oxc_syntax = { version = "0.22.0" } -oxc_transformer = { version = "0.22.0" } +oxc_allocator = { version = "0.34.0" } +oxc_codegen = { version = "0.34.0" } +oxc_parser = { version = "0.34.0" } +oxc_sourcemap = { version = "0.34.0" } +oxc_span = { version = "0.34.0" } +oxc_syntax = { version = "0.34.0" } +oxc_transformer = { version = "0.34.0" } +oxc_semantic = { version = "0.34.0" } itertools = { version = "0.13.0" } tokio = { version = "1.38.0", features = ["rt-multi-thread"] } diff --git a/napi/transform/Cargo.toml b/napi/transform/Cargo.toml index 314389f..498eb14 100644 --- a/napi/transform/Cargo.toml +++ b/napi/transform/Cargo.toml @@ -20,6 +20,7 @@ oxc_sourcemap = { workspace = true } oxc_span = { workspace = true } oxc_syntax = { workspace = true } oxc_transformer = { workspace = true } +oxc_semantic = { workspace = true } itertools = { workspace = true } tokio = { workspace = true } diff --git a/napi/transform/src/lib.rs b/napi/transform/src/lib.rs index 7ac3c7a..f0c68c1 100644 --- a/napi/transform/src/lib.rs +++ b/napi/transform/src/lib.rs @@ -9,8 +9,9 @@ use std::path::Path; use napi::{Error, Status}; use oxc_allocator::Allocator; -use oxc_codegen::{Codegen, CodegenReturn}; +use oxc_codegen::{CodeGenerator, CodegenOptions, CodegenReturn}; use oxc_parser::Parser; +use oxc_semantic::SemanticBuilder; use oxc_sourcemap::SourceMap as OxcSourceMap; use oxc_span::SourceType; use oxc_transformer::Transformer; @@ -55,9 +56,7 @@ pub struct SourceMap { impl TryFrom for SourceMap { type Error = napi::Error; fn try_from(sourcemap: OxcSourceMap) -> Result { - let mappings = sourcemap - .to_json_string() - .map_err(|e| Error::from_reason(format!("{e}")))?; + let mappings = sourcemap.to_json_string(); // TODO: do not clone once fields are exposed from oxc_sourcemap Ok(Self { file: sourcemap.get_file().map(ToString::to_string), @@ -89,13 +88,12 @@ pub fn transform( ) -> Result { let options = options.unwrap_or_default(); let source_type = - SourceType::from_path(&filename).map_err(|err| Error::new(Status::InvalidArg, err.0))?; + SourceType::from_path(&filename).map_err(|err| Error::new(Status::InvalidArg, err))?; let allocator = Allocator::default(); let parser_ret = Parser::new(&allocator, &source_text, source_type).parse(); let errors = parser_ret.errors; let mut program = parser_ret.program; - let trivias = parser_ret.trivias; if !errors.is_empty() { let errors = errors @@ -107,43 +105,33 @@ pub fn transform( return Err(Error::new(Status::GenericFailure, message)); } + let (symbols, scopes) = SemanticBuilder::new() + .build(&program) + .semantic + .into_symbol_table_and_scope_tree(); let path = Path::new(&filename); let transform_options = options.clone().into(); - let ret = Transformer::new( - &allocator, - path, - source_type, - &source_text, - trivias, - transform_options, - ) - .build(&mut program); + let ret = Transformer::new(&allocator, path, transform_options).build_with_symbols_and_scopes( + symbols, + scopes, + &mut program, + ); if !ret.errors.is_empty() { return Err(Error::from_reason(format!("{}", ret.errors[0]))); } // TODO: source maps before transforming - let CodegenReturn { - source_text, - source_map, - } = if options.codegen.compress.is_some() { - let mut codegen = Codegen::::new(); - if options.codegen.source_map { - codegen = codegen.enable_source_map(&filename, &source_text) - } - codegen.build(&program) - } else { - let mut codegen = Codegen::::new(); - if options.codegen.source_map { - codegen = codegen.enable_source_map(&filename, &source_text) - } - codegen.build(&program) - }; - - let _source_map = source_map.map(SourceMap::try_from).transpose()?; + let CodegenReturn { code, map } = CodeGenerator::new() + .with_options(CodegenOptions { + source_map_path: Some(path.to_path_buf()), + ..CodegenOptions::default() + }) + .build(&program); + + let _source_map = map.map(SourceMap::try_from).transpose()?; Ok(TransformResult { - source_text, + source_text: code, // source_map: source_map.map(SourceMap::from), source_map: None, }) diff --git a/napi/transform/src/options.rs b/napi/transform/src/options.rs index c1d98b6..ffc0047 100644 --- a/napi/transform/src/options.rs +++ b/napi/transform/src/options.rs @@ -1,5 +1,5 @@ use napi::{bindgen_prelude::*, ValueType}; -use oxc_transformer::{ReactJsxRuntime, ReactOptions, TransformOptions}; +use oxc_transformer::{JsxOptions, JsxRuntime, TransformOptions}; #[napi(object, js_name = "TransformOptions")] #[derive(Debug, Default, Clone)] @@ -13,7 +13,7 @@ pub struct JsTransformOptions { impl From for TransformOptions { fn from(options: JsTransformOptions) -> Self { Self { - react: options.react.into(), + jsx: options.react.into(), ..Default::default() } } @@ -133,7 +133,7 @@ pub struct JsReactOptions { pub runtime: JsReactJsxRuntime, } -impl From for ReactOptions { +impl From for JsxOptions { fn from(options: JsReactOptions) -> Self { Self { runtime: options.runtime.into(), @@ -150,11 +150,11 @@ pub enum JsReactJsxRuntime { #[default] Automatic, } -impl From for ReactJsxRuntime { +impl From for JsxRuntime { fn from(runtime: JsReactJsxRuntime) -> Self { match runtime { - JsReactJsxRuntime::Classic => ReactJsxRuntime::Classic, - JsReactJsxRuntime::Automatic => ReactJsxRuntime::Automatic, + JsReactJsxRuntime::Classic => JsxRuntime::Classic, + JsReactJsxRuntime::Automatic => JsxRuntime::Automatic, } } }