Skip to content

Commit ae18fca

Browse files
committed
generate npm export paths correctly from windows
1 parent a28ef99 commit ae18fca

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

resources/build-npm.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ async function buildPackage(outDir: string): Promise<void> {
8787

8888
for (const filepath of emittedTSFiles) {
8989
if (path.basename(filepath) === 'index.js') {
90-
const relativePath = './' + path.relative('./npmDist', filepath);
90+
const relativePath =
91+
'./' + crossPlatformRelativePath('./npmDist', filepath);
9192
packageJSON.exports[path.dirname(relativePath)] = relativePath;
9293
}
9394
}
@@ -140,3 +141,11 @@ function emitTSFiles(options: {
140141
emittedTSFiles: tsResult.emittedFiles.sort((a, b) => a.localeCompare(b)),
141142
};
142143
}
144+
145+
function crossPlatformRelativePath(from: string, to: string): string {
146+
const relativePath = path.relative(from, to);
147+
if (process.platform !== 'win32') {
148+
return relativePath;
149+
}
150+
return path.posix.format({ ...path.parse(relativePath), root: '' });
151+
}

0 commit comments

Comments
 (0)