@cedarjs/prerender 1.0.0-canary.12482 → 1.0.0-canary.12485
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildAndImport.d.ts","sourceRoot":"","sources":["../../src/build-and-import/buildAndImport.ts"],"names":[],"mappings":"AAiCA,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,iBAAiB,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"buildAndImport.d.ts","sourceRoot":"","sources":["../../src/build-and-import/buildAndImport.ts"],"names":[],"mappings":"AAiCA,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,iBAAiB,CAAC,CAAC,CAyHlD"}
|
|
@@ -59,12 +59,7 @@ async function buildAndImport(options) {
|
|
|
59
59
|
if (!(0, import_utils.isValidJsFile)(options.filepath)) {
|
|
60
60
|
throw new Error(`${options.filepath} is not a valid JS file`);
|
|
61
61
|
}
|
|
62
|
-
console.log("options", options);
|
|
63
62
|
const tsConfigs = (0, import_internal.parseTypeScriptConfigFiles)();
|
|
64
|
-
console.log(
|
|
65
|
-
"tsConfigs.web?.data.compilerOptions",
|
|
66
|
-
tsConfigs.web?.compilerOptions
|
|
67
|
-
);
|
|
68
63
|
const resolvePaths = tsconfigPathsToRegExp(
|
|
69
64
|
tsConfigs.web?.compilerOptions?.paths || {}
|
|
70
65
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runPrerender.d.ts","sourceRoot":"","sources":["../src/runPrerender.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"runPrerender.d.ts","sourceRoot":"","sources":["../src/runPrerender.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AA4P7C,UAAU,eAAe;IACvB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;IACrC,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,eAAO,MAAM,YAAY,gCAGtB,eAAe,KAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAmHzC,CAAA;AAGD,eAAO,MAAM,wBAAwB,mBACnB,MAAM,WACb,MAAM,SAchB,CAAA"}
|
package/dist/runPrerender.js
CHANGED
|
@@ -39,7 +39,6 @@ var import_client = require("@apollo/client");
|
|
|
39
39
|
var import_cheerio = require("cheerio");
|
|
40
40
|
var import_server = __toESM(require("react-dom/server"));
|
|
41
41
|
var import_project_config = require("@cedarjs/project-config");
|
|
42
|
-
var import_router = require("@cedarjs/router");
|
|
43
42
|
var import_util = require("@cedarjs/router/dist/util");
|
|
44
43
|
var import_buildAndImport = require("./build-and-import/buildAndImport");
|
|
45
44
|
var import_detection = require("./detection");
|
|
@@ -47,7 +46,7 @@ var import_errors = require("./errors");
|
|
|
47
46
|
var import_graphql = require("./graphql/graphql");
|
|
48
47
|
var import_internal = require("./internal");
|
|
49
48
|
const prerenderApolloClient = new import_client.ApolloClient({ cache: new import_client.InMemoryCache() });
|
|
50
|
-
async function recursivelyRender(App, Routes, CellCacheContextProvider, renderPath, gqlHandler, queryCache) {
|
|
49
|
+
async function recursivelyRender(App, Routes, CellCacheContextProvider, LocationProvider, renderPath, gqlHandler, queryCache) {
|
|
51
50
|
const { getOperationName } = await import("@cedarjs/web");
|
|
52
51
|
let shouldShowGraphqlHandlerNotFoundWarn = false;
|
|
53
52
|
await Promise.all(
|
|
@@ -110,13 +109,14 @@ async function recursivelyRender(App, Routes, CellCacheContextProvider, renderPa
|
|
|
110
109
|
);
|
|
111
110
|
const prerenderUrl = process.env.RWJS_PRERENDER_ORIGIN || "http://localhost" + renderPath;
|
|
112
111
|
const componentAsHtml = import_server.default.renderToString(
|
|
113
|
-
/* @__PURE__ */ import_react.default.createElement(
|
|
112
|
+
/* @__PURE__ */ import_react.default.createElement(LocationProvider, { location: new URL(prerenderUrl) }, /* @__PURE__ */ import_react.default.createElement(CellCacheContextProvider, { queryCache }, /* @__PURE__ */ import_react.default.createElement(App, null, /* @__PURE__ */ import_react.default.createElement(Routes, null))))
|
|
114
113
|
);
|
|
115
114
|
if (Object.values(queryCache).some((value) => !value.hasProcessed)) {
|
|
116
115
|
return recursivelyRender(
|
|
117
116
|
App,
|
|
118
117
|
Routes,
|
|
119
118
|
CellCacheContextProvider,
|
|
119
|
+
LocationProvider,
|
|
120
120
|
renderPath,
|
|
121
121
|
gqlHandler,
|
|
122
122
|
queryCache
|
|
@@ -183,11 +183,13 @@ globalThis.__REDWOOD__PRERENDER_PAGES.${route?.pageIdentifier}=${varNameMatch?.[
|
|
|
183
183
|
}
|
|
184
184
|
async function createCombinedEntry({ appPath, routesPath, outDir }) {
|
|
185
185
|
const combinedContent = `
|
|
186
|
+
import { LocationProvider } from '@cedarjs/router'
|
|
187
|
+
import { CellCacheContextProvider } from '@cedarjs/web'
|
|
188
|
+
|
|
186
189
|
import App from "${(0, import_project_config.importStatementPath)(appPath.replace(".tsx", ""))}";
|
|
187
190
|
import Routes from "${(0, import_project_config.importStatementPath)(routesPath.replace(".tsx", ""))}";
|
|
188
|
-
import { CellCacheContextProvider } from '@cedarjs/web'
|
|
189
191
|
|
|
190
|
-
export { App, Routes
|
|
192
|
+
export { LocationProvider, CellCacheContextProvider, App, Routes };
|
|
191
193
|
`;
|
|
192
194
|
const tempFilePath = import_node_path.default.join(outDir, "__prerender-temp-entry.tsx");
|
|
193
195
|
await import_node_fs.default.promises.writeFile(tempFilePath, combinedContent, "utf8");
|
|
@@ -215,8 +217,9 @@ const runPrerender = async ({
|
|
|
215
217
|
renderCache.App = required.App;
|
|
216
218
|
renderCache.Routes = required.Routes;
|
|
217
219
|
renderCache.CellCacheContextProvider = required.CellCacheContextProvider;
|
|
220
|
+
renderCache.LocationProvider = required.LocationProvider;
|
|
218
221
|
}
|
|
219
|
-
const { App, Routes, CellCacheContextProvider } = renderCache;
|
|
222
|
+
const { LocationProvider, App, Routes, CellCacheContextProvider } = renderCache;
|
|
220
223
|
if (!App) {
|
|
221
224
|
throw new Error("App not found");
|
|
222
225
|
}
|
|
@@ -226,10 +229,14 @@ const runPrerender = async ({
|
|
|
226
229
|
if (!CellCacheContextProvider) {
|
|
227
230
|
throw new Error("CellCacheContextProvider not found");
|
|
228
231
|
}
|
|
232
|
+
if (!LocationProvider) {
|
|
233
|
+
throw new Error("LocationProvider not found");
|
|
234
|
+
}
|
|
229
235
|
const componentAsHtml = await recursivelyRender(
|
|
230
236
|
App,
|
|
231
237
|
Routes,
|
|
232
238
|
CellCacheContextProvider,
|
|
239
|
+
LocationProvider,
|
|
233
240
|
renderPath,
|
|
234
241
|
gqlHandler,
|
|
235
242
|
queryCache
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/prerender",
|
|
3
|
-
"version": "1.0.0-canary.
|
|
3
|
+
"version": "1.0.0-canary.12485+9eca35b85",
|
|
4
4
|
"description": "RedwoodJS prerender",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -40,11 +40,11 @@
|
|
|
40
40
|
"test:watch": "vitest watch"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@cedarjs/babel-config": "1.0.0-canary.
|
|
44
|
-
"@cedarjs/project-config": "1.0.0-canary.
|
|
45
|
-
"@cedarjs/router": "1.0.0-canary.
|
|
46
|
-
"@cedarjs/structure": "1.0.0-canary.
|
|
47
|
-
"@cedarjs/web": "1.0.0-canary.
|
|
43
|
+
"@cedarjs/babel-config": "1.0.0-canary.12485",
|
|
44
|
+
"@cedarjs/project-config": "1.0.0-canary.12485",
|
|
45
|
+
"@cedarjs/router": "1.0.0-canary.12485",
|
|
46
|
+
"@cedarjs/structure": "1.0.0-canary.12485",
|
|
47
|
+
"@cedarjs/web": "1.0.0-canary.12485",
|
|
48
48
|
"@rollup/plugin-alias": "5.1.1",
|
|
49
49
|
"@rollup/plugin-commonjs": "28.0.6",
|
|
50
50
|
"@rollup/plugin-node-resolve": "16.0.1",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"unimport": "5.0.1"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@cedarjs/framework-tools": "1.0.0-canary.
|
|
64
|
+
"@cedarjs/framework-tools": "1.0.0-canary.12485",
|
|
65
65
|
"@types/mime-types": "2.1.4",
|
|
66
66
|
"babel-plugin-tester": "11.0.4",
|
|
67
67
|
"concurrently": "8.2.2",
|
|
@@ -78,5 +78,5 @@
|
|
|
78
78
|
"react": "react",
|
|
79
79
|
"react-dom": "react-dom"
|
|
80
80
|
},
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "9eca35b85097a6799b8a8568267bc06629b2c14a"
|
|
82
82
|
}
|