@cedarjs/prerender 5.0.6 → 5.0.7-next.219

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.
Files changed (25) hide show
  1. package/dist/babelPlugins/babel-plugin-redwood-cell.d.ts.map +1 -1
  2. package/dist/babelPlugins/babel-plugin-redwood-cell.js +2 -1
  3. package/dist/babelPlugins/babel-plugin-redwood-prerender-media-imports.d.ts.map +1 -1
  4. package/dist/babelPlugins/babel-plugin-redwood-prerender-media-imports.js +2 -1
  5. package/dist/build-and-import/rollupPlugins/rollup-plugin-cedarjs-cell.d.ts.map +1 -1
  6. package/dist/build-and-import/rollupPlugins/rollup-plugin-cedarjs-cell.js +2 -1
  7. package/dist/build-and-import/rollupPlugins/rollup-plugin-cedarjs-ignore-html-and-css-imports.d.ts +4 -3
  8. package/dist/build-and-import/rollupPlugins/rollup-plugin-cedarjs-ignore-html-and-css-imports.d.ts.map +1 -1
  9. package/dist/build-and-import/rollupPlugins/rollup-plugin-cedarjs-prerender-media-imports.d.ts.map +1 -1
  10. package/dist/cjs/babelPlugins/babel-plugin-redwood-cell.d.ts.map +1 -1
  11. package/dist/cjs/babelPlugins/babel-plugin-redwood-cell.js +2 -1
  12. package/dist/cjs/babelPlugins/babel-plugin-redwood-prerender-media-imports.d.ts.map +1 -1
  13. package/dist/cjs/babelPlugins/babel-plugin-redwood-prerender-media-imports.js +2 -1
  14. package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-cell.js +2 -1
  15. package/dist/cjs/graphql/node-runner.js +1 -2
  16. package/dist/cjs/runPrerender.d.ts.map +1 -1
  17. package/dist/cjs/runPrerender.js +6 -6
  18. package/dist/cjs/runPrerenderEsm.js +1 -1
  19. package/dist/graphql/node-runner.js +2 -2
  20. package/dist/runPrerenderEsm.js +1 -1
  21. package/package.json +14 -15
  22. package/dist/cjs/graphql/vite-plugin-cedar-import-dir.js +0 -118
  23. package/dist/graphql/vite-plugin-cedar-import-dir.d.ts +0 -19
  24. package/dist/graphql/vite-plugin-cedar-import-dir.d.ts.map +0 -1
  25. package/dist/graphql/vite-plugin-cedar-import-dir.js +0 -84
