diff --git a/.changeset/perfect-countries-sleep.md b/.changeset/perfect-countries-sleep.md new file mode 100644 index 00000000..8708cfa0 --- /dev/null +++ b/.changeset/perfect-countries-sleep.md @@ -0,0 +1,5 @@ +--- +"yak-swc": patch +--- + +Improve cross-os hashes to be more consistent. diff --git a/.github/workflows/autofix.yml b/.github/workflows/autofix.yml index a5d551b7..f28c8fd9 100644 --- a/.github/workflows/autofix.yml +++ b/.github/workflows/autofix.yml @@ -18,6 +18,17 @@ jobs: with: node-version: 20 + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + profile: minimal + override: true + - name: Enable caching + uses: Swatinem/rust-cache@v2 + with: + workspaces: packages/yak-swc + - uses: pnpm/action-setup@v4 name: Install pnpm with: diff --git a/packages/yak-swc/package.json b/packages/yak-swc/package.json index 7bc494fe..fbbb6b9e 100644 --- a/packages/yak-swc/package.json +++ b/packages/yak-swc/package.json @@ -22,6 +22,7 @@ "scripts": { "build": "cargo build --release --target=wasm32-wasi", "prepublishOnly": "npm run build", + "prettier": "cargo fmt --all", "test": "cargo test", "test:snapshots": "cd yak_swc && UPDATE=1 cargo test" }, diff --git a/packages/yak-swc/relative_posix_path/src/lib.rs b/packages/yak-swc/relative_posix_path/src/lib.rs index f5f4f198..c7b1c7f8 100644 --- a/packages/yak-swc/relative_posix_path/src/lib.rs +++ b/packages/yak-swc/relative_posix_path/src/lib.rs @@ -30,7 +30,7 @@ pub fn relative_posix_path(base_path: &str, filename: &str) -> String { /// - "/foo/bar" -> "/foo/bar" fn convert_path_to_posix(path: &str) -> String { lazy_static! { - static ref PATH_REPLACEMENT_REGEX: Regex = Regex::new(r":\\|\\").unwrap(); + static ref PATH_REPLACEMENT_REGEX: Regex = Regex::new(r":\\|\\|:/").unwrap(); } PATH_REPLACEMENT_REGEX.replace_all(path, "/").to_string() @@ -56,6 +56,14 @@ mod tests { ); } + #[test] + fn test_relative_path_windows_forward_slash() { + assert_eq!( + relative_posix_path(r"E:\foo", "E:/foo/bar/file.tsx"), + "bar/file.tsx" + ); + } + #[test] fn test_convert_unix_path() { assert_eq!(convert_path_to_posix(r"/foo/bar"), "/foo/bar");