From 64a789084c51fdb4e4c0dbfd76709dd1eba44655 Mon Sep 17 00:00:00 2001 From: Benjamin Woodruff Date: Tue, 7 May 2024 23:36:51 -0700 Subject: [PATCH] turbopack-node: Use path.join for postcss loader (vercel/turbo#8105) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### Description A followup requested by @sokra in https://github.com/vercel/turbo/pull/7995#discussion_r1568285539 There's no meaningful change in behavior here, as node on windows interprets both `/` and `\` as valid path separators, but this makes the intent clearer. ### Testing Instructions
Repeated the test plan for #7995. Tested on both Windows and Linux. ![Screenshot 2024-05-07 at 2.22.17 PM.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/HAZVitxRNnZz8QMiPn4a/bf7afcfb-0834-454a-b5ee-f52ae736eb47.png)
Closes PACK-3049 --- crates/turbopack-node/src/transforms/postcss.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/turbopack-node/src/transforms/postcss.rs b/crates/turbopack-node/src/transforms/postcss.rs index 05e423ebf156b..31636b701c7a1 100644 --- a/crates/turbopack-node/src/transforms/postcss.rs +++ b/crates/turbopack-node/src/transforms/postcss.rs @@ -248,9 +248,10 @@ pub(crate) async fn config_loader_source( // Bundling would break the ability to use `require.resolve` in the config file. let code = formatdoc! { r#" - import {{ pathToFileURL }} from 'url'; + import {{ pathToFileURL }} from 'node:url'; + import path from 'node:path'; - const configPath = `${{process.cwd()}}/${{{config_path}}}`; + const configPath = path.join(process.cwd(), {config_path}); // Absolute paths don't work with ESM imports on Windows: // https://github.com/nodejs/node/issues/31710 // convert it to a file:// URL, which works on all platforms