Skip to content

Commit 8ddd25f

Browse files
committed
(packages/build-tools): Bump componentizeJS and fix windows paths
This PR brings in fixes for windows paths when trying build with the tool. It converts the windows paths to ones that can be used in wasi. Signed-off-by: karthik2804 <[email protected]>
1 parent b88738b commit 8ddd25f

File tree

3 files changed

+25
-7
lines changed

3 files changed

+25
-7
lines changed

packages/build-tools/package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/build-tools/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@spinframework/build-tools",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "",
55
"main": "index.js",
66
"scripts": {
@@ -29,7 +29,7 @@
2929
"typescript": "^5.7.3"
3030
},
3131
"dependencies": {
32-
"@bytecodealliance/componentize-js": "^0.18.0",
32+
"@bytecodealliance/componentize-js": "^0.18.1",
3333
"@bytecodealliance/jco": "^1.10.2",
3434
"yargs": "^17.7.2"
3535
},

packages/build-tools/src/wasiDepsParser.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
11
import fs from 'fs';
22
import { TargetWorld } from '../lib/wit_tools.js';
33
import path from 'path';
4+
import { resolve } from 'node:path';
5+
import { platform } from 'node:process';
6+
const isWindows = platform === 'win32';
7+
8+
function maybeWindowsPath(path: string): string {
9+
if (!path) return path;
10+
const resolvedPath = resolve(path);
11+
if (!isWindows) return resolvedPath;
12+
13+
// Strip any existing UNC prefix check both the format we add as well as what
14+
// the windows API returns when using path.resolve
15+
let cleanPath = resolvedPath;
16+
while (cleanPath.startsWith('\\\\?\\') || cleanPath.startsWith('//?/')) {
17+
cleanPath = cleanPath.substring(4);
18+
}
19+
20+
return '//?/' + cleanPath.replace(/\\/g, '/');
21+
}
422

523
// Define the structure of a package.json file
624
// Includes dependencies and an optional config section for 'knitwit'
@@ -62,7 +80,7 @@ function absolutizeWitPath(
6280
if (depPackageJson.config?.witDependencies) {
6381
depPackageJson.config.witDependencies.forEach(witDep => {
6482
if (!path.isAbsolute(witDep.witPath)) {
65-
witDep.witPath = path.resolve(depPackageJsonPath, witDep.witPath);
83+
witDep.witPath = maybeWindowsPath(path.resolve(depPackageJsonPath, witDep.witPath));
6684
}
6785
});
6886
}

0 commit comments

Comments
 (0)