diff --git a/src/framework/piral-core/src/tools/codegen.ts b/src/framework/piral-core/src/tools/codegen.ts index 2f56093a8..e387babc4 100644 --- a/src/framework/piral-core/src/tools/codegen.ts +++ b/src/framework/piral-core/src/tools/codegen.ts @@ -1,7 +1,7 @@ // this file is bundled, so the references here will not be at runtime (i.e., for a user) import { getModulePath } from 'piral-cli/src/external/resolve'; import { readFileSync, existsSync } from 'fs'; -import { resolve, relative, dirname } from 'path'; +import { resolve, relative, dirname, sep, posix } from 'path'; function findPackagePath(moduleDir: string) { const packageJson = 'package.json'; @@ -67,8 +67,10 @@ function getModulePathOrDefault(root: string, origin: string, name: string) { try { const absPath = getModulePath(root, name); const relPath = relative(origin, absPath); - // fixes relative paths on Windows OS - should use forward slash - const path = relPath.split('\\').join('/'); + + // The relative path is to be used in an import statement, + // so it should be normalized back to use posix path separators. + const path = relPath.split(sep).join(posix.sep); return path; } catch { return name;