rwsdk 1.0.0-alpha.10 → 1.0.0-alpha.11
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/lib/e2e/dev.mjs +62 -52
- package/dist/lib/e2e/environment.d.mts +1 -1
- package/dist/lib/e2e/environment.mjs +55 -12
- package/dist/lib/e2e/index.d.mts +1 -0
- package/dist/lib/e2e/index.mjs +1 -0
- package/dist/lib/e2e/poll.d.mts +8 -0
- package/dist/lib/e2e/poll.mjs +31 -0
- package/dist/lib/e2e/retry.d.mts +4 -0
- package/dist/lib/e2e/retry.mjs +16 -0
- package/dist/lib/e2e/setup.d.mts +2 -0
- package/dist/lib/e2e/setup.mjs +1 -0
- package/dist/lib/e2e/tarball.d.mts +2 -1
- package/dist/lib/e2e/tarball.mjs +2 -2
- package/dist/lib/e2e/testHarness.d.mts +53 -50
- package/dist/lib/e2e/testHarness.mjs +237 -326
- package/dist/vite/redwoodPlugin.d.mts +2 -0
- package/dist/vite/redwoodPlugin.mjs +19 -0
- package/dist/vite/resolveForcedPaths.d.mts +4 -0
- package/dist/vite/resolveForcedPaths.mjs +9 -0
- package/dist/vite/transformClientComponents.mjs +2 -1
- package/dist/vite/transformServerFunctions.d.mts +1 -1
- package/dist/vite/transformServerFunctions.mjs +1 -1
- package/dist/vite/transformServerFunctions.test.mjs +3 -3
- package/package.json +5 -1
|
@@ -27,6 +27,7 @@ import { manifestPlugin } from "./manifestPlugin.mjs";
|
|
|
27
27
|
import { linkerPlugin } from "./linkerPlugin.mjs";
|
|
28
28
|
import { directiveModulesDevPlugin } from "./directiveModulesDevPlugin.mjs";
|
|
29
29
|
import { directivesFilteringPlugin } from "./directivesFilteringPlugin.mjs";
|
|
30
|
+
import { resolveForcedPaths } from "./resolveForcedPaths.mjs";
|
|
30
31
|
export const determineWorkerEntryPathname = async ({ projectRootDir, workerConfigPath, options, readConfig = unstable_readConfig, }) => {
|
|
31
32
|
if (options.entry?.worker) {
|
|
32
33
|
return resolve(projectRootDir, options.entry.worker);
|
|
@@ -39,6 +40,24 @@ const serverFiles = new Set();
|
|
|
39
40
|
const clientEntryPoints = new Set();
|
|
40
41
|
export const redwoodPlugin = async (options = {}) => {
|
|
41
42
|
const projectRootDir = process.cwd();
|
|
43
|
+
if (options.forceClientPaths) {
|
|
44
|
+
const clientPaths = await resolveForcedPaths({
|
|
45
|
+
patterns: options.forceClientPaths,
|
|
46
|
+
projectRootDir,
|
|
47
|
+
});
|
|
48
|
+
for (const p of clientPaths) {
|
|
49
|
+
clientFiles.add(p);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (options.forceServerPaths) {
|
|
53
|
+
const serverPaths = await resolveForcedPaths({
|
|
54
|
+
patterns: options.forceServerPaths,
|
|
55
|
+
projectRootDir,
|
|
56
|
+
});
|
|
57
|
+
for (const p of serverPaths) {
|
|
58
|
+
serverFiles.add(p);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
42
61
|
const workerConfigPath = options.configPath ??
|
|
43
62
|
(process.env.RWSDK_WRANGLER_CONFIG
|
|
44
63
|
? resolve(projectRootDir, process.env.RWSDK_WRANGLER_CONFIG)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { glob } from "glob";
|
|
2
|
+
import { normalizeModulePath } from "../lib/normalizeModulePath.mjs";
|
|
3
|
+
export async function resolveForcedPaths({ patterns, projectRootDir, }) {
|
|
4
|
+
return (await glob(patterns, {
|
|
5
|
+
cwd: projectRootDir,
|
|
6
|
+
absolute: true,
|
|
7
|
+
realpath: true,
|
|
8
|
+
})).map((filepath) => normalizeModulePath(filepath, projectRootDir));
|
|
9
|
+
}
|
|
@@ -5,7 +5,8 @@ import { findExports } from "./findSpecifiers.mjs";
|
|
|
5
5
|
const logVite = debug("rwsdk:vite:transform-client-components:vite");
|
|
6
6
|
const logEsbuild = debug("rwsdk:vite:transform-client-components:esbuild");
|
|
7
7
|
export async function transformClientComponents(code, normalizedId, ctx) {
|
|
8
|
-
if (!
|
|
8
|
+
if (!ctx.clientFiles?.has(normalizedId) &&
|
|
9
|
+
!hasDirective(code, "use client")) {
|
|
9
10
|
return;
|
|
10
11
|
}
|
|
11
12
|
const log = ctx.isEsbuild ? logEsbuild : logVite;
|
|
@@ -12,5 +12,5 @@ type ExportInfoCompat = {
|
|
|
12
12
|
};
|
|
13
13
|
export declare const findExportedFunctions: (code: string, normalizedId?: string) => Set<string>;
|
|
14
14
|
export declare const findExportInfo: (code: string, normalizedId?: string) => ExportInfoCompat;
|
|
15
|
-
export declare const transformServerFunctions: (code: string, normalizedId: string, environment: "client" | "worker" | "ssr", serverFiles
|
|
15
|
+
export declare const transformServerFunctions: (code: string, normalizedId: string, environment: "client" | "worker" | "ssr", serverFiles: Set<string>) => TransformResult | undefined;
|
|
16
16
|
export type { TransformResult };
|
|
@@ -85,7 +85,7 @@ function hasDefaultExport(code, normalizedId) {
|
|
|
85
85
|
return false;
|
|
86
86
|
}
|
|
87
87
|
export const transformServerFunctions = (code, normalizedId, environment, serverFiles) => {
|
|
88
|
-
if (!hasDirective(code, "use server")) {
|
|
88
|
+
if (!serverFiles.has(normalizedId) && !hasDirective(code, "use server")) {
|
|
89
89
|
return;
|
|
90
90
|
}
|
|
91
91
|
process.env.VERBOSE &&
|
|
@@ -107,15 +107,15 @@ export * from './utils';
|
|
|
107
107
|
for (const [key, CODE] of Object.entries(TEST_CASES)) {
|
|
108
108
|
describe(key, () => {
|
|
109
109
|
it(`CLIENT`, () => {
|
|
110
|
-
const result = transformServerFunctions(CODE, "/test.tsx", "client");
|
|
110
|
+
const result = transformServerFunctions(CODE, "/test.tsx", "client", new Set());
|
|
111
111
|
expect(result?.code).toMatchSnapshot();
|
|
112
112
|
});
|
|
113
113
|
it(`WORKER`, () => {
|
|
114
|
-
const result = transformServerFunctions(CODE, "/test.tsx", "worker");
|
|
114
|
+
const result = transformServerFunctions(CODE, "/test.tsx", "worker", new Set());
|
|
115
115
|
expect(result?.code).toMatchSnapshot();
|
|
116
116
|
});
|
|
117
117
|
it(`SSR`, () => {
|
|
118
|
-
const result = transformServerFunctions(CODE, "/test.tsx", "ssr");
|
|
118
|
+
const result = transformServerFunctions(CODE, "/test.tsx", "ssr", new Set());
|
|
119
119
|
expect(result?.code).toMatchSnapshot();
|
|
120
120
|
});
|
|
121
121
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rwsdk",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.11",
|
|
4
4
|
"description": "Build fast, server-driven webapps on Cloudflare with SSR, RSC, and realtime",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -63,6 +63,10 @@
|
|
|
63
63
|
"types": "./dist/lib/e2e/index.d.mts",
|
|
64
64
|
"default": "./dist/lib/e2e/index.mjs"
|
|
65
65
|
},
|
|
66
|
+
"./e2e/setup": {
|
|
67
|
+
"types": "./dist/lib/e2e/setup.d.mts",
|
|
68
|
+
"default": "./dist/lib/e2e/setup.mjs"
|
|
69
|
+
},
|
|
66
70
|
"./db": {
|
|
67
71
|
"types": "./dist/runtime/lib/db/index.d.ts",
|
|
68
72
|
"default": "./dist/runtime/lib/db/index.js"
|