Skip to content

Commit db7c484

Browse files
authored
Merge pull request #118604 from openclaw/fix/aws-hydrate-typescript-resolution
fix(ci): restore direct AWS dependency hydration
2 parents 3832074 + adf5362 commit db7c484

2 files changed

Lines changed: 47 additions & 1 deletion

File tree

‎scripts/lib/package-dist-imports.mjs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
// Scans packaged dist JavaScript for relative imports and missing closure entries.
2+
import { createRequire } from "node:module";
23
import path from "node:path";
3-
import ts from "typescript";
44
import { visitModuleSpecifiers } from "./guard-inventory-utils.mjs";
55

6+
const require = createRequire(import.meta.url);
7+
const ts = require("typescript");
68
const JS_DIST_FILE_RE = /^dist\/.*\.(?:cjs|js|mjs)$/u;
79

810
function normalizePackagePath(value) {

‎test/scripts/postinstall-bundled-plugins.test.ts‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,50 @@ async function writeBaileysMediaFile(packageRoot: string, text: string) {
6868
}
6969

7070
describe("bundled plugin postinstall", () => {
71+
it("resolves TypeScript from NODE_PATH during external modules-dir installs", async () => {
72+
const packageRoot = await createTempDirAsync("openclaw-postinstall-node-path-");
73+
const scriptRoot = path.join(packageRoot, "scripts");
74+
const externalModulesDir = path.join(packageRoot, "external-node-modules");
75+
await fs.mkdir(path.join(scriptRoot, "lib"), { recursive: true });
76+
await fs.mkdir(externalModulesDir, { recursive: true });
77+
await fs.writeFile(
78+
path.join(packageRoot, "package.json"),
79+
'{"name":"openclaw","type":"module","version":"2026.7.2"}\n',
80+
);
81+
for (const relativePath of [
82+
"scripts/postinstall-bundled-plugins.mjs",
83+
"scripts/lib/package-dist-imports.mjs",
84+
"scripts/lib/guard-inventory-utils.mjs",
85+
]) {
86+
await fs.copyFile(
87+
fileURLToPath(new URL(`../../${relativePath}`, import.meta.url)),
88+
path.join(packageRoot, relativePath),
89+
);
90+
}
91+
await fs.symlink(
92+
fileURLToPath(new URL("../../node_modules/typescript", import.meta.url)),
93+
path.join(externalModulesDir, "typescript"),
94+
process.platform === "win32" ? "junction" : "dir",
95+
);
96+
97+
const result = spawnSync(
98+
process.execPath,
99+
[path.join(scriptRoot, "postinstall-bundled-plugins.mjs")],
100+
{
101+
cwd: packageRoot,
102+
encoding: "utf8",
103+
env: {
104+
...process.env,
105+
NODE_PATH: [externalModulesDir, process.env.NODE_PATH]
106+
.filter(Boolean)
107+
.join(path.delimiter),
108+
},
109+
},
110+
);
111+
112+
expect(result.status, result.stderr).toBe(0);
113+
});
114+
71115
it("recognizes direct invocation through symlinked temp prefixes", () => {
72116
const realpathSync = vi.fn((value: string) =>
73117
value.replace(/^\/var\/folders\//u, "/private/var/folders/"),

0 commit comments

Comments
 (0)