@cedarjs/prerender 9.0.0-canary.1784 → 9.0.0-canary.3124
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/apolloState.d.ts +13 -0
- package/dist/apolloState.d.ts.map +1 -0
- package/dist/apolloState.js +6 -0
- package/dist/browserUtils/index.d.ts +1 -1
- package/dist/browserUtils/index.d.ts.map +1 -1
- package/dist/build-and-import/buildAndImport.d.ts +1 -1
- package/dist/build-and-import/buildAndImport.d.ts.map +1 -1
- package/dist/build-and-import/buildAndImport.js +22 -9
- package/dist/build-and-import/rollupPlugins/rollup-plugin-cedar-remove-dev-fatal-error-page.d.ts +14 -0
- package/dist/build-and-import/rollupPlugins/rollup-plugin-cedar-remove-dev-fatal-error-page.d.ts.map +1 -0
- package/dist/build-and-import/rollupPlugins/rollup-plugin-cedar-remove-dev-fatal-error-page.js +29 -0
- package/dist/build-and-import/rollupPlugins/rollup-plugin-cedarjs-cell.d.ts.map +1 -1
- package/dist/build-and-import/rollupPlugins/rollup-plugin-cedarjs-cell.js +2 -1
- package/dist/build-and-import/rollupPlugins/rollup-plugin-cedarjs-ignore-html-and-css-imports.d.ts +4 -3
- package/dist/build-and-import/rollupPlugins/rollup-plugin-cedarjs-ignore-html-and-css-imports.d.ts.map +1 -1
- package/dist/build-and-import/rollupPlugins/rollup-plugin-cedarjs-prerender-media-imports.d.ts.map +1 -1
- package/dist/build-and-import/rollupPlugins/rollup-plugin-cedarjs-routes-auto-loader.d.ts.map +1 -1
- package/dist/detection/detection.d.ts.map +1 -1
- package/dist/detection/detection.js +1 -3
- package/dist/graphql/graphql.d.ts +17 -2
- package/dist/graphql/graphql.d.ts.map +1 -1
- package/dist/graphql/node-runner.d.ts +1 -1
- package/dist/graphql/node-runner.d.ts.map +1 -1
- package/dist/graphql/node-runner.js +27 -37
- package/dist/{cjs/index.d.ts.map → index.d.ts.map} +1 -1
- package/dist/index.js +1 -0
- package/dist/runPrerender.d.ts.map +1 -0
- package/dist/{runPrerenderEsm.js → runPrerender.js} +76 -63
- package/package.json +36 -65
- package/LICENSE +0 -21
- package/dist/babelPlugins/babel-plugin-redwood-cell.d.ts +0 -5
- package/dist/babelPlugins/babel-plugin-redwood-cell.d.ts.map +0 -1
- package/dist/babelPlugins/babel-plugin-redwood-cell.js +0 -97
- package/dist/babelPlugins/babel-plugin-redwood-prerender-media-imports.d.ts +0 -5
- package/dist/babelPlugins/babel-plugin-redwood-prerender-media-imports.d.ts.map +0 -1
- package/dist/babelPlugins/babel-plugin-redwood-prerender-media-imports.js +0 -76
- package/dist/babelPlugins/utils.d.ts +0 -2
- package/dist/babelPlugins/utils.d.ts.map +0 -1
- package/dist/babelPlugins/utils.js +0 -15
- package/dist/cjs/babelPlugins/babel-plugin-redwood-cell.d.ts +0 -5
- package/dist/cjs/babelPlugins/babel-plugin-redwood-cell.d.ts.map +0 -1
- package/dist/cjs/babelPlugins/babel-plugin-redwood-cell.js +0 -121
- package/dist/cjs/babelPlugins/babel-plugin-redwood-prerender-media-imports.d.ts +0 -5
- package/dist/cjs/babelPlugins/babel-plugin-redwood-prerender-media-imports.d.ts.map +0 -1
- package/dist/cjs/babelPlugins/babel-plugin-redwood-prerender-media-imports.js +0 -100
- package/dist/cjs/babelPlugins/utils.d.ts +0 -2
- package/dist/cjs/babelPlugins/utils.d.ts.map +0 -1
- package/dist/cjs/babelPlugins/utils.js +0 -49
- package/dist/cjs/browserUtils/index.d.ts +0 -8
- package/dist/cjs/browserUtils/index.d.ts.map +0 -1
- package/dist/cjs/browserUtils/index.js +0 -47
- package/dist/cjs/build-and-import/buildAndImport.js +0 -173
- package/dist/cjs/build-and-import/load-tsconfig.d.js +0 -1
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-cell.js +0 -183
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-directory-named-imports.js +0 -83
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-external.js +0 -125
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-ignore-html-and-css-imports.js +0 -48
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-inject-file-globals.js +0 -66
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-prerender-media-imports.js +0 -118
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-routes-auto-loader.js +0 -146
- package/dist/cjs/build-and-import/rollupPlugins/utils.js +0 -78
- package/dist/cjs/build-and-import/utils.js +0 -68
- package/dist/cjs/detection/detection.d.ts +0 -11
- package/dist/cjs/detection/detection.d.ts.map +0 -1
- package/dist/cjs/detection/detection.js +0 -48
- package/dist/cjs/errors.d.ts +0 -19
- package/dist/cjs/errors.d.ts.map +0 -1
- package/dist/cjs/errors.js +0 -52
- package/dist/cjs/graphql/graphql.d.ts +0 -19
- package/dist/cjs/graphql/graphql.d.ts.map +0 -1
- package/dist/cjs/graphql/graphql.js +0 -152
- package/dist/cjs/graphql/node-runner.js +0 -109
- package/dist/cjs/graphql/vite-plugin-cedar-auto-import.js +0 -107
- package/dist/cjs/graphql/vite-plugin-cedar-import-dir.js +0 -118
- package/dist/cjs/index.js +0 -22
- package/dist/cjs/internal.d.ts +0 -28
- package/dist/cjs/internal.d.ts.map +0 -1
- package/dist/cjs/internal.js +0 -135
- package/dist/cjs/package.json +0 -1
- package/dist/cjs/runPrerender.d.ts.map +0 -1
- package/dist/cjs/runPrerender.js +0 -307
- package/dist/cjs/runPrerenderEsm.js +0 -304
- package/dist/graphql/vite-plugin-cedar-import-dir.d.ts +0 -19
- package/dist/graphql/vite-plugin-cedar-import-dir.d.ts.map +0 -1
- package/dist/graphql/vite-plugin-cedar-import-dir.js +0 -84
- package/dist/runPrerenderEsm.d.ts +0 -9
- package/dist/runPrerenderEsm.d.ts.map +0 -1
- /package/dist/{cjs/index.d.ts → index.d.ts} +0 -0
- /package/dist/{cjs/runPrerender.d.ts → runPrerender.d.ts} +0 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether an extracted Apollo cache state is non-empty and worth inlining
|
|
3
|
+
* into the prerendered HTML as a bootstrap `<script>`.
|
|
4
|
+
*
|
|
5
|
+
* Only emit the Apollo state bootstrap when there is state to restore. Both
|
|
6
|
+
* consumers (`CedarApolloProvider` and the suspense provider) already do
|
|
7
|
+
* `.restore(globalThis?.__CEDAR__APOLLO_STATE ?? {})`, so an empty payload is
|
|
8
|
+
* a no-op. It is still an inline `<script>` though, which every strict-CSP app
|
|
9
|
+
* has to allow-list with a hash that goes stale whenever the payload changes.
|
|
10
|
+
* A page that prerenders no Cells emits nothing.
|
|
11
|
+
*/
|
|
12
|
+
export declare function hasApolloState(state: unknown): state is Record<string, unknown>;
|
|
13
|
+
//# sourceMappingURL=apolloState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apolloState.d.ts","sourceRoot":"","sources":["../src/apolloState.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAIlC"}
|
|
@@ -4,5 +4,5 @@ export declare const isBrowser: boolean;
|
|
|
4
4
|
export declare const useIsBrowser: () => boolean;
|
|
5
5
|
export declare const BrowserOnly: ({ children }: {
|
|
6
6
|
children: ReactElement;
|
|
7
|
-
}) => ReactElement<
|
|
7
|
+
}) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | null;
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/browserUtils/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAKzC,eAAO,MAAM,cAAc,QAAO,OAEjC,CAAA;AAED,eAAO,MAAM,SAAS,SAAoB,CAAA;AAE1C,eAAO,MAAM,YAAY,eAIxB,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,cAAc;IAAE,QAAQ,EAAE,YAAY,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/browserUtils/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAKzC,eAAO,MAAM,cAAc,QAAO,OAEjC,CAAA;AAED,eAAO,MAAM,SAAS,SAAoB,CAAA;AAE1C,eAAO,MAAM,YAAY,eAIxB,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,cAAc;IAAE,QAAQ,EAAE,YAAY,CAAA;CAAE,sFAInE,CAAA"}
|
|
@@ -7,6 +7,6 @@ interface Options {
|
|
|
7
7
|
*/
|
|
8
8
|
preserveTemporaryFile?: boolean;
|
|
9
9
|
}
|
|
10
|
-
export declare function buildAndImport(options: Options): Promise<Record<string, React.
|
|
10
|
+
export declare function buildAndImport(options: Options): Promise<Record<string, React.ElementType>>;
|
|
11
11
|
export {};
|
|
12
12
|
//# sourceMappingURL=buildAndImport.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildAndImport.d.ts","sourceRoot":"","sources":["../../src/build-and-import/buildAndImport.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"buildAndImport.d.ts","sourceRoot":"","sources":["../../src/build-and-import/buildAndImport.ts"],"names":[],"mappings":"AAqCA,UAAU,OAAO;IACf,yCAAyC;IACzC,QAAQ,EAAE,MAAM,CAAA;IAEhB;;;OAGG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAChC;AAED,wBAAsB,cAAc,CAClC,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC,CA4I5C"}
|
|
@@ -7,11 +7,12 @@ import replace from "@rollup/plugin-replace";
|
|
|
7
7
|
import { rollup } from "rollup";
|
|
8
8
|
import { swc } from "rollup-plugin-swc3";
|
|
9
9
|
import unimportPlugin from "unimport/unplugin";
|
|
10
|
-
import { getConfig, getPaths
|
|
10
|
+
import { getConfig, getPaths } from "@cedarjs/project-config";
|
|
11
11
|
import {
|
|
12
12
|
getPathsFromTypeScriptConfig,
|
|
13
13
|
parseTypeScriptConfigFiles
|
|
14
14
|
} from "../internal.js";
|
|
15
|
+
import { cedarRemoveDevFatalErrorPagePlugin } from "./rollupPlugins/rollup-plugin-cedar-remove-dev-fatal-error-page.js";
|
|
15
16
|
import { cellTransformPlugin } from "./rollupPlugins/rollup-plugin-cedarjs-cell.js";
|
|
16
17
|
import { cedarjsDirectoryNamedImportPlugin } from "./rollupPlugins/rollup-plugin-cedarjs-directory-named-imports.js";
|
|
17
18
|
import { externalPlugin } from "./rollupPlugins/rollup-plugin-cedarjs-external.js";
|
|
@@ -41,7 +42,6 @@ async function buildAndImport(options) {
|
|
|
41
42
|
if (!fs.existsSync(outDir)) {
|
|
42
43
|
fs.mkdirSync(outDir, { recursive: true });
|
|
43
44
|
}
|
|
44
|
-
const isEsm = projectIsEsm();
|
|
45
45
|
const build = await rollup({
|
|
46
46
|
input: [options.filepath],
|
|
47
47
|
output: {
|
|
@@ -78,6 +78,25 @@ async function buildAndImport(options) {
|
|
|
78
78
|
...getPathsFromTypeScriptConfig(tsConfigs.web, webBase)
|
|
79
79
|
]
|
|
80
80
|
}),
|
|
81
|
+
// Handle JSON imports (e.g. .cedar/gqlorm-schema.json)
|
|
82
|
+
{
|
|
83
|
+
name: "json",
|
|
84
|
+
transform(code, id) {
|
|
85
|
+
if (!id.endsWith(".json")) {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
try {
|
|
89
|
+
const parsed = JSON.parse(code);
|
|
90
|
+
return {
|
|
91
|
+
code: `export default ${JSON.stringify(parsed)}`,
|
|
92
|
+
map: { mappings: "" }
|
|
93
|
+
};
|
|
94
|
+
} catch {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
cedarRemoveDevFatalErrorPagePlugin(),
|
|
81
100
|
ignoreHtmlAndCssImportsPlugin(),
|
|
82
101
|
cellTransformPlugin(),
|
|
83
102
|
cedarjsRoutesAutoLoaderPlugin(),
|
|
@@ -94,16 +113,10 @@ async function buildAndImport(options) {
|
|
|
94
113
|
from: "react"
|
|
95
114
|
},
|
|
96
115
|
// import { gql } from 'graphql-tag'
|
|
97
|
-
!useTrustedDocumentsGqlTag &&
|
|
116
|
+
!useTrustedDocumentsGqlTag && {
|
|
98
117
|
name: "gql",
|
|
99
118
|
from: "graphql-tag"
|
|
100
119
|
},
|
|
101
|
-
// import gql from 'graphql-tag'
|
|
102
|
-
!useTrustedDocumentsGqlTag && !isEsm && {
|
|
103
|
-
name: "default",
|
|
104
|
-
as: "gql",
|
|
105
|
-
from: "graphql-tag"
|
|
106
|
-
},
|
|
107
120
|
// import { gql } from 'src/graphql/gql'
|
|
108
121
|
useTrustedDocumentsGqlTag && {
|
|
109
122
|
name: "gql",
|
package/dist/build-and-import/rollupPlugins/rollup-plugin-cedar-remove-dev-fatal-error-page.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Plugin as RollupPlugin } from 'rollup';
|
|
2
|
+
/**
|
|
3
|
+
* Rollup plugin to remove the DevFatalErrorPage import during prerendering.
|
|
4
|
+
*
|
|
5
|
+
* Replaces:
|
|
6
|
+
* import { DevFatalErrorPage } from '@cedarjs/web/dist/components/DevFatalErrorPage'
|
|
7
|
+
* with:
|
|
8
|
+
* const DevFatalErrorPage = undefined
|
|
9
|
+
*
|
|
10
|
+
* Prerendering runs in a production context and should not include the
|
|
11
|
+
* dev-only error page component in the bundle.
|
|
12
|
+
*/
|
|
13
|
+
export declare const cedarRemoveDevFatalErrorPagePlugin: () => RollupPlugin;
|
|
14
|
+
//# sourceMappingURL=rollup-plugin-cedar-remove-dev-fatal-error-page.d.ts.map
|
package/dist/build-and-import/rollupPlugins/rollup-plugin-cedar-remove-dev-fatal-error-page.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rollup-plugin-cedar-remove-dev-fatal-error-page.d.ts","sourceRoot":"","sources":["../../../src/build-and-import/rollupPlugins/rollup-plugin-cedar-remove-dev-fatal-error-page.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,YAAY,EAAE,MAAM,QAAQ,CAAA;AAcpD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,kCAAkC,QAAO,YAqBrD,CAAA"}
|
package/dist/build-and-import/rollupPlugins/rollup-plugin-cedar-remove-dev-fatal-error-page.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const DEV_FATAL_ERROR_PAGE_MODULE = "@cedarjs/web/dist/components/DevFatalErrorPage";
|
|
2
|
+
function escapeRegExp(s) {
|
|
3
|
+
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
4
|
+
}
|
|
5
|
+
const ESCAPED_MODULE = escapeRegExp(DEV_FATAL_ERROR_PAGE_MODULE);
|
|
6
|
+
const IMPORT_PATTERN = new RegExp(
|
|
7
|
+
`import\\s*\\{[^}]*\\bDevFatalErrorPage\\b[^}]*\\}\\s*from\\s*['"]${ESCAPED_MODULE}['"]`
|
|
8
|
+
);
|
|
9
|
+
const cedarRemoveDevFatalErrorPagePlugin = () => {
|
|
10
|
+
return {
|
|
11
|
+
name: "cedar-remove-dev-fatal-error-page",
|
|
12
|
+
transform(code) {
|
|
13
|
+
if (!code.includes(DEV_FATAL_ERROR_PAGE_MODULE)) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
const newCode = code.replace(
|
|
17
|
+
IMPORT_PATTERN,
|
|
18
|
+
"const DevFatalErrorPage = undefined"
|
|
19
|
+
);
|
|
20
|
+
if (newCode === code) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
return { code: newCode, map: null };
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export {
|
|
28
|
+
cedarRemoveDevFatalErrorPagePlugin
|
|
29
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollup-plugin-cedarjs-cell.d.ts","sourceRoot":"","sources":["../../../src/build-and-import/rollupPlugins/rollup-plugin-cedarjs-cell.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"rollup-plugin-cedarjs-cell.d.ts","sourceRoot":"","sources":["../../../src/build-and-import/rollupPlugins/rollup-plugin-cedarjs-cell.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAoBpC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,CAsK5C"}
|
|
@@ -7,6 +7,7 @@ const generate = babelGenerator.default;
|
|
|
7
7
|
const EXPECTED_EXPORTS_FROM_CELL = [
|
|
8
8
|
"beforeQuery",
|
|
9
9
|
"QUERY",
|
|
10
|
+
"FRAGMENT",
|
|
10
11
|
"data",
|
|
11
12
|
"isEmpty",
|
|
12
13
|
"afterQuery",
|
|
@@ -64,7 +65,7 @@ function cellTransformPlugin() {
|
|
|
64
65
|
}
|
|
65
66
|
}
|
|
66
67
|
});
|
|
67
|
-
const hasQueryOrDataExport = exportNames.includes("QUERY") || exportNames.includes("data");
|
|
68
|
+
const hasQueryOrDataExport = exportNames.includes("QUERY") || exportNames.includes("FRAGMENT") || exportNames.includes("data");
|
|
68
69
|
if (hasDefaultExport || !hasQueryOrDataExport) {
|
|
69
70
|
return null;
|
|
70
71
|
}
|
package/dist/build-and-import/rollupPlugins/rollup-plugin-cedarjs-ignore-html-and-css-imports.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { Plugin as RollupPlugin } from 'rollup';
|
|
2
2
|
/**
|
|
3
|
-
* A Rollup plugin that ignores imports of HTML and CSS files by replacing them
|
|
4
|
-
* This is useful when bundling code that imports these
|
|
5
|
-
*
|
|
3
|
+
* A Rollup plugin that ignores imports of HTML and CSS files by replacing them
|
|
4
|
+
* with empty modules. This is useful when bundling code that imports these
|
|
5
|
+
* files for the browser build (where Vite handles them), but you want Rollup to
|
|
6
|
+
* ignore them during the build process.
|
|
6
7
|
*
|
|
7
8
|
* @param options Configuration options
|
|
8
9
|
* @returns Rollup plugin
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollup-plugin-cedarjs-ignore-html-and-css-imports.d.ts","sourceRoot":"","sources":["../../../src/build-and-import/rollupPlugins/rollup-plugin-cedarjs-ignore-html-and-css-imports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,YAAY,EAAE,MAAM,QAAQ,CAAA;AAEpD
|
|
1
|
+
{"version":3,"file":"rollup-plugin-cedarjs-ignore-html-and-css-imports.d.ts","sourceRoot":"","sources":["../../../src/build-and-import/rollupPlugins/rollup-plugin-cedarjs-ignore-html-and-css-imports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,YAAY,EAAE,MAAM,QAAQ,CAAA;AAEpD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,6BAA6B,QAAO,YAyBhD,CAAA"}
|
package/dist/build-and-import/rollupPlugins/rollup-plugin-cedarjs-prerender-media-imports.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollup-plugin-cedarjs-prerender-media-imports.d.ts","sourceRoot":"","sources":["../../../src/build-and-import/rollupPlugins/rollup-plugin-cedarjs-prerender-media-imports.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"rollup-plugin-cedarjs-prerender-media-imports.d.ts","sourceRoot":"","sources":["../../../src/build-and-import/rollupPlugins/rollup-plugin-cedarjs-prerender-media-imports.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AA8BpC,MAAM,WAAW,4BAA4B;IAC3C,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;CACtB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,kCAAkC,CAChD,OAAO,GAAE,4BAAiC,GACzC,MAAM,CA0ER"}
|
package/dist/build-and-import/rollupPlugins/rollup-plugin-cedarjs-routes-auto-loader.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollup-plugin-cedarjs-routes-auto-loader.d.ts","sourceRoot":"","sources":["../../../src/build-and-import/rollupPlugins/rollup-plugin-cedarjs-routes-auto-loader.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAYpC,MAAM,WAAW,aAAa;IAC5B,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB;
|
|
1
|
+
{"version":3,"file":"rollup-plugin-cedarjs-routes-auto-loader.d.ts","sourceRoot":"","sources":["../../../src/build-and-import/rollupPlugins/rollup-plugin-cedarjs-routes-auto-loader.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAYpC,MAAM,WAAW,aAAa;IAC5B,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB;AAoBD,wBAAgB,6BAA6B,IAAI,MAAM,CAoJtD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detection.d.ts","sourceRoot":"","sources":["../../src/detection/detection.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"detection.d.ts","sourceRoot":"","sources":["../../src/detection/detection.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,qBAAqB;;;;;;;;;GAqBjC,CAAA"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { getPaths } from "@cedarjs/project-config";
|
|
2
1
|
import { getProject } from "@cedarjs/structure";
|
|
3
2
|
const detectPrerenderRoutes = () => {
|
|
4
|
-
const
|
|
5
|
-
const routes = rwProject.getRouter().routes;
|
|
3
|
+
const routes = getProject().getRouter().routes;
|
|
6
4
|
const prerenderRoutes = routes.filter((route) => route.prerender).map((route) => ({
|
|
7
5
|
name: route.isNotFound ? "404" : route.name,
|
|
8
6
|
// `path` will be updated/expanded later where route parameters will be
|
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
import type { DocumentNode } from 'graphql';
|
|
2
2
|
export type FileImporter = (path: string) => Promise<any>;
|
|
3
|
+
/**
|
|
4
|
+
* The project's GraphQL API handler, wrapped so it can be called with a bare
|
|
5
|
+
* GraphQL operation. Resolves to the handler's response, whose `body` holds
|
|
6
|
+
* the JSON-encoded result.
|
|
7
|
+
*/
|
|
8
|
+
export type GqlHandler = (operation: GqlOperation) => Promise<{
|
|
9
|
+
body?: string;
|
|
10
|
+
} | undefined>;
|
|
11
|
+
interface GqlOperation {
|
|
12
|
+
operationName: string;
|
|
13
|
+
query: string | undefined;
|
|
14
|
+
variables?: Record<string, unknown>;
|
|
15
|
+
extensions?: Record<string, unknown>;
|
|
16
|
+
}
|
|
3
17
|
/**
|
|
4
18
|
* Loads the graphql server, with all the user's settings
|
|
5
19
|
* And execute the query against it
|
|
@@ -8,12 +22,13 @@ export type FileImporter = (path: string) => Promise<any>;
|
|
|
8
22
|
* there is a GraphQL error. Instead, it returns the result with the graphql
|
|
9
23
|
* error.
|
|
10
24
|
*/
|
|
11
|
-
export declare function executeQuery(fileImporter: FileImporter, gqlHandler:
|
|
25
|
+
export declare function executeQuery(fileImporter: FileImporter, gqlHandler: GqlHandler, query: DocumentNode, variables?: Record<string, unknown>): Promise<string | undefined>;
|
|
12
26
|
/**
|
|
13
27
|
* Finds the graphql handler, returns a function
|
|
14
28
|
* that can be used to execute queries against it
|
|
15
29
|
*
|
|
16
30
|
* Throws GqlHandlerImportError, so that we can warn the user (but not blow up)
|
|
17
31
|
*/
|
|
18
|
-
export declare function getGqlHandler(fileImporter: FileImporter): Promise<
|
|
32
|
+
export declare function getGqlHandler(fileImporter: FileImporter): Promise<GqlHandler>;
|
|
33
|
+
export {};
|
|
19
34
|
//# sourceMappingURL=graphql.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql.d.ts","sourceRoot":"","sources":["../../src/graphql/graphql.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAS3C,MAAM,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"graphql.d.ts","sourceRoot":"","sources":["../../src/graphql/graphql.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAS3C,MAAM,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;AAEzD;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,CACvB,SAAS,EAAE,YAAY,KACpB,OAAO,CAAC;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAAC,CAAA;AAE3C,UAAU,YAAY;IACpB,aAAa,EAAE,MAAM,CAAA;IACrB,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACnC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACrC;AAED;;;;;;;GAOG;AACH,wBAAsB,YAAY,CAChC,YAAY,EAAE,YAAY,EAC1B,UAAU,EAAE,UAAU,EACtB,KAAK,EAAE,YAAY,EACnB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,+BAmCpC;AAED;;;;;GAKG;AACH,wBAAsB,aAAa,CACjC,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,UAAU,CAAC,CAgBrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-runner.d.ts","sourceRoot":"","sources":["../../src/graphql/node-runner.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"node-runner.d.ts","sourceRoot":"","sources":["../../src/graphql/node-runner.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAyC,UAAU,EAAE,MAAM,MAAM,CAAA;AAsD7E,qBAAa,UAAU;IACrB,OAAO,CAAC,UAAU,CAAC,CAA2B;IAC9C,OAAO,CAAC,GAAG,CAAC,CAAoC;IAChD,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAY;gBAEjC,gBAAgB,GAAE,UAAe;IAIvC,IAAI;IAYJ,UAAU,CAAC,QAAQ,EAAE,MAAM;IAa3B,KAAK;CAGZ"}
|
|
@@ -1,24 +1,28 @@
|
|
|
1
|
-
import { createServer,
|
|
2
|
-
import { ViteNodeRunner } from "vite-node/client";
|
|
3
|
-
import { ViteNodeServer } from "vite-node/server";
|
|
4
|
-
import { installSourcemapsSupport } from "vite-node/source-map";
|
|
1
|
+
import { createServer, isRunnableDevEnvironment, mergeConfig } from "vite";
|
|
5
2
|
import { getPaths } from "@cedarjs/project-config";
|
|
6
3
|
import {
|
|
7
4
|
cedarCellTransform,
|
|
8
|
-
|
|
5
|
+
cedarjsResolveCedarStyleImportsPlugin,
|
|
9
6
|
cedarjsJobPathInjectorPlugin,
|
|
10
|
-
cedarSwapApolloProvider
|
|
7
|
+
cedarSwapApolloProvider,
|
|
8
|
+
cedarCjsCompatPlugin,
|
|
9
|
+
cedarImportDirPlugin
|
|
11
10
|
} from "@cedarjs/vite";
|
|
12
11
|
import { cedarAutoImportsPlugin } from "./vite-plugin-cedar-auto-import.js";
|
|
13
|
-
import { cedarImportDirPlugin } from "./vite-plugin-cedar-import-dir.js";
|
|
14
12
|
async function createViteServer(customConfig = {}) {
|
|
15
13
|
const defaultConfig = {
|
|
16
14
|
mode: "production",
|
|
17
15
|
optimizeDeps: {
|
|
18
|
-
// This is recommended in the vite-node readme
|
|
19
16
|
noDiscovery: true,
|
|
20
17
|
include: void 0
|
|
21
18
|
},
|
|
19
|
+
server: {
|
|
20
|
+
hmr: false,
|
|
21
|
+
watch: null
|
|
22
|
+
},
|
|
23
|
+
environments: {
|
|
24
|
+
nodeRunnerEnv: {}
|
|
25
|
+
},
|
|
22
26
|
resolve: {
|
|
23
27
|
alias: [
|
|
24
28
|
{
|
|
@@ -28,9 +32,10 @@ async function createViteServer(customConfig = {}) {
|
|
|
28
32
|
]
|
|
29
33
|
},
|
|
30
34
|
plugins: [
|
|
35
|
+
cedarCjsCompatPlugin(),
|
|
31
36
|
cedarImportDirPlugin(),
|
|
32
37
|
cedarAutoImportsPlugin(),
|
|
33
|
-
|
|
38
|
+
cedarjsResolveCedarStyleImportsPlugin(),
|
|
34
39
|
cedarCellTransform(),
|
|
35
40
|
cedarjsJobPathInjectorPlugin(),
|
|
36
41
|
cedarSwapApolloProvider()
|
|
@@ -38,48 +43,33 @@ async function createViteServer(customConfig = {}) {
|
|
|
38
43
|
};
|
|
39
44
|
const mergedConfig = mergeConfig(defaultConfig, customConfig);
|
|
40
45
|
const server = await createServer(mergedConfig);
|
|
41
|
-
if (Number(viteVersion.split(".")[0]) < 6) {
|
|
42
|
-
await server.pluginContainer.buildStart({});
|
|
43
|
-
}
|
|
44
46
|
return server;
|
|
45
47
|
}
|
|
46
48
|
class NodeRunner {
|
|
47
49
|
viteServer = void 0;
|
|
48
|
-
|
|
50
|
+
env = void 0;
|
|
49
51
|
customViteConfig;
|
|
50
52
|
constructor(customViteConfig = {}) {
|
|
51
53
|
this.customViteConfig = customViteConfig;
|
|
52
54
|
}
|
|
53
55
|
async init() {
|
|
54
56
|
this.viteServer = await createViteServer(this.customViteConfig);
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
fallbackCJS: true
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
installSourcemapsSupport({
|
|
65
|
-
getSourceMap: (source) => nodeServer?.getSourceMap(source)
|
|
66
|
-
});
|
|
67
|
-
this.runner = new ViteNodeRunner({
|
|
68
|
-
root: this.viteServer.config.root,
|
|
69
|
-
base: this.viteServer.config.base,
|
|
70
|
-
fetchModule(id) {
|
|
71
|
-
return nodeServer.fetchModule(id);
|
|
72
|
-
},
|
|
73
|
-
resolveId(id, importer) {
|
|
74
|
-
return nodeServer.resolveId(id, importer);
|
|
75
|
-
}
|
|
76
|
-
});
|
|
57
|
+
const env = this.viteServer.environments.nodeRunnerEnv;
|
|
58
|
+
if (!env || !isRunnableDevEnvironment(env)) {
|
|
59
|
+
await this.viteServer.close();
|
|
60
|
+
throw new Error("Vite environment is not runnable.");
|
|
61
|
+
}
|
|
62
|
+
this.env = env;
|
|
77
63
|
}
|
|
78
64
|
async importFile(filePath) {
|
|
79
|
-
if (!this.
|
|
65
|
+
if (!this.env) {
|
|
80
66
|
await this.init();
|
|
81
67
|
}
|
|
82
|
-
|
|
68
|
+
const env = this.env;
|
|
69
|
+
if (!env) {
|
|
70
|
+
throw new Error("NodeRunner failed to initialize");
|
|
71
|
+
}
|
|
72
|
+
return env.runner.import(filePath);
|
|
83
73
|
}
|
|
84
74
|
async close() {
|
|
85
75
|
await this.viteServer?.close();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./runPrerender.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runPrerender.d.ts","sourceRoot":"","sources":["../src/runPrerender.tsx"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AA8Q7C,UAAU,eAAe;IACvB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;IACrC,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,eAAO,MAAM,YAAY,GAAU,6BAGhC,eAAe,KAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAqIzC,CAAA;AAGD,eAAO,MAAM,wBAAwB,GACnC,gBAAgB,MAAM,EACtB,SAAS,MAAM,SAchB,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import React from "react";
|
|
4
|
-
import
|
|
4
|
+
import { ApolloClient, ApolloLink, InMemoryCache } from "@apollo/client";
|
|
5
5
|
import { load as loadHtml } from "cheerio";
|
|
6
6
|
import ReactDOMServer from "react-dom/server";
|
|
7
7
|
import {
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
importStatementPath
|
|
11
11
|
} from "@cedarjs/project-config";
|
|
12
12
|
import { matchPath } from "@cedarjs/router/dist/util";
|
|
13
|
+
import { hasApolloState } from "./apolloState.js";
|
|
13
14
|
import { buildAndImport } from "./build-and-import/buildAndImport.js";
|
|
14
15
|
import { detectPrerenderRoutes } from "./detection/detection.js";
|
|
15
16
|
import {
|
|
@@ -20,9 +21,21 @@ import {
|
|
|
20
21
|
import { executeQuery, getGqlHandler } from "./graphql/graphql.js";
|
|
21
22
|
import { NodeRunner } from "./graphql/node-runner.js";
|
|
22
23
|
import { getRootHtmlPath, registerShims, writeToDist } from "./internal.js";
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
const prerenderApolloClient = new ApolloClient({
|
|
25
|
+
cache: new InMemoryCache(),
|
|
26
|
+
link: ApolloLink.empty()
|
|
27
|
+
});
|
|
28
|
+
async function recursivelyRender(args) {
|
|
29
|
+
const {
|
|
30
|
+
App,
|
|
31
|
+
Routes,
|
|
32
|
+
CellCacheContextProvider,
|
|
33
|
+
LocationProvider,
|
|
34
|
+
renderPath,
|
|
35
|
+
fileImporter,
|
|
36
|
+
gqlHandler,
|
|
37
|
+
queryCache
|
|
38
|
+
} = args;
|
|
26
39
|
const { getOperationName } = await import("@cedarjs/web");
|
|
27
40
|
let shouldShowGraphqlHandlerNotFoundWarn = false;
|
|
28
41
|
await Promise.all(
|
|
@@ -39,13 +52,13 @@ async function recursivelyRender(App, Routes, CellCacheContextProvider, Location
|
|
|
39
52
|
);
|
|
40
53
|
let result;
|
|
41
54
|
try {
|
|
42
|
-
result = JSON.parse(resultString);
|
|
55
|
+
result = JSON.parse(resultString ?? "");
|
|
43
56
|
} catch (e) {
|
|
44
57
|
if (e instanceof SyntaxError) {
|
|
45
58
|
throw new JSONParseError({
|
|
46
59
|
query: value.query,
|
|
47
60
|
variables: value.variables,
|
|
48
|
-
result: resultString
|
|
61
|
+
result: resultString ?? ""
|
|
49
62
|
});
|
|
50
63
|
}
|
|
51
64
|
}
|
|
@@ -89,16 +102,7 @@ async function recursivelyRender(App, Routes, CellCacheContextProvider, Location
|
|
|
89
102
|
/* @__PURE__ */ React.createElement(LocationProvider, { location: new URL(prerenderUrl) }, /* @__PURE__ */ React.createElement(CellCacheContextProvider, { queryCache }, /* @__PURE__ */ React.createElement(App, null, /* @__PURE__ */ React.createElement(Routes, null))))
|
|
90
103
|
);
|
|
91
104
|
if (Object.values(queryCache).some((value) => !value.hasProcessed)) {
|
|
92
|
-
return recursivelyRender(
|
|
93
|
-
App,
|
|
94
|
-
Routes,
|
|
95
|
-
CellCacheContextProvider,
|
|
96
|
-
LocationProvider,
|
|
97
|
-
renderPath,
|
|
98
|
-
fileImporter,
|
|
99
|
-
gqlHandler,
|
|
100
|
-
queryCache
|
|
101
|
-
);
|
|
105
|
+
return recursivelyRender(args);
|
|
102
106
|
} else {
|
|
103
107
|
if (shouldShowGraphqlHandlerNotFoundWarn) {
|
|
104
108
|
console.warn(
|
|
@@ -130,7 +134,7 @@ function insertChunkLoadingScript(indexHtmlTree, renderPath) {
|
|
|
130
134
|
);
|
|
131
135
|
const chunkPaths = [];
|
|
132
136
|
if (route?.filePath) {
|
|
133
|
-
const pagesIndex = route.filePath.indexOf(path.join("web", "src", "pages")) +
|
|
137
|
+
const pagesIndex = route.filePath.indexOf(path.join("web", "src", "pages")) + 4;
|
|
134
138
|
const pagePath = ensurePosixPath(route.filePath.slice(pagesIndex));
|
|
135
139
|
const pageChunkPath = buildManifest[pagePath]?.file;
|
|
136
140
|
if (pageChunkPath) {
|
|
@@ -180,48 +184,54 @@ const runPrerender = async ({
|
|
|
180
184
|
}) => {
|
|
181
185
|
registerShims(renderPath);
|
|
182
186
|
const nodeRunner = new NodeRunner();
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
187
|
+
let componentAsHtml;
|
|
188
|
+
try {
|
|
189
|
+
const gqlHandler = await getGqlHandler(
|
|
190
|
+
nodeRunner.importFile.bind(nodeRunner)
|
|
191
|
+
);
|
|
192
|
+
const prerenderDistPath = path.join(getPaths().web.dist, "__prerender");
|
|
193
|
+
fs.mkdirSync(prerenderDistPath, { recursive: true });
|
|
194
|
+
if (!renderCache.App) {
|
|
195
|
+
const entryPath = await createCombinedEntry({
|
|
196
|
+
appPath: getPaths().web.app,
|
|
197
|
+
routesPath: getPaths().web.routes,
|
|
198
|
+
outDir: prerenderDistPath
|
|
199
|
+
});
|
|
200
|
+
const required = await buildAndImport({
|
|
201
|
+
filepath: entryPath,
|
|
202
|
+
preserveTemporaryFile: true
|
|
203
|
+
});
|
|
204
|
+
renderCache.App = required.App;
|
|
205
|
+
renderCache.Routes = required.Routes;
|
|
206
|
+
renderCache.CellCacheContextProvider = required.CellCacheContextProvider;
|
|
207
|
+
renderCache.LocationProvider = required.LocationProvider;
|
|
208
|
+
}
|
|
209
|
+
const { LocationProvider, App, Routes, CellCacheContextProvider } = renderCache;
|
|
210
|
+
if (!App) {
|
|
211
|
+
throw new Error("App not found");
|
|
212
|
+
}
|
|
213
|
+
if (!Routes) {
|
|
214
|
+
throw new Error("Routes not found");
|
|
215
|
+
}
|
|
216
|
+
if (!CellCacheContextProvider) {
|
|
217
|
+
throw new Error("CellCacheContextProvider not found");
|
|
218
|
+
}
|
|
219
|
+
if (!LocationProvider) {
|
|
220
|
+
throw new Error("LocationProvider not found");
|
|
221
|
+
}
|
|
222
|
+
componentAsHtml = await recursivelyRender({
|
|
223
|
+
App,
|
|
224
|
+
Routes,
|
|
225
|
+
CellCacheContextProvider,
|
|
226
|
+
LocationProvider,
|
|
227
|
+
renderPath,
|
|
228
|
+
fileImporter: nodeRunner.importFile.bind(nodeRunner),
|
|
229
|
+
gqlHandler,
|
|
230
|
+
queryCache
|
|
195
231
|
});
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
renderCache.CellCacheContextProvider = required.CellCacheContextProvider;
|
|
199
|
-
renderCache.LocationProvider = required.LocationProvider;
|
|
200
|
-
}
|
|
201
|
-
const { LocationProvider, App, Routes, CellCacheContextProvider } = renderCache;
|
|
202
|
-
if (!App) {
|
|
203
|
-
throw new Error("App not found");
|
|
204
|
-
}
|
|
205
|
-
if (!Routes) {
|
|
206
|
-
throw new Error("Routes not found");
|
|
207
|
-
}
|
|
208
|
-
if (!CellCacheContextProvider) {
|
|
209
|
-
throw new Error("CellCacheContextProvider not found");
|
|
210
|
-
}
|
|
211
|
-
if (!LocationProvider) {
|
|
212
|
-
throw new Error("LocationProvider not found");
|
|
232
|
+
} finally {
|
|
233
|
+
await nodeRunner.close();
|
|
213
234
|
}
|
|
214
|
-
const componentAsHtml = await recursivelyRender(
|
|
215
|
-
App,
|
|
216
|
-
Routes,
|
|
217
|
-
CellCacheContextProvider,
|
|
218
|
-
LocationProvider,
|
|
219
|
-
renderPath,
|
|
220
|
-
nodeRunner.importFile.bind(nodeRunner),
|
|
221
|
-
gqlHandler,
|
|
222
|
-
queryCache
|
|
223
|
-
);
|
|
224
|
-
nodeRunner.close();
|
|
225
235
|
const { helmet } = globalThis.__REDWOOD__HELMET_CONTEXT;
|
|
226
236
|
Object.keys(queryCache).forEach((queryKey) => {
|
|
227
237
|
const { query, variables, data } = queryCache[queryKey];
|
|
@@ -250,14 +260,17 @@ const runPrerender = async ({
|
|
|
250
260
|
}
|
|
251
261
|
}
|
|
252
262
|
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
263
|
+
const apolloState = prerenderApolloClient.extract();
|
|
264
|
+
if (hasApolloState(apolloState)) {
|
|
265
|
+
indexHtmlTree("head").append(
|
|
266
|
+
`<script> globalThis.__CEDAR__APOLLO_STATE = ${JSON.stringify(
|
|
267
|
+
apolloState
|
|
268
|
+
)}</script>`
|
|
269
|
+
);
|
|
270
|
+
}
|
|
258
271
|
prerenderApolloClient.resetStore();
|
|
259
272
|
insertChunkLoadingScript(indexHtmlTree, renderPath);
|
|
260
|
-
indexHtmlTree("#redwood-app").append(componentAsHtml);
|
|
273
|
+
indexHtmlTree("#cedar-app, #redwood-app").append(componentAsHtml);
|
|
261
274
|
const renderOutput = indexHtmlTree.html();
|
|
262
275
|
return renderOutput;
|
|
263
276
|
};
|