rwsdk 1.0.0-beta.24 → 1.0.0-beta.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -270,10 +270,16 @@ async function installDependencies(targetDir, packageManager = "pnpm", projectDi
|
|
|
270
270
|
if (await pathExists(nodeModulesCachePath)) {
|
|
271
271
|
console.log(`✅ CACHE HIT for dependencies: Found cached node_modules. Hard-linking from ${nodeModulesCachePath}`);
|
|
272
272
|
try {
|
|
273
|
-
|
|
273
|
+
const destNodeModules = join(targetDir, "node_modules");
|
|
274
|
+
if (process.platform === "win32") {
|
|
275
|
+
await copy(nodeModulesCachePath, destNodeModules);
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
// On non-windows, use cp -al for performance
|
|
279
|
+
await $("cp", ["-al", nodeModulesCachePath, targetDir]);
|
|
280
|
+
}
|
|
274
281
|
console.log(`✅ Cache restored successfully.`);
|
|
275
282
|
console.log(`📦 Installing local SDK into cached node_modules...`);
|
|
276
|
-
// We still need to install the packed tarball
|
|
277
283
|
await runInstall(targetDir, packageManager, true);
|
|
278
284
|
return;
|
|
279
285
|
}
|
|
@@ -291,7 +297,16 @@ async function installDependencies(targetDir, packageManager = "pnpm", projectDi
|
|
|
291
297
|
await fs.promises.mkdir(path.dirname(nodeModulesCachePath), {
|
|
292
298
|
recursive: true,
|
|
293
299
|
});
|
|
294
|
-
|
|
300
|
+
if (process.platform === "win32") {
|
|
301
|
+
await copy(join(targetDir, "node_modules"), nodeModulesCachePath);
|
|
302
|
+
}
|
|
303
|
+
else {
|
|
304
|
+
await $("cp", [
|
|
305
|
+
"-al",
|
|
306
|
+
join(targetDir, "node_modules"),
|
|
307
|
+
nodeModulesCachePath,
|
|
308
|
+
]);
|
|
309
|
+
}
|
|
295
310
|
console.log(`✅ node_modules cached successfully.`);
|
|
296
311
|
}
|
|
297
312
|
}
|
|
@@ -336,18 +351,6 @@ async function runInstall(targetDir, packageManager, isCacheHit) {
|
|
|
336
351
|
yarn: ["yarn", "install", "--silent"],
|
|
337
352
|
"yarn-classic": ["yarn", "--silent"],
|
|
338
353
|
}[packageManager];
|
|
339
|
-
if (isCacheHit && packageManager === "pnpm") {
|
|
340
|
-
// For pnpm, a targeted `install <tarball>` is much faster
|
|
341
|
-
// We need to find the tarball name first.
|
|
342
|
-
const files = await fs.promises.readdir(targetDir);
|
|
343
|
-
const tarball = files.find((f) => f.startsWith("rwsdk-") && f.endsWith(".tgz"));
|
|
344
|
-
if (tarball) {
|
|
345
|
-
installCommand[1] = `./${tarball}`;
|
|
346
|
-
}
|
|
347
|
-
else {
|
|
348
|
-
log("Could not find SDK tarball for targeted install, falling back to full install.");
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
354
|
// Run install command in the target directory
|
|
352
355
|
log(`Running ${installCommand.join(" ")}`);
|
|
353
356
|
const [command, ...args] = installCommand;
|
|
@@ -33,25 +33,6 @@ export const hasEntryAsAncestor = ({ module, entryFile, seen = new Set(), }) =>
|
|
|
33
33
|
}
|
|
34
34
|
return false;
|
|
35
35
|
};
|
|
36
|
-
const isInUseClientGraph = ({ file, clientFiles, server, }) => {
|
|
37
|
-
const id = normalizeModulePath(file, server.config.root);
|
|
38
|
-
if (clientFiles.has(id)) {
|
|
39
|
-
return true;
|
|
40
|
-
}
|
|
41
|
-
const modules = server.environments.client.moduleGraph.getModulesByFile(file);
|
|
42
|
-
if (!modules) {
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
for (const m of modules) {
|
|
46
|
-
for (const importer of m.importers) {
|
|
47
|
-
if (importer.file &&
|
|
48
|
-
isInUseClientGraph({ file: importer.file, clientFiles, server })) {
|
|
49
|
-
return true;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return false;
|
|
54
|
-
};
|
|
55
36
|
export const miniflareHMRPlugin = (givenOptions) => [
|
|
56
37
|
{
|
|
57
38
|
name: "rwsdk:miniflare-hmr",
|
|
@@ -93,15 +74,6 @@ export const miniflareHMRPlugin = (givenOptions) => [
|
|
|
93
74
|
}
|
|
94
75
|
if (this.environment.name === "ssr") {
|
|
95
76
|
log("SSR update, invalidating recursively", ctx.file);
|
|
96
|
-
const isUseClientUpdate = isInUseClientGraph({
|
|
97
|
-
file: ctx.file,
|
|
98
|
-
clientFiles,
|
|
99
|
-
server: ctx.server,
|
|
100
|
-
});
|
|
101
|
-
if (!isUseClientUpdate) {
|
|
102
|
-
log("hmr: not a use client update, short circuiting");
|
|
103
|
-
return [];
|
|
104
|
-
}
|
|
105
77
|
invalidateModule(ctx.server, "ssr", ctx.file);
|
|
106
78
|
invalidateModule(ctx.server, environment, VIRTUAL_SSR_PREFIX +
|
|
107
79
|
normalizeModulePath(ctx.file, givenOptions.rootDir));
|
|
@@ -166,21 +138,12 @@ export const miniflareHMRPlugin = (givenOptions) => [
|
|
|
166
138
|
}
|
|
167
139
|
}
|
|
168
140
|
}
|
|
169
|
-
const isUseClientUpdate = isInUseClientGraph({
|
|
170
|
-
file: ctx.file,
|
|
171
|
-
clientFiles,
|
|
172
|
-
server: ctx.server,
|
|
173
|
-
});
|
|
174
|
-
if (!isUseClientUpdate && !ctx.file.endsWith(".css")) {
|
|
175
|
-
log("hmr: not a use client update and not css, short circuiting");
|
|
176
|
-
return [];
|
|
177
|
-
}
|
|
178
|
-
log("hmr: returning client modules for hmr");
|
|
179
141
|
return ctx.modules;
|
|
180
142
|
}
|
|
181
143
|
// The worker needs an update, and the hot check is for the worker environment
|
|
182
144
|
// => Notify for custom RSC-based HMR update, then short circuit HMR
|
|
183
145
|
if (isWorkerUpdate && this.environment.name === environment) {
|
|
146
|
+
invalidateModule(ctx.server, environment, ctx.file);
|
|
184
147
|
const shortName = getShortName(ctx.file, ctx.server.config.root);
|
|
185
148
|
this.environment.logger.info(`${colors.green(`worker update`)} ${colors.dim(shortName)}`, {
|
|
186
149
|
clear: true,
|