rwsdk 1.0.0-beta.5 → 1.0.0-beta.7
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.
- package/dist/runtime/client/navigation.js +2 -1
- package/dist/runtime/lib/manifest.d.ts +1 -1
- package/dist/runtime/lib/manifest.js +7 -4
- package/dist/vite/buildApp.mjs +2 -0
- package/dist/vite/linkerPlugin.mjs +1 -1
- package/dist/vite/redwoodPlugin.mjs +0 -4
- package/package.json +1 -1
- package/dist/vite/manifestPlugin.d.mts +0 -4
- package/dist/vite/manifestPlugin.mjs +0 -63
|
@@ -44,7 +44,8 @@ export async function navigate(href, options = { history: "push" }) {
|
|
|
44
44
|
else {
|
|
45
45
|
window.history.replaceState({ path: href }, "", url);
|
|
46
46
|
}
|
|
47
|
-
|
|
47
|
+
// @ts-expect-error
|
|
48
|
+
await globalThis.__rsc_callServer();
|
|
48
49
|
const scrollToTop = options.info?.scrollToTop ?? true;
|
|
49
50
|
const scrollBehavior = options.info?.scrollBehavior ?? "instant";
|
|
50
51
|
if (scrollToTop && history.scrollRestoration === "auto") {
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
let manifest;
|
|
2
|
-
export
|
|
2
|
+
export async function getManifest() {
|
|
3
3
|
if (manifest) {
|
|
4
4
|
return manifest;
|
|
5
5
|
}
|
|
6
6
|
if (import.meta.env.VITE_IS_DEV_SERVER) {
|
|
7
|
+
// In dev, there's no manifest, so we can use an empty object.
|
|
7
8
|
manifest = {};
|
|
8
9
|
}
|
|
9
10
|
else {
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
// context(justinvdm, 2 Oct 2025): In production, the manifest is a
|
|
12
|
+
// placeholder string that will be replaced by the linker plugin with the
|
|
13
|
+
// actual manifest JSON object.
|
|
14
|
+
manifest = "__RWSDK_MANIFEST_PLACEHOLDER__";
|
|
12
15
|
}
|
|
13
16
|
return manifest;
|
|
14
|
-
}
|
|
17
|
+
}
|
package/dist/vite/buildApp.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import debug from "debug";
|
|
2
|
+
import { rm } from "node:fs/promises";
|
|
2
3
|
import { resolve } from "node:path";
|
|
3
4
|
import { runDirectivesScan } from "./runDirectivesScan.mjs";
|
|
4
5
|
const log = debug("rwsdk:vite:build-app");
|
|
@@ -10,6 +11,7 @@ const log = debug("rwsdk:vite:build-app");
|
|
|
10
11
|
* @see docs/architecture/productionBuildProcess.md
|
|
11
12
|
*/
|
|
12
13
|
export async function buildApp({ builder, clientEntryPoints, clientFiles, serverFiles, projectRootDir, workerEntryPathname, }) {
|
|
14
|
+
await rm(resolve(projectRootDir, "dist"), { recursive: true, force: true });
|
|
13
15
|
const workerEnv = builder.environments.worker;
|
|
14
16
|
await runDirectivesScan({
|
|
15
17
|
rootConfig: builder.config,
|
|
@@ -9,7 +9,7 @@ export function linkWorkerBundle({ code, manifestContent, projectRootDir, }) {
|
|
|
9
9
|
const manifest = JSON.parse(manifestContent);
|
|
10
10
|
// 1. Replace the manifest placeholder with the actual manifest content.
|
|
11
11
|
log("Injecting manifest into worker bundle");
|
|
12
|
-
newCode = newCode.replace('"__RWSDK_MANIFEST_PLACEHOLDER__"
|
|
12
|
+
newCode = newCode.replace(/['"]__RWSDK_MANIFEST_PLACEHOLDER__['"]/, manifestContent);
|
|
13
13
|
// 2. Replace asset placeholders with their final hashed paths.
|
|
14
14
|
log("Replacing asset placeholders in final worker bundle");
|
|
15
15
|
for (const [key, value] of Object.entries(manifest)) {
|
|
@@ -18,7 +18,6 @@ import { directivesPlugin } from "./directivesPlugin.mjs";
|
|
|
18
18
|
import { injectVitePreamble } from "./injectVitePreamblePlugin.mjs";
|
|
19
19
|
import { knownDepsResolverPlugin } from "./knownDepsResolverPlugin.mjs";
|
|
20
20
|
import { linkerPlugin } from "./linkerPlugin.mjs";
|
|
21
|
-
import { manifestPlugin } from "./manifestPlugin.mjs";
|
|
22
21
|
import { miniflareHMRPlugin } from "./miniflareHMRPlugin.mjs";
|
|
23
22
|
import { moveStaticAssetsPlugin } from "./moveStaticAssetsPlugin.mjs";
|
|
24
23
|
import { prismaPlugin } from "./prismaPlugin.mjs";
|
|
@@ -144,9 +143,6 @@ export const redwoodPlugin = async (options = {}) => {
|
|
|
144
143
|
clientEntryPoints,
|
|
145
144
|
projectRootDir,
|
|
146
145
|
}),
|
|
147
|
-
manifestPlugin({
|
|
148
|
-
projectRootDir,
|
|
149
|
-
}),
|
|
150
146
|
moveStaticAssetsPlugin({ rootDir: projectRootDir }),
|
|
151
147
|
prismaPlugin({ projectRootDir }),
|
|
152
148
|
linkerPlugin({ projectRootDir }),
|
package/package.json
CHANGED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import debug from "debug";
|
|
2
|
-
const log = debug("rwsdk:vite:manifest-plugin");
|
|
3
|
-
const virtualModuleId = "virtual:rwsdk:manifest.js";
|
|
4
|
-
const resolvedVirtualModuleId = "\0" + virtualModuleId;
|
|
5
|
-
export const manifestPlugin = ({ projectRootDir, }) => {
|
|
6
|
-
let isBuild = false;
|
|
7
|
-
return {
|
|
8
|
-
name: "rwsdk:vite:manifest-plugin",
|
|
9
|
-
enforce: "pre",
|
|
10
|
-
configResolved(config) {
|
|
11
|
-
isBuild = config.command === "build";
|
|
12
|
-
},
|
|
13
|
-
resolveId(id) {
|
|
14
|
-
// Skip during directive scanning to avoid performance issues
|
|
15
|
-
if (process.env.RWSDK_DIRECTIVE_SCAN_ACTIVE) {
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
if (id === virtualModuleId) {
|
|
19
|
-
return resolvedVirtualModuleId;
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
async load(id) {
|
|
23
|
-
// Skip during directive scanning to avoid performance issues
|
|
24
|
-
if (process.env.RWSDK_DIRECTIVE_SCAN_ACTIVE) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
if (id === resolvedVirtualModuleId) {
|
|
28
|
-
if (isBuild) {
|
|
29
|
-
// context(justinvdm, 28 Aug 2025): During the build, we don't have
|
|
30
|
-
// the manifest yet. We insert a placeholder that the linker plugin
|
|
31
|
-
// will replace in the final phase.
|
|
32
|
-
log("Returning manifest placeholder for build");
|
|
33
|
-
return `export default "__RWSDK_MANIFEST_PLACEHOLDER__"`;
|
|
34
|
-
}
|
|
35
|
-
// In dev, we can return an empty object.
|
|
36
|
-
log("Not a build, returning empty manifest");
|
|
37
|
-
return `export default {}`;
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
configEnvironment(name, config) {
|
|
41
|
-
if (name !== "worker" && name !== "ssr") {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
log("Configuring environment: name=%s", name);
|
|
45
|
-
config.optimizeDeps ??= {};
|
|
46
|
-
config.optimizeDeps.esbuildOptions ??= {};
|
|
47
|
-
config.optimizeDeps.esbuildOptions.plugins ??= [];
|
|
48
|
-
config.optimizeDeps.esbuildOptions.plugins.push({
|
|
49
|
-
name: "rwsdk:manifest:esbuild",
|
|
50
|
-
setup(build) {
|
|
51
|
-
log("Setting up esbuild plugin for environment: %s", name);
|
|
52
|
-
build.onResolve({ filter: /^virtual:rwsdk:manifest\.js$/ }, () => {
|
|
53
|
-
log("Resolving virtual manifest module in esbuild");
|
|
54
|
-
return {
|
|
55
|
-
path: "virtual:rwsdk:manifest.js",
|
|
56
|
-
external: true,
|
|
57
|
-
};
|
|
58
|
-
});
|
|
59
|
-
},
|
|
60
|
-
});
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
};
|