Skip to content

Commit fc22aa9

Browse files
committed
chore(zero): address path format differences in windows
1 parent a0b765b commit fc22aa9

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

package-lock.json

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

packages/shared/src/tool/get-external-from-package-json.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
import {readFile} from 'node:fs/promises';
66
import {pkgUp} from 'pkg-up';
7+
import {resolve as resolvePath} from 'node:path';
8+
import {fileURLToPath} from 'node:url';
79
import {isInternalPackage} from './internal-packages.js';
810

911
/**
@@ -12,7 +14,9 @@ import {isInternalPackage} from './internal-packages.js';
1214
* @returns {Promise<string[]>}
1315
*/
1416
export async function getExternalFromPackageJSON(basePath, includePeerDeps) {
15-
const path = await pkgUp({cwd: basePath});
17+
const cwd = basePath.startsWith('file:') ? fileURLToPath(basePath) : basePath;
18+
const path = await pkgUp({cwd});
19+
1620
if (!path) {
1721
throw new Error('Could not find package.json');
1822
}
@@ -46,7 +50,7 @@ function getRecursiveExternals(name, includePeerDeps) {
4650
includePeerDeps,
4751
);
4852
}
49-
const depPath = new URL(`../../../${name}/package.json`, import.meta.url)
50-
.pathname;
53+
const depPath = resolvePath(`../${name}`);
54+
5155
return getExternalFromPackageJSON(depPath, includePeerDeps);
5256
}

packages/zero/tool/build.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import * as esbuild from 'esbuild';
44
import assert from 'node:assert/strict';
55
import {readFile} from 'node:fs/promises';
66
import {builtinModules} from 'node:module';
7+
import {resolve as resolvePath} from 'node:path';
78
import {makeDefine, sharedOptions} from '../../shared/src/build.js';
89
import {getExternalFromPackageJSON} from '../../shared/src/tool/get-external-from-package-json.js';
910

@@ -12,7 +13,8 @@ import {getExternalFromPackageJSON} from '../../shared/src/tool/get-external-fro
1213
* @returns {string}
1314
*/
1415
function basePath(path) {
15-
return new URL('../' + path, import.meta.url).pathname;
16+
const base = resolvePath(path);
17+
return base;
1618
}
1719

1820
/**
@@ -29,8 +31,9 @@ async function getExternal(includePeerDeps) {
2931
* @param {string} internalPackageName
3032
*/
3133
async function addExternalDepsFor(internalPackageName) {
34+
const internalPackageDir = basePath('../' + internalPackageName);
3235
for (const dep of await getExternalFromPackageJSON(
33-
basePath('../' + internalPackageName),
36+
internalPackageDir,
3437
includePeerDeps,
3538
)) {
3639
externalSet.add(dep);

0 commit comments

Comments
 (0)