@cedarjs/vite 6.0.2-rc.53 → 6.0.3-next.227
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/apiDevMiddleware.js +2 -2
- package/dist/buildApp.d.ts.map +1 -1
- package/dist/buildApp.js +3 -7
- package/dist/buildRouteHooks.d.ts +17 -0
- package/dist/buildRouteHooks.d.ts.map +1 -1
- package/dist/buildRouteHooks.js +87 -68
- package/dist/buildRouteManifest.d.ts.map +1 -1
- package/dist/buildRouteManifest.js +3 -13
- package/dist/bundled/react-server-dom-webpack.server.js +2311 -29157
- package/dist/devFeServer.js +3 -3
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -4
- package/dist/lib/getMergedConfig.d.ts.map +1 -1
- package/dist/lib/getMergedConfig.js +0 -5
- package/dist/middleware/types.d.ts +4 -1
- package/dist/middleware/types.d.ts.map +1 -1
- package/dist/plugins/vite-plugin-cedar-cell.d.ts +2 -1
- package/dist/plugins/vite-plugin-cedar-cell.d.ts.map +1 -1
- package/dist/plugins/vite-plugin-cedar-cell.js +30 -11
- package/dist/plugins/vite-plugin-cedar-mock-cell-data.d.ts.map +1 -1
- package/dist/plugins/vite-plugin-cedar-universal-deploy.js +2 -2
- package/dist/plugins/vite-plugin-handler-als-wrapping.d.ts +2 -6
- package/dist/plugins/vite-plugin-handler-als-wrapping.d.ts.map +1 -1
- package/dist/plugins/vite-plugin-handler-als-wrapping.js +4 -7
- package/dist/runFeServer.js +3 -3
- package/dist/streaming/streamHelpers.d.ts +6 -1
- package/dist/streaming/streamHelpers.d.ts.map +1 -1
- package/dist/streaming/streamHelpers.js +1 -1
- package/package.json +34 -32
- package/dist/plugins/vite-plugin-jsx-loader.d.ts +0 -6
- package/dist/plugins/vite-plugin-jsx-loader.d.ts.map +0 -1
- package/dist/plugins/vite-plugin-jsx-loader.js +0 -18
package/dist/apiDevMiddleware.js
CHANGED
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
transformWithBabel
|
|
19
19
|
} from "@cedarjs/babel-config";
|
|
20
20
|
import { getAsyncStoreInstance } from "@cedarjs/context/dist/store";
|
|
21
|
-
import {
|
|
21
|
+
import { createGraphQLServer } from "@cedarjs/graphql-server";
|
|
22
22
|
import { applyGqlormInject } from "@cedarjs/internal/dist/build/api-graphql-transforms.js";
|
|
23
23
|
import { getConfig, getPaths } from "@cedarjs/project-config";
|
|
24
24
|
import { generateDiffSourceMap } from "./lib/generateDiffSourceMap.js";
|
|
@@ -133,7 +133,7 @@ async function internalLoadApiFunctions(viteServer) {
|
|
|
133
133
|
});
|
|
134
134
|
await Promise.all(imports);
|
|
135
135
|
if (extractedGraphqlOptions) {
|
|
136
|
-
loadedGraphqlServer = await
|
|
136
|
+
loadedGraphqlServer = await createGraphQLServer(extractedGraphqlOptions);
|
|
137
137
|
} else {
|
|
138
138
|
loadedGraphqlServer = null;
|
|
139
139
|
}
|
package/dist/buildApp.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildApp.d.ts","sourceRoot":"","sources":["../src/buildApp.ts"],"names":[],"mappings":"AA6DA,MAAM,WAAW,oBAAoB;IACnC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;IACpB,EAAE,CAAC,EAAE,OAAO,CAAA;CACb;AAED;;;;;;;;GAQG;AACH,wBAAsB,aAAa,CAAC,EAClC,OAAe,EACf,SAA0B,EAC1B,EAAU,GACX,GAAE,oBAAyB,
|
|
1
|
+
{"version":3,"file":"buildApp.d.ts","sourceRoot":"","sources":["../src/buildApp.ts"],"names":[],"mappings":"AA6DA,MAAM,WAAW,oBAAoB;IACnC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;IACpB,EAAE,CAAC,EAAE,OAAO,CAAA;CACb;AAED;;;;;;;;GAQG;AACH,wBAAsB,aAAa,CAAC,EAClC,OAAe,EACf,SAA0B,EAC1B,EAAU,GACX,GAAE,oBAAyB,iBAsa3B"}
|
package/dist/buildApp.js
CHANGED
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
applySrcAlias
|
|
21
21
|
} from "@cedarjs/internal/dist/build/api.js";
|
|
22
22
|
import { findApiFiles } from "@cedarjs/internal/dist/files.js";
|
|
23
|
-
import { getConfig, getPaths
|
|
23
|
+
import { getConfig, getPaths } from "@cedarjs/project-config";
|
|
24
24
|
import { generateDiffSourceMap } from "./lib/generateDiffSourceMap.js";
|
|
25
25
|
import { getWorkspacePackageAliases } from "./lib/workspacePackageAliases.js";
|
|
26
26
|
import { cedarAutoImportsPlugin } from "./plugins/vite-plugin-cedar-auto-import.js";
|
|
@@ -60,8 +60,6 @@ async function buildCedarApp({
|
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
62
|
if (workspace.includes("api")) {
|
|
63
|
-
const isEsm = projectSideIsEsm("api");
|
|
64
|
-
const format = isEsm ? "es" : "cjs";
|
|
65
63
|
const apiFiles = findApiFiles();
|
|
66
64
|
const input = {};
|
|
67
65
|
for (const f of apiFiles) {
|
|
@@ -77,7 +75,7 @@ async function buildCedarApp({
|
|
|
77
75
|
rollupOptions: {
|
|
78
76
|
input,
|
|
79
77
|
output: {
|
|
80
|
-
format,
|
|
78
|
+
format: "es",
|
|
81
79
|
preserveModules: true,
|
|
82
80
|
preserveModulesRoot: cedarPaths.api.src,
|
|
83
81
|
entryFileNames: "[name].js",
|
|
@@ -256,9 +254,7 @@ async function buildCedarApp({
|
|
|
256
254
|
plugins.push(cedarDirectoryNamedImportPlugin());
|
|
257
255
|
plugins.push(cedarOtelWrappingPlugin());
|
|
258
256
|
plugins.push(cedarjsJobPathInjectorPlugin());
|
|
259
|
-
plugins.push(
|
|
260
|
-
handlerAlsWrappingPlugin({ projectIsEsm: projectSideIsEsm("api") })
|
|
261
|
-
);
|
|
257
|
+
plugins.push(handlerAlsWrappingPlugin());
|
|
262
258
|
}
|
|
263
259
|
plugins.push(cedarMockCellDataPlugin());
|
|
264
260
|
if (workspace.includes("api")) {
|
|
@@ -1,3 +1,20 @@
|
|
|
1
1
|
import type { Paths } from '@cedarjs/project-config';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the path, relative to `web/dist/ssr/routeHooks` and with a `.js`
|
|
4
|
+
* extension, that the built version of the given route hook source file is
|
|
5
|
+
* written to. The layout mirrors `web/src`, so
|
|
6
|
+
* `web/src/pages/HomePage/HomePage.routeHooks.ts` ends up at
|
|
7
|
+
* `pages/HomePage/HomePage.routeHooks.js` and `web/src/App.routeHooks.ts` at
|
|
8
|
+
* `App.routeHooks.js`.
|
|
9
|
+
*
|
|
10
|
+
* Used both by the build (to name the Rollup entries) and by the route
|
|
11
|
+
* manifest (so the streaming handler can find the file at request time).
|
|
12
|
+
*/
|
|
13
|
+
export declare function getRouteHookDistPath(routeHookSrcPath: string, webSrc?: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* Bundles every `web/src/** /*.routeHooks.{js,ts,tsx,jsx}` file into
|
|
16
|
+
* `web/dist/ssr/routeHooks` as a node ESM module, one output file per route
|
|
17
|
+
* hook. The streaming SSR handler `import()`s them at request time.
|
|
18
|
+
*/
|
|
2
19
|
export declare function buildRouteHooks(verbose: boolean | undefined, rwPaths: Paths): Promise<void>;
|
|
3
20
|
//# sourceMappingURL=buildRouteHooks.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildRouteHooks.d.ts","sourceRoot":"","sources":["../src/buildRouteHooks.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"buildRouteHooks.d.ts","sourceRoot":"","sources":["../src/buildRouteHooks.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAiBpD;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAClC,gBAAgB,EAAE,MAAM,EACxB,MAAM,SAAqB,UAG5B;AA6BD;;;;GAIG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,OAAO,GAAG,SAAS,EAC5B,OAAO,EAAE,KAAK,iBAuEf"}
|
package/dist/buildRouteHooks.js
CHANGED
|
@@ -1,81 +1,100 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
1
|
import path from "node:path";
|
|
3
|
-
import { build as
|
|
4
|
-
import { gqlPlugin } from "vite-plugin-graphql-tag";
|
|
5
|
-
import
|
|
6
|
-
getRouteHookBabelPlugins,
|
|
7
|
-
transformWithBabel
|
|
8
|
-
} from "@cedarjs/babel-config";
|
|
2
|
+
import { build as viteBuild } from "vite";
|
|
3
|
+
import { gqlPlugin as gqlTagPlugin } from "vite-plugin-graphql-tag";
|
|
4
|
+
import tsPathsMod from "vite-tsconfig-paths";
|
|
9
5
|
import { findRouteHooksSrc } from "@cedarjs/internal/dist/files.js";
|
|
10
6
|
import { getPaths } from "@cedarjs/project-config";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
import { cedarApiImportGuardPlugin } from "./plugins/vite-plugin-cedar-api-import-guard.js";
|
|
8
|
+
import { cedarAutoImportsPlugin } from "./plugins/vite-plugin-cedar-auto-import.js";
|
|
9
|
+
import { cedarDirectoryNamedImportPlugin } from "./plugins/vite-plugin-cedar-directory-named-import.js";
|
|
10
|
+
import { cedarjsResolveCedarStyleImportsPlugin } from "./plugins/vite-plugin-cedarjs-resolve-cedar-style-imports.js";
|
|
11
|
+
const tsconfigPaths = (
|
|
12
|
+
// @ts-expect-error – .default only exists at runtime in CJS double-wrap
|
|
13
|
+
// interop
|
|
14
|
+
tsPathsMod.default?.default || tsPathsMod.default || tsPathsMod
|
|
15
|
+
);
|
|
16
|
+
function getRouteHookDistPath(routeHookSrcPath, webSrc = getPaths().web.src) {
|
|
17
|
+
return getRouteHookEntryName(routeHookSrcPath, webSrc) + ".js";
|
|
15
18
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
function getRouteHookEntryName(routeHookSrcPath, webSrc) {
|
|
20
|
+
return path.relative(webSrc, routeHookSrcPath).replace(/\.(js|ts|tsx|jsx)$/, "").split(path.sep).join("/");
|
|
21
|
+
}
|
|
22
|
+
function postGqlTagPlugin() {
|
|
23
|
+
const plugin = gqlTagPlugin();
|
|
24
|
+
if (!plugin || Array.isArray(plugin) || plugin instanceof Promise) {
|
|
25
|
+
throw new Error("vite-plugin-graphql-tag did not return a plugin object");
|
|
26
|
+
}
|
|
27
|
+
return { ...plugin, enforce: "post" };
|
|
19
28
|
}
|
|
20
|
-
const gqlTransform = transform.handler;
|
|
21
29
|
async function buildRouteHooks(verbose, rwPaths) {
|
|
22
30
|
const allRouteHooks = findRouteHooksSrc();
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
},
|
|
41
|
-
error(err) {
|
|
42
|
-
throw new Error(String(err));
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
const gqlResult = await gqlTransform.call(
|
|
46
|
-
mockCtx,
|
|
47
|
-
transformedCode.code,
|
|
48
|
-
args.path
|
|
49
|
-
);
|
|
50
|
-
const gqlCode = gqlResult && typeof gqlResult === "object" && "code" in gqlResult ? gqlResult.code : void 0;
|
|
51
|
-
return {
|
|
52
|
-
contents: gqlCode ?? transformedCode.code,
|
|
53
|
-
loader: "js"
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
throw new Error(`Could not transform file: ${args.path}`);
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
await esbuildBuild({
|
|
61
|
-
absWorkingDir: getPaths().web.base,
|
|
62
|
-
entryPoints: allRouteHooks,
|
|
63
|
-
platform: "node",
|
|
64
|
-
target: "node16",
|
|
65
|
-
// @MARK Disable splitting and esm, because Redwood web modules don't support esm yet
|
|
66
|
-
// outExtension: { '.js': '.mjs' },
|
|
67
|
-
// format: 'esm',
|
|
68
|
-
// splitting: true,
|
|
69
|
-
bundle: true,
|
|
70
|
-
plugins: [runRwBabelTransformsPlugin],
|
|
71
|
-
packages: "external",
|
|
31
|
+
if (allRouteHooks.length === 0) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const input = {};
|
|
35
|
+
for (const routeHook of allRouteHooks) {
|
|
36
|
+
input[getRouteHookEntryName(routeHook, rwPaths.web.src)] = routeHook;
|
|
37
|
+
}
|
|
38
|
+
await viteBuild({
|
|
39
|
+
// Route hooks run in node, so the project's web/vite.config, which is set
|
|
40
|
+
// up for browser and SSR builds of React code, doesn't apply. Only the
|
|
41
|
+
// plugins listed below are used.
|
|
42
|
+
configFile: false,
|
|
43
|
+
root: rwPaths.web.base,
|
|
44
|
+
// Route hooks are node modules, so the static assets in web/public
|
|
45
|
+
// must not be copied next to them
|
|
46
|
+
publicDir: false,
|
|
47
|
+
envFile: false,
|
|
72
48
|
logLevel: verbose ? "info" : "error",
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
49
|
+
plugins: [
|
|
50
|
+
// Turns `$api/` imports into an error in the client environment. It's a
|
|
51
|
+
// no-op in this ssr-only build, but it has to sit in front of
|
|
52
|
+
// tsconfigPaths() wherever that plugin is used, so it's kept here for
|
|
53
|
+
// parity with the web build
|
|
54
|
+
cedarApiImportGuardPlugin(),
|
|
55
|
+
// Resolves the `paths` mapping in web/tsconfig.json, like `$api/*`
|
|
56
|
+
tsconfigPaths(),
|
|
57
|
+
// Resolves `src/` imports to the web side, `$api/` and `api/` imports to
|
|
58
|
+
// the api side, and directory-named modules for those
|
|
59
|
+
cedarjsResolveCedarStyleImportsPlugin(),
|
|
60
|
+
// Resolves relative `./Foo` imports to `./Foo/index` or `./Foo/Foo`
|
|
61
|
+
cedarDirectoryNamedImportPlugin(),
|
|
62
|
+
// Auto-imports `gql` and `React`
|
|
63
|
+
cedarAutoImportsPlugin(),
|
|
64
|
+
// Compiles `gql` template literals into DocumentNode objects. Placed
|
|
65
|
+
// after cedarAutoImportsPlugin(), see postGqlTagPlugin()
|
|
66
|
+
postGqlTagPlugin()
|
|
67
|
+
],
|
|
68
|
+
build: {
|
|
69
|
+
ssr: true,
|
|
70
|
+
target: "node24",
|
|
71
|
+
minify: false,
|
|
72
|
+
outDir: rwPaths.web.distRouteHooks,
|
|
73
|
+
// The directory only ever holds route hook output, so clearing it keeps
|
|
74
|
+
// chunks from earlier builds from piling up
|
|
75
|
+
emptyOutDir: true,
|
|
76
|
+
rollupOptions: {
|
|
77
|
+
input,
|
|
78
|
+
output: {
|
|
79
|
+
format: "es",
|
|
80
|
+
entryFileNames: "[name].js",
|
|
81
|
+
// Modules shared between route hooks, like the api side's db.js
|
|
82
|
+
chunkFileNames: "chunks/[name]-[hash].js",
|
|
83
|
+
exports: "named"
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
// Node builtins and everything that resolves into node_modules stay as
|
|
88
|
+
// imports for node to resolve at runtime. Only project files (the route
|
|
89
|
+
// hook itself and whatever it imports from the web and api sides) are
|
|
90
|
+
// bundled. Bare specifiers like `$api/` and `src/` are resolved by the
|
|
91
|
+
// plugins above before Vite decides whether to externalize them
|
|
92
|
+
ssr: {
|
|
93
|
+
external: true
|
|
76
94
|
}
|
|
77
95
|
});
|
|
78
96
|
}
|
|
79
97
|
export {
|
|
80
|
-
buildRouteHooks
|
|
98
|
+
buildRouteHooks,
|
|
99
|
+
getRouteHookDistPath
|
|
81
100
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildRouteManifest.d.ts","sourceRoot":"","sources":["../src/buildRouteManifest.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"buildRouteManifest.d.ts","sourceRoot":"","sources":["../src/buildRouteManifest.ts"],"names":[],"mappings":"AAYA;;;GAGG;AACH,wBAAsB,kBAAkB,kBAkDvC"}
|
|
@@ -2,7 +2,8 @@ import fs from "node:fs/promises";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import url from "node:url";
|
|
4
4
|
import { getProjectRoutes } from "@cedarjs/internal/dist/routes.js";
|
|
5
|
-
import {
|
|
5
|
+
import { getPaths } from "@cedarjs/project-config";
|
|
6
|
+
import { getRouteHookDistPath } from "./buildRouteHooks.js";
|
|
6
7
|
async function buildRouteManifest() {
|
|
7
8
|
const rwPaths = getPaths();
|
|
8
9
|
const buildManifestUrl = url.pathToFileURL(
|
|
@@ -24,7 +25,7 @@ async function buildRouteManifest() {
|
|
|
24
25
|
// E.g. /blog/post/{id:Int}
|
|
25
26
|
pathDefinition: route.pathDefinition,
|
|
26
27
|
hasParams: route.hasParams,
|
|
27
|
-
routeHooks:
|
|
28
|
+
routeHooks: route.routeHooks ? getRouteHookDistPath(route.routeHooks) : null,
|
|
28
29
|
redirect: route.redirect ? {
|
|
29
30
|
to: route.redirect?.to,
|
|
30
31
|
permanent: false
|
|
@@ -42,17 +43,6 @@ async function buildRouteManifest() {
|
|
|
42
43
|
await fs.mkdir(rwPaths.web.distSsr, { recursive: true });
|
|
43
44
|
return fs.writeFile(webRouteManifest, JSON.stringify(routeManifest, null, 2));
|
|
44
45
|
}
|
|
45
|
-
const FIXME_constructRouteHookPath = (routeHookSrcPath) => {
|
|
46
|
-
const rwPaths = getPaths();
|
|
47
|
-
if (!routeHookSrcPath) {
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
if (getAppRouteHook()) {
|
|
51
|
-
return path.relative(rwPaths.web.src, routeHookSrcPath).replace(".ts", ".js");
|
|
52
|
-
} else {
|
|
53
|
-
return path.relative(path.join(rwPaths.web.src, "pages"), routeHookSrcPath).replace(".ts", ".js");
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
46
|
export {
|
|
57
47
|
buildRouteManifest
|
|
58
48
|
};
|