diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c236fd4..105dfc2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,10 +11,10 @@ concurrency: cancel-in-progress: true jobs: test: - permissions: - contents: read - id-token: write - runs-on: ubuntu-latest + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + runs-on: ${{ matrix.os }} timeout-minutes: 30 steps: - uses: actions/checkout@v4 @@ -22,17 +22,19 @@ jobs: - uses: Swatinem/rust-cache@v2 - uses: denoland/setup-deno@v2 with: - deno-version: ~2.x + deno-version: 2.x - uses: actions/setup-node@v4 with: node-version: "20" registry-url: "https://registry.npmjs.org" - name: Format + if: matrix.os == 'ubuntu-latest' run: | cargo fmt --all -- --check deno fmt --check - name: Lint (Cargo) + if: matrix.os == 'ubuntu-latest' run: cargo clippy --all-targets --all-features --release - name: Build @@ -43,5 +45,22 @@ jobs: run: cargo test --all-targets --all-features --release - name: Test (Deno) run: deno task test + + jsr: + runs-on: ubuntu-latest + timeout-minutes: 30 + permissions: + contents: read + id-token: write + steps: + - uses: actions/checkout@v4 + - uses: dsherret/rust-toolchain-file@v1 + - uses: Swatinem/rust-cache@v2 + - uses: denoland/setup-deno@v2 + with: + deno-version: 2.x + + - name: Build + run: deno task build - name: Publish on tag run: deno run -A jsr:@david/publish-on-tag@0.2.0 diff --git a/Cargo.lock b/Cargo.lock index d7f6d57..5b5a862 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -414,17 +414,16 @@ dependencies = [ [[package]] name = "deno_ast" -version = "0.46.6" +version = "0.48.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cef7f606485e5e5fdee9946d5822de9242d8143da9beb1c32cbaf2e8dd1ef025" +checksum = "0ced09fdb8884e29716cc0691e8510f9c655762bbb9da3111dacc0a2ef6e8960" dependencies = [ "base64 0.22.1", "capacity_builder", - "deno_error", + "deno_error 0.6.1", "deno_media_type", "deno_terminal", "dprint-swc-ext", - "once_cell", "percent-encoding", "serde", "sourcemap", @@ -443,16 +442,16 @@ dependencies = [ "swc_visit", "swc_visit_macros", "text_lines", - "thiserror 2.0.12", + "thiserror", "unicode-width 0.2.0", "url", ] [[package]] name = "deno_cache_dir" -version = "0.20.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "869a62459ded73382e018c7c58a07df170ba5f5befb67e18ee10494e769efe2a" +checksum = "7825da0551e670a270a3a20b92f8a0bffeb7d6120fa86b64e5daa969b8dd1a10" dependencies = [ "async-trait", "base32", @@ -461,7 +460,7 @@ dependencies = [ "cache_control", "chrono", "data-url", - "deno_error", + "deno_error 0.6.1", "deno_media_type", "deno_path_util", "http 1.3.1", @@ -473,34 +472,32 @@ dependencies = [ "serde_json", "sha2", "sys_traits", - "thiserror 1.0.69", + "thiserror", "url", ] [[package]] name = "deno_config" -version = "0.54.2" +version = "0.61.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35a3ff33a35a2e995bfea372cbe9fe0990a735e27988a787277a1c6ee15d1b1a" +checksum = "ee8ce54588354b9149710db8439b8acb1f3c6722d3a007fcc39a651d0b00d15e" dependencies = [ "boxed_error", "capacity_builder", - "deno_error", + "deno_error 0.6.1", "deno_package_json", "deno_path_util", - "deno_semver", + "deno_semver 0.8.1", "glob", "ignore", "import_map", "indexmap", "jsonc-parser", "log", - "percent-encoding", - "phf", "serde", "serde_json", "sys_traits", - "thiserror 2.0.12", + "thiserror", "url", ] @@ -510,7 +507,17 @@ version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19fae9fe305307b5ef3ee4e8244c79cffcca421ab0ce8634dea0c6b1342f220f" dependencies = [ - "deno_error_macro", + "deno_error_macro 0.5.6", + "libc", +] + +[[package]] +name = "deno_error" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "612ec3fc481fea759141b0c57810889b0a4fb6fee8f10748677bfe492fd30486" +dependencies = [ + "deno_error_macro 0.6.1", "libc", "serde", "serde_json", @@ -528,22 +535,33 @@ dependencies = [ "syn", ] +[[package]] +name = "deno_error_macro" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8380a4224d5d2c3f84da4d764c4326cac62e9a1e3d4960442d29136fc07be863" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "deno_graph" -version = "0.90.0" +version = "0.96.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63892e3d2eaf61633ecc1046340f862f295e7ad04d75522517e9a2505a158c4e" +checksum = "0733ed99295ebeddeb0fb33efa41ccd47ccd9481ab1ebe01f2ea8af80204479e" dependencies = [ "async-trait", + "boxed_error", "capacity_builder", "data-url", "deno_ast", - "deno_error", + "deno_error 0.6.1", "deno_media_type", "deno_path_util", - "deno_semver", + "deno_semver 0.8.1", "deno_unsync", - "encoding_rs", "futures", "import_map", "indexmap", @@ -556,29 +574,29 @@ dependencies = [ "serde_json", "sha2", "sys_traits", - "thiserror 2.0.12", + "thiserror", "url", "wasm_dep_analyzer", ] [[package]] name = "deno_lockfile" -version = "0.28.0" +version = "0.30.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a03d93aa789e2652a644e3e71638b4e21faafad5f7392dc8f126589d158695" +checksum = "0d4346e56cda020df5da35a3ec2624f09bd77c9f5ed18d903915007825fe9d3f" dependencies = [ "async-trait", - "deno_semver", + "deno_semver 0.8.1", "serde", "serde_json", - "thiserror 2.0.12", + "thiserror", ] [[package]] name = "deno_media_type" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d9080fcfcea53bcd6eea1916217bd5611c896f3a0db4c001a859722a1258a47" +checksum = "f0ec0dada9dc5ac4733b4175d36f6a150b7dd68fab46db35cb1ef00dd7366acb" dependencies = [ "data-url", "encoding_rs", @@ -595,14 +613,15 @@ dependencies = [ "base64 0.13.1", "deno_ast", "deno_config", - "deno_error", + "deno_error 0.6.1", "deno_graph", "deno_path_util", "deno_resolver", - "deno_semver", + "deno_semver 0.7.1", "futures", "import_map", "jsonc-parser", + "node_resolver", "once_cell", "pathdiff", "pretty_assertions", @@ -617,60 +636,90 @@ dependencies = [ [[package]] name = "deno_npm" -version = "0.33.2" +version = "0.35.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5217eb9aaebd02e92baeea7b474ca3f663b611204ccbfba11f8d296be08abe69" +checksum = "536a02c258d4a3fcbbbb898562e230bbe5939ac2eb7c2058718508304e4ab7cf" dependencies = [ "async-trait", "capacity_builder", - "deno_error", + "deno_error 0.6.1", "deno_lockfile", - "deno_semver", + "deno_semver 0.8.1", "futures", "indexmap", "log", "monch", "serde", "serde_json", - "thiserror 2.0.12", + "thiserror", "url", ] [[package]] name = "deno_package_json" -version = "0.6.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "236bc2d6d6c06b68cbde960542e13501cf833c975f221a012da619f714c57123" +checksum = "2c0ec78660b920021d97d158440f09455393b63c965b32d55a7e940a0e9a0a3e" dependencies = [ "boxed_error", - "deno_error", + "deno_error 0.6.1", "deno_path_util", - "deno_semver", + "deno_semver 0.8.1", "indexmap", "serde", "serde_json", "sys_traits", - "thiserror 2.0.12", + "thiserror", "url", ] [[package]] name = "deno_path_util" -version = "0.3.2" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "516f813389095889776b81cc9108ff6f336fd9409b4b12fc0138aea23d2708e1" +dependencies = [ + "deno_error 0.6.1", + "percent-encoding", + "sys_traits", + "thiserror", + "url", +] + +[[package]] +name = "deno_permissions" +version = "0.70.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c238a664a0a6f1ce0ff2b73c6854811526d00f442a12f878cb8555b23fe13aa3" +checksum = "7609d9ec89c3018e9a4d14923cc0121da00c0241859c35a4bc8a0834f2a35d8e" dependencies = [ - "deno_error", + "capacity_builder", + "deno_error 0.6.1", + "deno_path_util", + "deno_terminal", + "deno_unsync", + "fqdn", + "ipnetwork", + "libc", + "log", + "nix", + "once_cell", + "parking_lot", "percent-encoding", + "serde", + "serde_json", "sys_traits", - "thiserror 2.0.12", + "thiserror", "url", + "which", + "winapi", + "windows-sys 0.59.0", ] [[package]] name = "deno_resolver" -version = "0.35.0" -source = "git+https://github.com/denoland/deno?rev=59ffc1987c67f570e2081457c898efe51c872945#59ffc1987c67f570e2081457c898efe51c872945" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1813a4562fd598fbb5e9d3112391f22382f9feff6573668dc768b5e65eca5cf9" dependencies = [ "anyhow", "async-once-cell", @@ -679,26 +728,33 @@ dependencies = [ "boxed_error", "deno_cache_dir", "deno_config", - "deno_error", + "deno_error 0.6.1", "deno_graph", + "deno_lockfile", "deno_media_type", "deno_npm", "deno_package_json", "deno_path_util", - "deno_semver", + "deno_permissions", + "deno_semver 0.8.1", "deno_terminal", "deno_unsync", + "dissimilar", "futures", + "http 1.3.1", "import_map", "indexmap", + "jsonc-parser", "log", "node_resolver", "once_cell", "parking_lot", + "phf", "serde", "serde_json", "sys_traits", - "thiserror 2.0.12", + "thiserror", + "twox-hash", "url", ] @@ -709,13 +765,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4775271f9b5602482698f76d24ea9ed8ba27af7f587a7e9a876916300c542435" dependencies = [ "capacity_builder", - "deno_error", + "deno_error 0.5.6", + "ecow", + "hipstr", + "monch", + "once_cell", + "serde", + "thiserror", + "url", +] + +[[package]] +name = "deno_semver" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a7123b11b66cf19e023372bfcb137498243ef32dd73c725b938c118ac9943f5" +dependencies = [ + "capacity_builder", + "deno_error 0.6.1", "ecow", "hipstr", "monch", "once_cell", "serde", - "thiserror 2.0.12", + "thiserror", "url", ] @@ -731,11 +804,11 @@ dependencies = [ [[package]] name = "deno_unsync" -version = "0.4.2" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d774fd83f26b24f0805a6ab8b26834a0d06ceac0db517b769b1e4633c96a2057" +checksum = "6742a724e8becb372a74c650a1aefb8924a5b8107f7d75b3848763ea24b27a87" dependencies = [ - "futures", + "futures-util", "parking_lot", "tokio", ] @@ -767,6 +840,12 @@ dependencies = [ "syn", ] +[[package]] +name = "dissimilar" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59f8e79d1fbf76bdfbde321e902714bf6c49df88a7dda6fc682fc2979226962d" + [[package]] name = "dnt-wasm" version = "0.0.0" @@ -774,7 +853,7 @@ dependencies = [ "anyhow", "console_error_panic_hook", "deno_config", - "deno_error", + "deno_error 0.6.1", "deno_node_transform", "deno_path_util", "getrandom 0.2.16", @@ -788,9 +867,9 @@ dependencies = [ [[package]] name = "dprint-swc-ext" -version = "0.23.0" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "569b85f94c1e7d1065874115193cf081d658ebb01213d54fda357516837a17fc" +checksum = "9a09827d6db1a3af25e105553d674ee9019be58fa3d6745c2a2803f8ce8e3eb8" dependencies = [ "allocator-api2", "bumpalo", @@ -879,6 +958,12 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "fqdn" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb540cf7bc4fe6df9d8f7f0c974cfd0dce8ed4e9e8884e73433b503ee78b4e7d" + [[package]] name = "from_variant" version = "2.0.0" @@ -1362,18 +1447,18 @@ dependencies = [ [[package]] name = "import_map" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1215d4d92511fbbdaea50e750e91f2429598ef817f02b579158e92803b52c00a" +checksum = "f315e535cb94a0e80704278d630990bb48834c8c8d976acf0a2f6bc8fede7c38" dependencies = [ "boxed_error", - "deno_error", + "deno_error 0.6.1", "indexmap", "log", "percent-encoding", "serde", "serde_json", - "thiserror 2.0.12", + "thiserror", "url", ] @@ -1394,6 +1479,15 @@ version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" +[[package]] +name = "ipnetwork" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf466541e9d546596ee94f9f69590f89473455f88372423e0008fc1a7daf100e" +dependencies = [ + "serde", +] + [[package]] name = "is-macro" version = "0.3.7" @@ -1414,10 +1508,11 @@ checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" [[package]] name = "js-sys" -version = "0.3.69" +version = "0.3.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" +checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" dependencies = [ + "once_cell", "wasm-bindgen", ] @@ -1430,6 +1525,16 @@ dependencies = [ "serde_json", ] +[[package]] +name = "junction" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72bbdfd737a243da3dfc1f99ee8d6e166480f17ab4ac84d7c34aacd73fc7bd16" +dependencies = [ + "scopeguard", + "windows-sys 0.52.0", +] + [[package]] name = "lazy-regex" version = "3.4.1" @@ -1554,22 +1659,34 @@ version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" +[[package]] +name = "nix" +version = "0.27.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" +dependencies = [ + "bitflags 2.9.0", + "cfg-if", + "libc", +] + [[package]] name = "node_resolver" -version = "0.42.0" -source = "git+https://github.com/denoland/deno?rev=59ffc1987c67f570e2081457c898efe51c872945#59ffc1987c67f570e2081457c898efe51c872945" +version = "0.49.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8f7d49e392159082d2fe0081f14ba5b35705a782412beb559a9d1ef6b1463c0" dependencies = [ "anyhow", "async-trait", "boxed_error", "dashmap", "deno_config", - "deno_error", + "deno_error 0.6.1", "deno_graph", "deno_media_type", "deno_package_json", "deno_path_util", - "deno_semver", + "deno_semver 0.8.1", "futures", "lazy-regex", "once_cell", @@ -1578,7 +1695,7 @@ dependencies = [ "serde", "serde_json", "sys_traits", - "thiserror 2.0.12", + "thiserror", "url", ] @@ -2041,9 +2158,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.20" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2" +checksum = "8a0d197bd2c9dc6e53b84da9556a69ba4cdfab8619eb41a8bd1cc2027a0f6b1d" [[package]] name = "ryu" @@ -2131,9 +2248,9 @@ dependencies = [ [[package]] name = "serde-wasm-bindgen" -version = "0.5.0" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3b143e2833c57ab9ad3ea280d21fd34e285a42837aeb0ee301f4f41890fa00e" +checksum = "8302e169f0eddcc139c70f139d19d6467353af16f9fce27e8c30158036a1e16b" dependencies = [ "js-sys", "serde", @@ -2261,9 +2378,9 @@ dependencies = [ [[package]] name = "sourcemap" -version = "9.2.0" +version = "9.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd430118acc9fdd838557649b9b43fd0a78e3834d84a283b466f8e84720d6101" +checksum = "e22afbcb92ce02d23815b9795523c005cb9d3c214f8b7a66318541c240ea7935" dependencies = [ "base64-simd", "bitvec", @@ -2348,9 +2465,9 @@ dependencies = [ [[package]] name = "swc_common" -version = "8.1.1" +version = "9.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f8c8e4348383e4154f8d384cdad7e48f5d6d3daef78af376ac4e5ddbbf60c88" +checksum = "a56b6f5a8e5affa271b56757a93badee6f44defcd28f3ba106bb2603afe40d3d" dependencies = [ "anyhow", "ast_node", @@ -2376,9 +2493,9 @@ dependencies = [ [[package]] name = "swc_ecma_ast" -version = "8.1.2" +version = "9.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4062a54522a9c02d2b68cc09282774b87121cd48693b0e67ae8c18b31b709866" +checksum = "0613d84468a6bb6d45d13c5a3368b37bd21f3067a089f69adac630dcb462a018" dependencies = [ "bitflags 2.9.0", "is-macro", @@ -2397,9 +2514,9 @@ dependencies = [ [[package]] name = "swc_ecma_codegen" -version = "10.0.0" +version = "11.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b85453d346d0642f296c2b3aa204886a6ae2b9652262c3468d6f4556c1ed020d" +checksum = "b01b3de365a86b8f982cc162f257c82f84bda31d61084174a3be37e8ab15c0f4" dependencies = [ "ascii", "compact_str", @@ -2432,9 +2549,9 @@ dependencies = [ [[package]] name = "swc_ecma_lexer" -version = "11.1.3" +version = "12.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0d9ed10e3efa2230d0b3d0ad63c2e67d9b40c3892f31a865ad14d6fa881e0e9" +checksum = "0d11c8e71901401b9aae2ece4946eeb7674b14b8301a53768afbbeeb0e48b599" dependencies = [ "arrayvec", "bitflags 2.9.0", @@ -2457,9 +2574,9 @@ dependencies = [ [[package]] name = "swc_ecma_loader" -version = "8.0.0" +version = "9.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a801462c997b71e4add7684ce4953c7d6200c75b5552b8d594783da84ad9564c" +checksum = "8eb574d660c05f3483c984107452b386e45b95531bdb1253794077edc986f413" dependencies = [ "anyhow", "pathdiff", @@ -2472,9 +2589,9 @@ dependencies = [ [[package]] name = "swc_ecma_parser" -version = "11.1.3" +version = "12.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "398f4105e5fa3dedcefc58d068a5b2d8330cd4a36c4ae1ef2da83ed0a3e3c61f" +checksum = "250786944fbc05f6484eda9213df129ccfe17226ae9ad51b62fce2f72135dbee" dependencies = [ "arrayvec", "bitflags 2.9.0", @@ -2498,9 +2615,9 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_base" -version = "12.2.0" +version = "13.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b46e3a36213d78fb4233e596b8a5c81c6cdafe02d03d780eed006c983aa0a724" +checksum = "6856da3da598f4da001b7e4ce225ee8970bc9d5cbaafcaf580190cf0a6031ec5" dependencies = [ "better_scoped_tls", "bitflags 2.9.0", @@ -2522,9 +2639,9 @@ dependencies = [ [[package]] name = "swc_ecma_utils" -version = "12.0.1" +version = "13.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7c499ba586b784be6dfbdd76ebd3cfdbabaf43a5bda162a11fe7dd326670b62" +checksum = "7ed837406d5dbbfbf5792b1dc90964245a0cf659753d4745fe177ffebe8598b9" dependencies = [ "indexmap", "num_cpus", @@ -2543,9 +2660,9 @@ dependencies = [ [[package]] name = "swc_ecma_visit" -version = "8.0.0" +version = "9.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f7a65fa06d0c0f709f1df4e820ccdc4eca7b3db7f9d131545e20c2ac2f1cd23" +checksum = "249dc9eede1a4ad59a038f9cfd61ce67845bd2c1392ade3586d714e7181f3c1a" dependencies = [ "new_debug_unreachable", "num-bigint", @@ -2642,18 +2759,31 @@ dependencies = [ [[package]] name = "sys_traits" -version = "0.1.9" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3374191d43a934854e99a46cd47f8124369e690353e0f8db42769218d083690" +checksum = "4f74a2c95f72e36fa6bd04a40d15623a9904bab1cc2fa6c6135b09d774a65088" dependencies = [ "getrandom 0.2.16", "js-sys", + "junction", "libc", "parking_lot", + "sys_traits_macros", "wasm-bindgen", "windows-sys 0.59.0", ] +[[package]] +name = "sys_traits_macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "181f22127402abcf8ee5c83ccd5b408933fec36a6095cf82cda545634692657e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "system-configuration" version = "0.5.1" @@ -2712,33 +2842,13 @@ dependencies = [ "serde", ] -[[package]] -name = "thiserror" -version = "1.0.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" -dependencies = [ - "thiserror-impl 1.0.69", -] - [[package]] name = "thiserror" version = "2.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" dependencies = [ - "thiserror-impl 2.0.12", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" -dependencies = [ - "proc-macro2", - "quote", - "syn", + "thiserror-impl", ] [[package]] @@ -2867,6 +2977,12 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" +[[package]] +name = "twox-hash" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7b17f197b3050ba473acf9181f7b1d3b66d1cf7356c6cc57886662276e65908" + [[package]] name = "typed-arena" version = "2.0.2" @@ -2999,11 +3115,13 @@ dependencies = [ [[package]] name = "wasm-bindgen" -version = "0.2.92" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" +checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" dependencies = [ "cfg-if", + "once_cell", + "rustversion", "serde", "serde_json", "wasm-bindgen-macro", @@ -3011,13 +3129,12 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.92" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" +checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" dependencies = [ "bumpalo", "log", - "once_cell", "proc-macro2", "quote", "syn", @@ -3026,21 +3143,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.42" +version = "0.4.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" +checksum = "555d470ec0bc3bb57890405e5d4322cc9ea83cebb085523ced7be4144dac1e61" dependencies = [ "cfg-if", "js-sys", + "once_cell", "wasm-bindgen", "web-sys", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.92" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" +checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3048,9 +3166,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.92" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" +checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" dependencies = [ "proc-macro2", "quote", @@ -3061,30 +3179,55 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.92" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" +checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" +dependencies = [ + "unicode-ident", +] [[package]] name = "wasm_dep_analyzer" -version = "0.2.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2eeee3bdea6257cc36d756fa745a70f9d393571e47d69e0ed97581676a5369ca" +checksum = "e51cf5f08b357e64cd7642ab4bbeb11aecab9e15520692129624fb9908b8df2c" dependencies = [ - "deno_error", - "thiserror 2.0.12", + "deno_error 0.6.1", + "thiserror", ] [[package]] name = "web-sys" -version = "0.3.69" +version = "0.3.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" +checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2" dependencies = [ "js-sys", "wasm-bindgen", ] +[[package]] +name = "which" +version = "8.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3fabb953106c3c8eea8306e4393700d7657561cb43122571b172bbfb7c7ba1d" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + [[package]] name = "winapi-util" version = "0.1.9" @@ -3094,6 +3237,12 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + [[package]] name = "windows-sys" version = "0.48.0" diff --git a/Cargo.toml b/Cargo.toml index 05d4b1c..83fe099 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,13 +13,10 @@ members = [ [workspace.dependencies] async-trait = "0.1.88" -deno_config = "0.54.2" -deno_error = { version = "0.5.6", features = ["serde", "serde_json", "url"] } -deno_path_util = "0.3.2" -deno_resolver = { version = "0.35.0", features = ["graph"] } +deno_config = "0.61.0" +deno_error = { version = "0.6.1", features = ["serde", "serde_json", "url"] } +deno_path_util = "0.4.0" +deno_resolver = { version = "0.42.0", features = ["graph"] } serde_json = { version = "1.0.140", features = ["preserve_order"] } -sys_traits = { version = "0.1.9", features = ["real"] } +sys_traits = { version = "0.1.17", features = ["real"] } url = { version = "2.5.4", features =["serde"] } - -[patch.crates-io] -deno_resolver = { git = "https://github.com/denoland/deno", rev = "59ffc1987c67f570e2081457c898efe51c872945" } diff --git a/README.md b/README.md index 14252e5..8394625 100644 --- a/README.md +++ b/README.md @@ -542,7 +542,7 @@ Since the file you're calling is a script, simply add statements before and after the `await build({ ... })` statement: ```ts -import { build, emptyDir } from "https://deno.land/x/dnt/mod.ts"; +import { build, emptyDir } from "@deno/dnt"; // run pre-build steps here await emptyDir("./npm"); @@ -566,7 +566,7 @@ Deno tests run with. For example: ```ts -import { copy } from "https://deno.land/std@x.x.x/fs/mod.ts"; +import { copy } from "@std/fs"; await Deno.remove("npm", { recursive: true }).catch((_) => {}); await copy("testdata", "npm/esm/testdata", { overwrite: true }); @@ -734,10 +734,10 @@ For only the Deno to canonical TypeScript transform which may be useful for bundlers, use the following: ```ts -// docs: https://doc.deno.land/https/deno.land/x/dnt/transform.ts -import { transform } from "https://deno.land/x/dnt/transform.ts"; +// docs: https://jsr.io/@deno/dnt/doc/transform +import { transform } from "@deno/dnt/transform"; -const outputResult = await transform({ +const outputResult = transform({ entryPoints: ["./mod.ts"], testEntryPoints: ["./mod.test.ts"], shims: [], diff --git a/deno.jsonc b/deno.jsonc index 4423ffd..8580648 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -2,7 +2,7 @@ "name": "@deno/dnt", "tasks": { "test": "deno test -A", - "build": "deno run -A jsr:@deno/wasmbuild@0.17.2 --out lib/pkg" + "build": "deno run -A jsr:@deno/wasmbuild@0.19.2 --out lib/pkg" }, "lint": { "rules": { diff --git a/mod.ts b/mod.ts index e2c8e93..f0ff819 100644 --- a/mod.ts +++ b/mod.ts @@ -189,8 +189,6 @@ export interface BuildOptions { filterDiagnostic?: (diagnostic: ts.Diagnostic) => boolean; /** Action to do after emitting and before running tests. */ postBuild?: () => void | Promise; - /** Custom Wasm URL for the internal Wasm module used by dnt. */ - internalWasmUrl?: string; } /** Builds the specified Deno module to an npm package using the TypeScript compiler. */ @@ -590,7 +588,6 @@ export async function build(options: BuildOptions): Promise { target: scriptTarget, importMap: options.importMap, configFile: options.configFile, - internalWasmUrl: options.internalWasmUrl, cwd: path.toFileUrl(cwd).toString(), }); } diff --git a/rs-lib/Cargo.toml b/rs-lib/Cargo.toml index e3f0c10..ecd5754 100644 --- a/rs-lib/Cargo.toml +++ b/rs-lib/Cargo.toml @@ -16,15 +16,16 @@ serialization = ["serde"] anyhow = "1.0.70" async-trait.workspace = true base64 = "0.13.1" -deno_ast = { version = "0.46.6", features = ["transforms", "view", "visit", "utils"] } +deno_ast = { version = "0.48.1", features = ["transforms", "view", "visit", "utils"] } deno_config.workspace = true deno_error.workspace = true -deno_graph = { version = "0.90.0", features = [], default-features = false } +deno_graph = { version = "0.96.2", features = ["swc"], default-features = false } deno_path_util.workspace = true deno_resolver.workspace = true deno_semver = "0.7.1" +node_resolver = "0.49.0" futures = "0.3.25" -import_map = { version = "0.21.0", features = ["ext"] } +import_map = { version = "0.22.0", features = ["ext"] } jsonc-parser = { version = "0.26.2", features = ["serde"] } once_cell = "1.17.1" pathdiff = "0.2.1" diff --git a/rs-lib/src/declaration_file_resolution.rs b/rs-lib/src/declaration_file_resolution.rs index 9b8a4ad..f48867d 100644 --- a/rs-lib/src/declaration_file_resolution.rs +++ b/rs-lib/src/declaration_file_resolution.rs @@ -106,7 +106,7 @@ fn select_best_types_dep( .js() .map(|m| &m.source) { - dep_source.len() > selected_source.len() + dep_source.text.len() > selected_source.text.len() } else { true } diff --git a/rs-lib/src/graph.rs b/rs-lib/src/graph.rs index 9f9e7d1..ff165f4 100644 --- a/rs-lib/src/graph.rs +++ b/rs-lib/src/graph.rs @@ -18,17 +18,18 @@ use anyhow::Result; use deno_ast::ModuleSpecifier; use deno_ast::ParseDiagnostic; use deno_ast::ParsedSource; -use deno_config::workspace::WorkspaceDirectory; -use deno_graph::CapturingModuleAnalyzer; -use deno_graph::EsParser; +use deno_graph::ast::CapturingModuleAnalyzer; +use deno_graph::ast::EsParser; +use deno_graph::ast::ParseOptions; +use deno_graph::ast::ParsedSourceStore; +use deno_graph::source::NullModuleInfoCacher; use deno_graph::JsModule; use deno_graph::Module; -use deno_graph::ParseOptions; -use deno_graph::ParsedSourceStore; +use deno_resolver::deno_json::CompilerOptionsResolver; +use deno_resolver::deno_json::JsxImportSourceConfigResolver; use deno_resolver::factory::WorkspaceFactorySys; use deno_resolver::graph::DefaultDenoResolverRc; use deno_resolver::npm::DenoInNpmPackageChecker; -use deno_resolver::workspace::ScopedJsxImportSourceConfig; use sys_traits::impls::RealSys; pub struct ModuleGraphOptions<'a, TSys: WorkspaceFactorySys> { @@ -37,9 +38,9 @@ pub struct ModuleGraphOptions<'a, TSys: WorkspaceFactorySys> { pub loader: Rc, pub resolver: DefaultDenoResolverRc, pub specifier_mappings: &'a HashMap, + pub compiler_options_resolver: Rc, pub cjs_tracker: Rc>, - pub workspace_dir: Rc, } /// Wrapper around deno_graph::ModuleGraph. @@ -60,7 +61,9 @@ impl ModuleGraph { options.specifier_mappings, ); let scoped_jsx_import_source_config = - ScopedJsxImportSourceConfig::from_workspace_dir(&options.workspace_dir)?; + JsxImportSourceConfigResolver::from_compiler_options_resolver( + &options.compiler_options_resolver, + )?; let source_parser = ScopeAnalysisParser; let capturing_analyzer = CapturingModuleAnalyzer::new(Some(Box::new(source_parser)), None); @@ -77,20 +80,23 @@ impl ModuleGraph { .chain(options.test_entry_points.iter()) .map(|s| s.to_owned()) .collect(), + Vec::new(), &loader, deno_graph::BuildOptions { is_dynamic: false, skip_dynamic_deps: false, - imports: Default::default(), resolver: Some(&graph_resolver), locker: None, module_analyzer: &capturing_analyzer, + module_info_cacher: &NullModuleInfoCacher, reporter: None, npm_resolver: None, file_system: &RealSys, jsr_url_provider: Default::default(), executor: Default::default(), passthrough_jsr_specifiers: false, + unstable_bytes_imports: false, + unstable_text_imports: false, }, ) .await; @@ -190,7 +196,7 @@ impl ModuleGraph { Some(parsed_source) => Ok(parsed_source), None => self.capturing_analyzer.parse_program(ParseOptions { specifier: &js_module.specifier, - source: js_module.source.clone(), + source: js_module.source.text.clone(), media_type: js_module.media_type, scope_analysis: false, }), diff --git a/rs-lib/src/lib.rs b/rs-lib/src/lib.rs index 09f24e7..962a1dd 100644 --- a/rs-lib/src/lib.rs +++ b/rs-lib/src/lib.rs @@ -20,6 +20,7 @@ use anyhow::bail; use deno_ast::apply_text_changes; use deno_ast::TextChange; use deno_graph::Module; +use deno_resolver::deno_json::CompilerOptionsOverrides; use deno_resolver::factory::ConfigDiscoveryOption; use deno_resolver::factory::ResolverFactoryOptions; use deno_resolver::factory::SpecifiedImportMapProvider; @@ -32,6 +33,8 @@ use graph::ModuleGraphOptions; use mappings::Mappings; use mappings::SYNTHETIC_SPECIFIERS; use mappings::SYNTHETIC_TEST_SPECIFIERS; +use node_resolver::analyze::NodeCodeTranslatorMode; +use node_resolver::NodeConditionOptions; use polyfills::build_polyfill_file; use polyfills::polyfills_for_target; use polyfills::Polyfill; @@ -339,16 +342,19 @@ pub async fn transform( WorkspaceFactoryOptions { additional_config_file_names: &[], config_discovery, - deno_dir_path_provider: None, is_package_manager_subcommand: false, node_modules_dir: None, no_npm: false, npm_process_state: None, vendor: None, + frozen_lockfile: None, + lock_arg: None, + lockfile_skip_write: true, + maybe_custom_deno_dir_root: None, + no_lock: false, }, ); - let workspace_dir = factory.workspace_directory()?.clone(); let loader = options.loader.unwrap_or_else(|| { #[cfg(feature = "tokio-loader")] return Rc::new(crate::loader::DefaultLoader::new()); @@ -362,8 +368,14 @@ pub async fn transform( deno_resolver::cjs::IsCjsResolutionMode::ImplicitTypeCommonJs, npm_system_info: Default::default(), node_resolver_options: NodeResolverOptions { - conditions_from_resolution_mode: Default::default(), typescript_version: None, + conditions: NodeConditionOptions { + conditions: Vec::new(), + import_conditions_override: None, + require_conditions_override: None, + }, + prefer_browser_field: false, + bundle_mode: false, }, node_resolution_cache: None, package_json_cache: None, @@ -379,6 +391,13 @@ pub async fn transform( bare_node_builtins: true, unstable_sloppy_imports: true, on_mapped_resolution_diagnostic: None, + compiler_options_overrides: CompilerOptionsOverrides { + no_transpile: true, + source_map_base: None, + preserve_jsx: true, + }, + node_analysis_cache: None, + node_code_translator_mode: NodeCodeTranslatorMode::ModuleLoader, }, ); let deno_resolver = resolver_factory.deno_resolver().await?; @@ -406,8 +425,10 @@ pub async fn transform( specifier_mappings: &options.specifier_mappings, loader, resolver: deno_resolver.clone(), + compiler_options_resolver: resolver_factory + .compiler_options_resolver()? + .clone(), cjs_tracker, - workspace_dir, }) .await?; @@ -546,7 +567,7 @@ pub async fn transform( apply_text_changes(parsed_source.text(), text_changes) } Module::Json(module) => { - format!("export default {};", strip_bom(&module.source).trim(),) + format!("export default {};", strip_bom(&module.source.text).trim(),) } Module::Node(_) | Module::Npm(_) diff --git a/rs-lib/src/loader/mod.rs b/rs-lib/src/loader/mod.rs index 4b618d6..eb54aaf 100644 --- a/rs-lib/src/loader/mod.rs +++ b/rs-lib/src/loader/mod.rs @@ -141,6 +141,7 @@ impl deno_graph::source::Loader for SourceLoader<'_> { specifier: r.specifier, content: r.content.into(), maybe_headers: r.headers, + mtime: None, }) }) .map_err(|err| { @@ -165,6 +166,7 @@ fn get_dummy_module( specifier: specifier.clone(), content: b"".to_vec().into(), maybe_headers: Some(headers), + mtime: None, }, )))) } diff --git a/rs-lib/src/parser.rs b/rs-lib/src/parser.rs index 7ae7bbb..a30eafd 100644 --- a/rs-lib/src/parser.rs +++ b/rs-lib/src/parser.rs @@ -5,8 +5,8 @@ use deno_ast::parse_program; use deno_ast::ParseDiagnostic; use deno_ast::ParseParams; use deno_ast::ParsedSource; -use deno_graph::EsParser; -use deno_graph::ParseOptions; +use deno_graph::ast::EsParser; +use deno_graph::ast::ParseOptions; #[derive(Default, Copy, Clone)] pub struct ScopeAnalysisParser; diff --git a/rs-lib/src/polyfills/mod.rs b/rs-lib/src/polyfills/mod.rs index a0570f8..16dc251 100644 --- a/rs-lib/src/polyfills/mod.rs +++ b/rs-lib/src/polyfills/mod.rs @@ -146,8 +146,8 @@ impl PolyfillTester { pub fn matches(&self, text: &str) -> bool { use deno_ast::MediaType; use deno_ast::ModuleSpecifier; - use deno_graph::EsParser; - use deno_graph::ParseOptions; + use deno_graph::ast::EsParser; + use deno_graph::ast::ParseOptions; use crate::analyze::get_top_level_decls; use crate::parser::ScopeAnalysisParser; diff --git a/rs-lib/tests/integration/in_memory_loader.rs b/rs-lib/tests/integration/in_memory_loader.rs index 1e1405a..3b36818 100644 --- a/rs-lib/tests/integration/in_memory_loader.rs +++ b/rs-lib/tests/integration/in_memory_loader.rs @@ -2,7 +2,7 @@ use std::collections::HashMap; use std::io::ErrorKind; -use std::path::Path; +use std::path::PathBuf; use std::pin::Pin; use std::sync::Arc; @@ -18,6 +18,7 @@ use deno_node_transform::LoadResponse; use deno_node_transform::Loader; use deno_node_transform::ModuleSpecifier; use sys_traits::impls::InMemorySys; +use sys_traits::EnvSetCurrentDir; use sys_traits::EnvSetVar; use sys_traits::FsCreateDirAll; use sys_traits::FsRead; @@ -36,8 +37,12 @@ pub struct InMemoryLoader { impl InMemoryLoader { pub fn new() -> Self { let sys = InMemorySys::default(); - sys.env_set_var("DENO_DIR", "/.deno"); - sys.fs_create_dir_all("/.deno").unwrap(); + let deno_dir_folder = if cfg!(windows) { "C:/.deno" } else { "/.deno" }; + sys.env_set_var("DENO_DIR", deno_dir_folder); + sys.fs_create_dir_all(deno_dir_folder).unwrap(); + if cfg!(windows) { + sys.env_set_current_dir("C:\\").unwrap(); + } Self { sys, remote_files: HashMap::new(), @@ -46,10 +51,16 @@ impl InMemoryLoader { pub fn add_local_file( &mut self, - path: impl AsRef, + path: impl AsRef, text: impl AsRef, ) -> &mut Self { - let parent_dir = path.as_ref().parent().unwrap(); + let path = path.as_ref(); + let path = if cfg!(windows) && path.starts_with("/") { + PathBuf::from(format!("C:{}", path)) + } else { + PathBuf::from(path) + }; + let parent_dir = path.parent().unwrap(); self.sys.fs_create_dir_all(parent_dir).unwrap(); self.sys.fs_write(path, text.as_ref().as_bytes()).unwrap(); self diff --git a/rs-lib/tests/integration/test_builder.rs b/rs-lib/tests/integration/test_builder.rs index 7528299..87a6646 100644 --- a/rs-lib/tests/integration/test_builder.rs +++ b/rs-lib/tests/integration/test_builder.rs @@ -14,7 +14,6 @@ use deno_node_transform::ScriptTarget; use deno_node_transform::Shim; use deno_node_transform::TransformOptions; use deno_node_transform::TransformOutput; -use sys_traits::impls::InMemorySys; use sys_traits::EnvCurrentDir; use super::InMemoryLoader; @@ -36,7 +35,11 @@ impl TestBuilder { pub fn new() -> Self { Self { loader: InMemoryLoader::new(), - entry_point: "file:///mod.ts".to_string(), + entry_point: if cfg!(windows) { + "file:///C:/mod.ts".to_string() + } else { + "file:///mod.ts".to_string() + }, additional_entry_points: Vec::new(), test_entry_points: Vec::new(), specifier_mappings: Default::default(), @@ -48,14 +51,6 @@ impl TestBuilder { } } - pub fn with_sys( - &mut self, - mut action: impl FnMut(&mut InMemorySys), - ) -> &mut Self { - action(&mut self.loader.sys); - self - } - pub fn with_loader( &mut self, mut action: impl FnMut(&mut InMemoryLoader), @@ -65,29 +60,31 @@ impl TestBuilder { } pub fn entry_point(&mut self, value: impl AsRef) -> &mut Self { - self.entry_point = value.as_ref().to_string(); + self.entry_point = normalize_urls(value.as_ref()); self } pub fn add_entry_point(&mut self, value: impl AsRef) -> &mut Self { self .additional_entry_points - .push(value.as_ref().to_string()); + .push(normalize_urls(value.as_ref())); self } pub fn add_test_entry_point(&mut self, value: impl AsRef) -> &mut Self { - self.test_entry_points.push(value.as_ref().to_string()); + self.test_entry_points.push(normalize_urls(value.as_ref())); self } pub fn set_config_file(&mut self, url: impl AsRef) -> &mut Self { - self.import_map = Some(ModuleSpecifier::parse(url.as_ref()).unwrap()); + self.import_map = + Some(ModuleSpecifier::parse(&normalize_urls(url.as_ref())).unwrap()); self } pub fn set_import_map(&mut self, url: impl AsRef) -> &mut Self { - self.import_map = Some(ModuleSpecifier::parse(url.as_ref()).unwrap()); + self.import_map = + Some(ModuleSpecifier::parse(&normalize_urls(url.as_ref())).unwrap()); self } @@ -152,7 +149,7 @@ impl TestBuilder { path: Option<&str>, ) -> &mut Self { self.specifier_mappings.insert( - ModuleSpecifier::parse(specifier.as_ref()).unwrap(), + ModuleSpecifier::parse(&normalize_urls(specifier.as_ref())).unwrap(), MappedSpecifier::Package(PackageMappedSpecifier { name: bare_specifier.as_ref().to_string(), version: version.map(|v| v.to_string()), @@ -169,8 +166,10 @@ impl TestBuilder { to: impl AsRef, ) -> &mut Self { self.specifier_mappings.insert( - ModuleSpecifier::parse(from.as_ref()).unwrap(), - MappedSpecifier::Module(ModuleSpecifier::parse(to.as_ref()).unwrap()), + ModuleSpecifier::parse(&normalize_urls(from.as_ref())).unwrap(), + MappedSpecifier::Module( + ModuleSpecifier::parse(&normalize_urls(to.as_ref())).unwrap(), + ), ); self } @@ -211,3 +210,11 @@ impl TestBuilder { .await } } + +pub fn normalize_urls(url: &str) -> String { + if cfg!(windows) { + url.replace("file:///", "file:///C:/") + } else { + url.to_string() + } +} diff --git a/rs-lib/tests/integration_test.rs b/rs-lib/tests/integration_test.rs index c357faa..1d7f4d6 100644 --- a/rs-lib/tests/integration_test.rs +++ b/rs-lib/tests/integration_test.rs @@ -19,6 +19,8 @@ use integration::TestBuilder; use crate::integration::assert_identity_transforms; use crate::integration::assert_transforms; +use self::integration::normalize_urls; + #[tokio::test] async fn transform_standalone_file() { let result = TestBuilder::new() @@ -211,7 +213,7 @@ async fn transform_shim_custom_shims() { }], })) .add_shim(Shim::Module(ModuleShim { - module: "file:///local_shim.ts".to_string(), + module: normalize_urls("file:///local_shim.ts"), global_names: vec![GlobalName { name: "LocalShim".to_string(), export_name: None, @@ -379,7 +381,9 @@ async fn transform_legacy_deno_shim_ignore_warnings() { .await .unwrap(); - assert_eq!(result.warnings, vec!["deno-shim-ignore has been renamed to dnt-shim-ignore. Please rename it in file:///mod.ts"]); + assert_eq!(result.warnings, vec![ + normalize_urls("deno-shim-ignore has been renamed to dnt-shim-ignore. Please rename it in file:///mod.ts") + ]); assert_files!( result.main.files, &[("mod.ts", "// deno-shim-ignore\nDeno.readTextFile();")] @@ -758,7 +762,9 @@ async fn transform_local_file_not_exists() { assert_eq!( err_message.to_string(), - "Module not found \"file:///other.ts\".\n at file:///mod.ts:1:24" + normalize_urls( + "Module not found \"file:///other.ts\".\n at file:///mod.ts:1:24" + ) ); } @@ -963,18 +969,18 @@ async fn transform_deno_types_and_type_ref_for_different_local_file() { assert_eq!( result.warnings, vec![ - concat!( + normalize_urls(concat!( "Duplicate declaration file found for file:///file.js\n", " Specified file:///declarations.d.ts in file:///mod.ts\n", " Selected file:///declarations3.d.ts\n", " Supress this warning by having only one local file specify the declaration file for this module.", - ), - concat!( + )), + normalize_urls(concat!( "Duplicate declaration file found for file:///file.js\n", " Specified file:///declarations2.d.ts in file:///other.ts\n", " Selected file:///declarations3.d.ts\n", " Supress this warning by having only one local file specify the declaration file for this module.", - ), + )), ] ); assert_files!( @@ -1893,10 +1899,10 @@ async fn redirect_not_found() { assert_eq!( err_message.to_string(), - concat!( + normalize_urls(concat!( "The following specifiers were indicated to be mapped to a module, but were not found:\n", " * file:///mod.deno.ts", - ), + )), ); } diff --git a/transform.ts b/transform.ts index ac058fb..2e2d726 100644 --- a/transform.ts +++ b/transform.ts @@ -6,7 +6,7 @@ * @module */ -import { instantiate } from "./lib/pkg/dnt_wasm.generated.js"; +import * as wasm from "./lib/pkg/dnt_wasm.js"; import type { ScriptTarget } from "./lib/types.ts"; import { valueToUrl } from "./lib/utils.ts"; @@ -75,7 +75,6 @@ export interface TransformOptions { /// Path or url to the import map. importMap?: string; configFile?: string; - internalWasmUrl?: string; cwd: string; } @@ -109,7 +108,7 @@ export interface OutputFile { /** Analyzes the provided entry point to get all the dependended on modules and * outputs canonical TypeScript code in memory. The output of this function * can then be sent to the TypeScript compiler or a bundler for further processing. */ -export async function transform( +export function transform( options: TransformOptions, ): Promise { if (options.entryPoints.length === 0) { @@ -131,10 +130,7 @@ export async function transform( ? undefined : valueToUrl(options.importMap), }; - const wasmFuncs = await instantiate({ - url: options.internalWasmUrl ? new URL(options.internalWasmUrl) : undefined, - }); - return wasmFuncs.transform(newOptions); + return wasm.transform(newOptions); } type SerializableMappedSpecifier = { diff --git a/wasm/Cargo.toml b/wasm/Cargo.toml index 00d79db..4195fc5 100644 --- a/wasm/Cargo.toml +++ b/wasm/Cargo.toml @@ -17,9 +17,9 @@ deno_error.workspace = true deno_path_util.workspace = true dnt = { path = "../rs-lib", default-features = false, features = ["serialization"], package="deno_node_transform" } getrandom = { version = "*", features = ["js"] } -js-sys = "=0.3.69" -wasm-bindgen = { version = "=0.2.92", features = ["serde-serialize"] } -wasm-bindgen-futures = "=0.4.42" +js-sys = "=0.3.77" +wasm-bindgen = { version = "=0.2.100", features = ["serde-serialize"] } +wasm-bindgen-futures = "=0.4.50" # The `console_error_panic_hook` crate provides better debugging of panics by # logging them with `console.error`. This is great for development, but requires @@ -28,7 +28,7 @@ wasm-bindgen-futures = "=0.4.42" console_error_panic_hook = { version = "0.1.6", optional = true } serde = { version = "1.0", features = ["derive"] } -serde-wasm-bindgen = "=0.5.0" +serde-wasm-bindgen = "=0.6.5" [target.'cfg(target_arch = "wasm32")'.dependencies] sys_traits = { workspace = true, features = ["real", "wasm"] }