diff --git a/packages/medusa/src/commands/build.ts b/packages/medusa/src/commands/build.ts index 86b3055dc6..3ba948da2c 100644 --- a/packages/medusa/src/commands/build.ts +++ b/packages/medusa/src/commands/build.ts @@ -1,6 +1,6 @@ import { ConfigModule } from "@medusajs/types" -import { transformFile } from "@swc/core" import { getConfigFile } from "@medusajs/utils" +import { transformFile } from "@swc/core" import { existsSync } from "node:fs" import { copyFile, mkdir, readdir, rm, writeFile } from "node:fs/promises" import path from "path" @@ -56,7 +56,7 @@ const getOutputPath = (file: string, config: FileConfig) => { outputPath = outputPath.replace(currentExtension, targetExtension) } - return outputPath + return outputPath.replaceAll(path.sep, "/") } const writeToOut = async ( @@ -72,9 +72,8 @@ const writeToOut = async ( async function copyToOut(file: string, config: FileConfig) { const outputPath = getOutputPath(file, config) - const dirNameRegex = new RegExp("\\" + path.sep + "([^\\" + path.sep + "]+)$") - await mkdir(outputPath.replace(dirNameRegex, ""), { recursive: true }) + await mkdir(outputPath.replace(/\/[^/]+$/, ""), { recursive: true }) await copyFile(file, outputPath) }