@@ -1 +1 @@
1
- {"version":3,"file":"babel-plugin-redwood-cell.d.ts","sourceRoot":"","sources":["../../src/babelPlugins/babel-plugin-redwood-cell.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AA+BnD,wBAAgB,sBAAsB,CAAC,EACrC,KAAK,EAAE,CAAC,GACT,EAAE;IACD,KAAK,EAAE,OAAO,KAAK,CAAA;CACpB,GAAG,SAAS,CAgHZ"}
1
+ {"version":3,"file":"babel-plugin-redwood-cell.d.ts","sourceRoot":"","sources":["../../src/babelPlugins/babel-plugin-redwood-cell.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAgCnD,wBAAgB,sBAAsB,CAAC,EACrC,KAAK,EAAE,CAAC,GACT,EAAE;IACD,KAAK,EAAE,OAAO,KAAK,CAAA;CACpB,GAAG,SAAS,CAmHZ"}
@@ -2,6 +2,7 @@ import { parse } from "path";
2
2
  const EXPECTED_EXPORTS_FROM_CELL = [
3
3
  "beforeQuery",
4
4
  "QUERY",
5
+ "FRAGMENT",
5
6
  "data",
6
7
  "isEmpty",
7
8
  "afterQuery",
@@ -44,7 +45,7 @@ function babelPluginRedwoodCell({
44
45
  hasDefaultExport = false;
45
46
  },
46
47
  exit(path) {
47
- const hasQueryOrDataExport = exportNames.includes("QUERY") || exportNames.includes("data");
48
+ const hasQueryOrDataExport = exportNames.includes("QUERY") || exportNames.includes("FRAGMENT") || exportNames.includes("data");
48
49
  if (hasDefaultExport || !hasQueryOrDataExport) {
49
50
  return;
50
51
  }
@@ -1 +1 @@
1
- {"version":3,"file":"babel-plugin-redwood-prerender-media-imports.d.ts","sourceRoot":"","sources":["../../src/babelPlugins/babel-plugin-redwood-prerender-media-imports.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAY,MAAM,aAAa,CAAA;AAyC7D,wBAAgB,uCAAuC,CAAC,EACtD,KAAK,EAAE,CAAC,GACT,EAAE;IACD,KAAK,EAAE,OAAO,KAAK,CAAA;CACpB,GAAG,SAAS,CAqDZ"}
1
+ {"version":3,"file":"babel-plugin-redwood-prerender-media-imports.d.ts","sourceRoot":"","sources":["../../src/babelPlugins/babel-plugin-redwood-prerender-media-imports.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAY,MAAM,aAAa,CAAA;AAuC7D,wBAAgB,uCAAuC,CAAC,EACtD,KAAK,EAAE,CAAC,GACT,EAAE;IACD,KAAK,EAAE,OAAO,KAAK,CAAA;CACpB,GAAG,SAAS,CAqDZ"}
@@ -2,7 +2,8 @@ import { extname, join, relative, dirname } from "path";
2
2
  import { ensurePosixPath, getPaths } from "@cedarjs/project-config";
3
3
  import { convertToDataUrl } from "./utils.js";
4
4
  const defaultOptions = {
5
- // This list of extensions matches config for file-loader in
5
+ // Media file extensions that Vite emits as assets, and that we therefore
6
+ // have to resolve to their built asset path (or a data URL) when prerendering
6
7
  extensions: [
7
8
  ".ico",
8
9
  ".jpg",
@@ -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;AAmBpC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,CAmK5C"}
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
  }
@@ -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 with empty modules.
4
- * This is useful when bundling code that imports these files for webpack or other bundlers,
5
- * but you want Rollup to ignore them during the build process.
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;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,6BAA6B,QAAO,YAyBhD,CAAA"}
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"}
@@ -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;AA6BpC,MAAM,WAAW,4BAA4B;IAC3C,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;CACtB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,kCAAkC,CAChD,OAAO,GAAE,4BAAiC,GACzC,MAAM,CA0ER"}
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"}
@@ -1 +1 @@
1
- {"version":3,"file":"babel-plugin-redwood-cell.d.ts","sourceRoot":"","sources":["../../../src/babelPlugins/babel-plugin-redwood-cell.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AA+BnD,wBAAgB,sBAAsB,CAAC,EACrC,KAAK,EAAE,CAAC,GACT,EAAE;IACD,KAAK,EAAE,OAAO,KAAK,CAAA;CACpB,GAAG,SAAS,CAgHZ"}
1
+ {"version":3,"file":"babel-plugin-redwood-cell.d.ts","sourceRoot":"","sources":["../../../src/babelPlugins/babel-plugin-redwood-cell.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAgCnD,wBAAgB,sBAAsB,CAAC,EACrC,KAAK,EAAE,CAAC,GACT,EAAE;IACD,KAAK,EAAE,OAAO,KAAK,CAAA;CACpB,GAAG,SAAS,CAmHZ"}
@@ -25,6 +25,7 @@ var import_path = require("path");
25
25
  const EXPECTED_EXPORTS_FROM_CELL = [
26
26
  "beforeQuery",
27
27
  "QUERY",
28
+ "FRAGMENT",
28
29
  "data",
29
30
  "isEmpty",
30
31
  "afterQuery",
@@ -67,7 +68,7 @@ function babelPluginRedwoodCell({
67
68
  hasDefaultExport = false;
68
69
  },
69
70
  exit(path) {
70
- const hasQueryOrDataExport = exportNames.includes("QUERY") || exportNames.includes("data");
71
+ const hasQueryOrDataExport = exportNames.includes("QUERY") || exportNames.includes("FRAGMENT") || exportNames.includes("data");
71
72
  if (hasDefaultExport || !hasQueryOrDataExport) {
72
73
  return;
73
74
  }
@@ -1 +1 @@
1
- {"version":3,"file":"babel-plugin-redwood-prerender-media-imports.d.ts","sourceRoot":"","sources":["../../../src/babelPlugins/babel-plugin-redwood-prerender-media-imports.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAY,MAAM,aAAa,CAAA;AAyC7D,wBAAgB,uCAAuC,CAAC,EACtD,KAAK,EAAE,CAAC,GACT,EAAE;IACD,KAAK,EAAE,OAAO,KAAK,CAAA;CACpB,GAAG,SAAS,CAqDZ"}
1
+ {"version":3,"file":"babel-plugin-redwood-prerender-media-imports.d.ts","sourceRoot":"","sources":["../../../src/babelPlugins/babel-plugin-redwood-prerender-media-imports.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAY,MAAM,aAAa,CAAA;AAuC7D,wBAAgB,uCAAuC,CAAC,EACtD,KAAK,EAAE,CAAC,GACT,EAAE;IACD,KAAK,EAAE,OAAO,KAAK,CAAA;CACpB,GAAG,SAAS,CAqDZ"}
@@ -25,7 +25,8 @@ var import_path = require("path");
25
25
  var import_project_config = require("@cedarjs/project-config");
26
26
  var import_utils = require("./utils.js");
27
27
  const defaultOptions = {
28
- // This list of extensions matches config for file-loader in
28
+ // Media file extensions that Vite emits as assets, and that we therefore
29
+ // have to resolve to their built asset path (or a data URL) when prerendering
29
30
  extensions: [
30
31
  ".ico",
31
32
  ".jpg",
@@ -40,6 +40,7 @@ const generate = import_generator.default.default;
40
40
  const EXPECTED_EXPORTS_FROM_CELL = [
41
41
  "beforeQuery",
42
42
  "QUERY",
43
+ "FRAGMENT",
43
44
  "data",
44
45
  "isEmpty",
45
46
  "afterQuery",
@@ -97,7 +98,7 @@ function cellTransformPlugin() {
97
98
  }
98
99
  }
99
100
  });
100
- const hasQueryOrDataExport = exportNames.includes("QUERY") || exportNames.includes("data");
101
+ const hasQueryOrDataExport = exportNames.includes("QUERY") || exportNames.includes("FRAGMENT") || exportNames.includes("data");
101
102
  if (hasDefaultExport || !hasQueryOrDataExport) {
102
103
  return null;
103
104
  }
@@ -25,7 +25,6 @@ var import_vite = require("vite");
25
25
  var import_project_config = require("@cedarjs/project-config");
26
26
  var import_vite2 = require("@cedarjs/vite");
27
27
  var import_vite_plugin_cedar_auto_import = require("./vite-plugin-cedar-auto-import.js");
28
- var import_vite_plugin_cedar_import_dir = require("./vite-plugin-cedar-import-dir.js");
29
28
  async function createViteServer(customConfig = {}) {
30
29
  const defaultConfig = {
31
30
  mode: "production",
@@ -50,7 +49,7 @@ async function createViteServer(customConfig = {}) {
50
49
  },
51
50
  plugins: [
52
51
  (0, import_vite2.cedarCjsCompatPlugin)(),
53
- (0, import_vite_plugin_cedar_import_dir.cedarImportDirPlugin)(),
52
+ (0, import_vite2.cedarImportDirPlugin)(),
54
53
  (0, import_vite_plugin_cedar_auto_import.cedarAutoImportsPlugin)(),
55
54
  (0, import_vite2.cedarjsResolveCedarStyleImportsPlugin)(),
56
55
  (0, import_vite2.cedarCellTransform)(),
@@ -1 +1 @@
1
- {"version":3,"file":"runPrerender.d.ts","sourceRoot":"","sources":["../../src/runPrerender.tsx"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAsO7C,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,CAkIzC,CAAA;AAGD,eAAO,MAAM,wBAAwB,GACnC,gBAAgB,MAAM,EACtB,SAAS,MAAM,SAchB,CAAA"}
1
+ {"version":3,"file":"runPrerender.d.ts","sourceRoot":"","sources":["../../src/runPrerender.tsx"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AA0O7C,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,CAmIzC,CAAA;AAGD,eAAO,MAAM,wBAAwB,GACnC,gBAAgB,MAAM,EACtB,SAAS,MAAM,SAchB,CAAA"}
@@ -40,8 +40,6 @@ var import_cheerio = require("cheerio");
40
40
  var import_server = __toESM(require("react-dom/server"), 1);
41
41
  var import_babel_config = require("@cedarjs/babel-config");
42
42
  var import_project_config = require("@cedarjs/project-config");
43
- var import_router = require("@cedarjs/router");
44
- var import_util = require("@cedarjs/router/dist/util");
45
43
  var import_babel_plugin_redwood_cell = require("./babelPlugins/babel-plugin-redwood-cell.js");
46
44
  var import_babel_plugin_redwood_prerender_media_imports = require("./babelPlugins/babel-plugin-redwood-prerender-media-imports.js");
47
45
  var import_detection = require("./detection/detection.js");
@@ -52,6 +50,7 @@ const { ApolloClient, InMemoryCache } = apolloClient.default || apolloClient;
52
50
  const prerenderApolloClient = new ApolloClient({ cache: new InMemoryCache() });
53
51
  async function recursivelyRender(App, Routes, renderPath, fileImporter, gqlHandler, queryCache) {
54
52
  const { CellCacheContextProvider, getOperationName } = require("@cedarjs/web");
53
+ const { LocationProvider } = require("@cedarjs/router");
55
54
  let shouldShowGraphqlHandlerNotFoundWarn = false;
56
55
  await Promise.all(
57
56
  Object.entries(queryCache).map(async ([cacheKey, value]) => {
@@ -114,7 +113,7 @@ async function recursivelyRender(App, Routes, renderPath, fileImporter, gqlHandl
114
113
  );
115
114
  const prerenderUrl = process.env.RWJS_PRERENDER_ORIGIN || "http://localhost" + renderPath;
116
115
  const componentAsHtml = import_server.default.renderToString(
117
- /* @__PURE__ */ import_react.default.createElement(import_router.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))))
116
+ /* @__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))))
118
117
  );
119
118
  if (Object.values(queryCache).some((value) => !value.hasProcessed)) {
120
119
  return recursivelyRender(
@@ -135,12 +134,13 @@ async function recursivelyRender(App, Routes, renderPath, fileImporter, gqlHandl
135
134
  }
136
135
  }
137
136
  function insertChunkLoadingScript(indexHtmlTree, renderPath) {
137
+ const { matchPath } = require("@cedarjs/router/dist/util");
138
138
  const prerenderRoutes = (0, import_detection.detectPrerenderRoutes)();
139
139
  const route = prerenderRoutes.find((route2) => {
140
140
  if (!route2.routePath) {
141
141
  return false;
142
142
  }
143
- return (0, import_util.matchPath)(route2.routePath, renderPath).match;
143
+ return matchPath(route2.routePath, renderPath).match;
144
144
  });
145
145
  if (!route) {
146
146
  throw new Error("Could not find a Route matching " + renderPath);
@@ -227,8 +227,8 @@ const runPrerender = async ({
227
227
  overrides: [
228
228
  {
229
229
  plugins: [
230
+ // Vite handles CSS imports for the browser build
230
231
  ["ignore-html-and-css-imports"],
231
- // webpack/postcss handles CSS imports
232
232
  [import_babel_plugin_redwood_prerender_media_imports.babelPluginRedwoodPrerenderMediaImports]
233
233
  ]
234
234
  },
@@ -280,7 +280,7 @@ const runPrerender = async ({
280
280
  }
281
281
  }
282
282
  indexHtmlTree("head").append(
283
- `<script> globalThis.__REDWOOD__APOLLO_STATE = ${JSON.stringify(
283
+ `<script> globalThis.__CEDAR__APOLLO_STATE = ${JSON.stringify(
284
284
  prerenderApolloClient.extract()
285
285
  )}</script>`
286
286
  );
@@ -277,7 +277,7 @@ const runPrerender = async ({
277
277
  }
278
278
  }
279
279
  indexHtmlTree("head").append(
280
- `<script> globalThis.__REDWOOD__APOLLO_STATE = ${JSON.stringify(
280
+ `<script> globalThis.__CEDAR__APOLLO_STATE = ${JSON.stringify(
281
281
  prerenderApolloClient.extract()
282
282
  )}</script>`
283
283
  );
@@ -5,10 +5,10 @@ import {
5
5
  cedarjsResolveCedarStyleImportsPlugin,
6
6
  cedarjsJobPathInjectorPlugin,
7
7
  cedarSwapApolloProvider,
8
- cedarCjsCompatPlugin
8
+ cedarCjsCompatPlugin,
9
+ cedarImportDirPlugin
9
10
  } from "@cedarjs/vite";
10
11
  import { cedarAutoImportsPlugin } from "./vite-plugin-cedar-auto-import.js";
11
- import { cedarImportDirPlugin } from "./vite-plugin-cedar-import-dir.js";
12
12
  async function createViteServer(customConfig = {}) {
13
13
  const defaultConfig = {
14
14
  mode: "production",
@@ -251,7 +251,7 @@ const runPrerender = async ({
251
251
  }
252
252
  }
253
253
  indexHtmlTree("head").append(
254
- `<script> globalThis.__REDWOOD__APOLLO_STATE = ${JSON.stringify(
254
+ `<script> globalThis.__CEDAR__APOLLO_STATE = ${JSON.stringify(
255
255
  prerenderApolloClient.extract()
256
256
  )}</script>`
257
257
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/prerender",
3
- "version": "5.0.6",
3
+ "version": "5.0.7-next.219",
4
4
  "description": "CedarJS prerender",
5
5
  "repository": {
6
6
  "type": "git",
@@ -67,19 +67,18 @@
67
67
  "test:watch": "vitest watch"
68
68
  },
69
69
  "dependencies": {
70
- "@ast-grep/napi": "0.43.0",
71
70
  "@babel/generator": "7.29.7",
72
71
  "@babel/parser": "7.29.7",
73
72
  "@babel/traverse": "7.29.7",
74
- "@cedarjs/babel-config": "5.0.6",
75
- "@cedarjs/project-config": "5.0.6",
76
- "@cedarjs/structure": "5.0.6",
77
- "@cedarjs/vite": "5.0.6",
73
+ "@cedarjs/babel-config": "5.0.7-next.219",
74
+ "@cedarjs/project-config": "5.0.7-next.219",
75
+ "@cedarjs/structure": "5.0.7-next.219",
76
+ "@cedarjs/vite": "5.0.7-next.219",
78
77
  "@rollup/plugin-alias": "5.1.1",
79
78
  "@rollup/plugin-commonjs": "28.0.9",
80
79
  "@rollup/plugin-node-resolve": "16.0.3",
81
80
  "@rollup/plugin-replace": "6.0.3",
82
- "@swc/core": "1.15.41",
81
+ "@swc/core": "1.15.46",
83
82
  "@whatwg-node/fetch": "0.10.13",
84
83
  "babel-plugin-ignore-html-and-css-imports": "0.1.0",
85
84
  "cheerio": "1.2.0",
@@ -89,23 +88,23 @@
89
88
  "rollup-plugin-swc3": "0.12.1",
90
89
  "unimport": "5.7.0",
91
90
  "unplugin-auto-import": "19.3.0",
92
- "vite": "7.3.5"
91
+ "vite": "7.3.6"
93
92
  },
94
93
  "devDependencies": {
95
- "@cedarjs/framework-tools": "5.0.6",
96
- "@cedarjs/router": "5.0.6",
97
- "@cedarjs/web": "5.0.6",
94
+ "@cedarjs/framework-tools": "5.0.7-next.219",
95
+ "@cedarjs/router": "5.0.7-next.219",
96
+ "@cedarjs/web": "5.0.7-next.219",
98
97
  "@types/mime-types": "2.1.4",
99
98
  "@types/react": "^18.2.55",
100
99
  "babel-plugin-tester": "11.0.4",
101
100
  "concurrently": "9.2.4",
102
- "publint": "0.3.21",
101
+ "publint": "0.3.22",
103
102
  "typescript": "5.9.3",
104
- "vitest": "3.2.6"
103
+ "vitest": "4.1.10"
105
104
  },
106
105
  "peerDependencies": {
107
- "@cedarjs/router": "5.0.6",
108
- "@cedarjs/web": "5.0.6",
106
+ "@cedarjs/router": "5.0.7-next.219",
107
+ "@cedarjs/web": "5.0.7-next.219",
109
108
  "react": "18.3.1",
110
109
  "react-dom": "18.3.1"
111
110
  },
@@ -1,118 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var vite_plugin_cedar_import_dir_exports = {};
30
- __export(vite_plugin_cedar_import_dir_exports, {
31
- cedarImportDirPlugin: () => cedarImportDirPlugin
32
- });
33
- module.exports = __toCommonJS(vite_plugin_cedar_import_dir_exports);
34
- var import_node_path = __toESM(require("node:path"), 1);
35
- var import_napi = require("@ast-grep/napi");
36
- var import_fast_glob = __toESM(require("fast-glob"), 1);
37
- var import_project_config = require("@cedarjs/project-config");
38
- function cedarImportDirPlugin() {
39
- return {
40
- name: "vite-plugin-cedar-import-dir",
41
- enforce: "pre",
42
- async transform(code, id) {
43
- if (!code.includes("/**/")) {
44
- return null;
45
- }
46
- const ext = import_node_path.default.extname(id);
47
- const language = ext === ".ts" || ext === ".tsx" ? import_napi.Lang.TypeScript : import_napi.Lang.JavaScript;
48
- let ast;
49
- try {
50
- ast = (0, import_napi.parse)(language, code);
51
- } catch (error) {
52
- console.warn("Failed to parse file:", id);
53
- console.warn(error);
54
- return null;
55
- }
56
- const root = ast.root();
57
- let hasTransformations = false;
58
- const edits = [];
59
- const globImports = root.findAll({
60
- rule: {
61
- pattern: "import $DEFAULT_IMPORT from $SOURCE"
62
- }
63
- });
64
- for (const importNode of globImports) {
65
- const sourceNode = importNode.getMatch("SOURCE");
66
- const defaultImportNode = importNode.getMatch("DEFAULT_IMPORT");
67
- if (!sourceNode || !defaultImportNode) {
68
- continue;
69
- }
70
- const sourceValue = sourceNode.text().slice(1, -1);
71
- if (!sourceValue.includes("/**/")) {
72
- continue;
73
- }
74
- hasTransformations = true;
75
- const importName = defaultImportNode.text();
76
- const importGlob = (0, import_project_config.importStatementPath)(sourceValue);
77
- const cwd = importGlob.startsWith("src/") ? (0, import_project_config.getPaths)().api.base : import_node_path.default.dirname(id);
78
- try {
79
- const dirFiles = import_fast_glob.default.sync(importGlob, { cwd }).filter(
80
- (n) => !n.includes(".test.") && !n.includes(".scenarios.") && !n.includes(".d.ts")
81
- );
82
- const staticGlob = importGlob.split("*")[0];
83
- const filePathToVarName = (filePath) => {
84
- return filePath.replace(staticGlob, "").replace(/\.(js|ts)$/, "").replace(/[^a-zA-Z0-9]/g, "_");
85
- };
86
- let replacement = `let ${importName} = {};
87
- `;
88
- for (const filePath of dirFiles) {
89
- const { dir: fileDir, name: fileName } = import_node_path.default.parse(filePath);
90
- const fileImportPath = fileDir + "/" + fileName;
91
- const filePathVarName = filePathToVarName(filePath);
92
- const namespaceImportName = `${importName}_${filePathVarName}`;
93
- replacement += `import * as ${namespaceImportName} from '${fileImportPath}';
94
- `;
95
- replacement += `${importName}.${filePathVarName} = ${namespaceImportName};
96
- `;
97
- }
98
- edits.push(importNode.replace(replacement.trim()));
99
- } catch (error) {
100
- console.warn(`Failed to process glob import: ${sourceValue}`, error);
101
- }
102
- }
103
- if (hasTransformations && edits.length > 0) {
104
- const transformedCode = root.commitEdits(edits);
105
- return {
106
- code: transformedCode,
107
- map: null
108
- // For simplicity, not generating source maps
109
- };
110
- }
111
- return null;
112
- }
113
- };
114
- }
115
- // Annotate the CommonJS export names for ESM import in node:
116
- 0 && (module.exports = {
117
- cedarImportDirPlugin
118
- });
@@ -1,19 +0,0 @@
1
- import type { Plugin } from 'vite';
2
- /**
3
- * This Vite plugin will search for import statements that include a glob double
4
- * star `**` in the source part of the statement. The files that are matched are
5
- * imported and appended to an object.
6
- *
7
- * @example
8
- * Given a directory "src/services" that contains "a.js", "b.ts" and
9
- * "nested/c.js" will produce the following results:
10
- * ```js
11
- * import services from 'src/services/**\/*.{js,ts}'
12
- * console.log(services)
13
- * // services.a = import('src/services/a')
14
- * // services.b = import('src/services/b')
15
- * // services.nested_c = import('src/services/nested/c')
16
- * ```
17
- */
18
- export declare function cedarImportDirPlugin(): Plugin;
19
- //# sourceMappingURL=vite-plugin-cedar-import-dir.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"vite-plugin-cedar-import-dir.d.ts","sourceRoot":"","sources":["../../src/graphql/vite-plugin-cedar-import-dir.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAIlC;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAgH7C"}
@@ -1,84 +0,0 @@
1
- import path from "node:path";
2
- import { parse, Lang } from "@ast-grep/napi";
3
- import fg from "fast-glob";
4
- import { importStatementPath, getPaths } from "@cedarjs/project-config";
5
- function cedarImportDirPlugin() {
6
- return {
7
- name: "vite-plugin-cedar-import-dir",
8
- enforce: "pre",
9
- async transform(code, id) {
10
- if (!code.includes("/**/")) {
11
- return null;
12
- }
13
- const ext = path.extname(id);
14
- const language = ext === ".ts" || ext === ".tsx" ? Lang.TypeScript : Lang.JavaScript;
15
- let ast;
16
- try {
17
- ast = parse(language, code);
18
- } catch (error) {
19
- console.warn("Failed to parse file:", id);
20
- console.warn(error);
21
- return null;
22
- }
23
- const root = ast.root();
24
- let hasTransformations = false;
25
- const edits = [];
26
- const globImports = root.findAll({
27
- rule: {
28
- pattern: "import $DEFAULT_IMPORT from $SOURCE"
29
- }
30
- });
31
- for (const importNode of globImports) {
32
- const sourceNode = importNode.getMatch("SOURCE");
33
- const defaultImportNode = importNode.getMatch("DEFAULT_IMPORT");
34
- if (!sourceNode || !defaultImportNode) {
35
- continue;
36
- }
37
- const sourceValue = sourceNode.text().slice(1, -1);
38
- if (!sourceValue.includes("/**/")) {
39
- continue;
40
- }
41
- hasTransformations = true;
42
- const importName = defaultImportNode.text();
43
- const importGlob = importStatementPath(sourceValue);
44
- const cwd = importGlob.startsWith("src/") ? getPaths().api.base : path.dirname(id);
45
- try {
46
- const dirFiles = fg.sync(importGlob, { cwd }).filter(
47
- (n) => !n.includes(".test.") && !n.includes(".scenarios.") && !n.includes(".d.ts")
48
- );
49
- const staticGlob = importGlob.split("*")[0];
50
- const filePathToVarName = (filePath) => {
51
- return filePath.replace(staticGlob, "").replace(/\.(js|ts)$/, "").replace(/[^a-zA-Z0-9]/g, "_");
52
- };
53
- let replacement = `let ${importName} = {};
54
- `;
55
- for (const filePath of dirFiles) {
56
- const { dir: fileDir, name: fileName } = path.parse(filePath);
57
- const fileImportPath = fileDir + "/" + fileName;
58
- const filePathVarName = filePathToVarName(filePath);
59
- const namespaceImportName = `${importName}_${filePathVarName}`;
60
- replacement += `import * as ${namespaceImportName} from '${fileImportPath}';
61
- `;
62
- replacement += `${importName}.${filePathVarName} = ${namespaceImportName};
63
- `;
64
- }
65
- edits.push(importNode.replace(replacement.trim()));
66
- } catch (error) {
67
- console.warn(`Failed to process glob import: ${sourceValue}`, error);
68
- }
69
- }
70
- if (hasTransformations && edits.length > 0) {
71
- const transformedCode = root.commitEdits(edits);
72
- return {
73
- code: transformedCode,
74
- map: null
75
- // For simplicity, not generating source maps
76
- };
77
- }
78
- return null;
79
- }
80
- };
81
- }
82
- export {
83
- cedarImportDirPlugin
84
- };