@cedarjs/prerender 7.0.0-rc.128 → 7.0.1-next.305

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 (72) hide show
  1. package/dist/browserUtils/index.d.ts +1 -1
  2. package/dist/browserUtils/index.d.ts.map +1 -1
  3. package/dist/build-and-import/buildAndImport.d.ts +1 -1
  4. package/dist/build-and-import/buildAndImport.d.ts.map +1 -1
  5. package/dist/build-and-import/buildAndImport.js +2 -9
  6. package/dist/build-and-import/rollupPlugins/rollup-plugin-cedarjs-routes-auto-loader.d.ts.map +1 -1
  7. package/dist/graphql/graphql.d.ts +17 -2
  8. package/dist/graphql/graphql.d.ts.map +1 -1
  9. package/dist/{cjs/index.d.ts.map → index.d.ts.map} +1 -1
  10. package/dist/index.js +1 -0
  11. package/dist/runPrerender.d.ts.map +1 -0
  12. package/dist/{runPrerenderEsm.js → runPrerender.js} +65 -56
  13. package/package.json +20 -51
  14. package/dist/babelPlugins/babel-plugin-redwood-cell.d.ts +0 -5
  15. package/dist/babelPlugins/babel-plugin-redwood-cell.d.ts.map +0 -1
  16. package/dist/babelPlugins/babel-plugin-redwood-cell.js +0 -98
  17. package/dist/babelPlugins/babel-plugin-redwood-prerender-media-imports.d.ts +0 -5
  18. package/dist/babelPlugins/babel-plugin-redwood-prerender-media-imports.d.ts.map +0 -1
  19. package/dist/babelPlugins/babel-plugin-redwood-prerender-media-imports.js +0 -77
  20. package/dist/babelPlugins/utils.d.ts +0 -2
  21. package/dist/babelPlugins/utils.d.ts.map +0 -1
  22. package/dist/babelPlugins/utils.js +0 -15
  23. package/dist/cjs/apolloState.d.ts +0 -13
  24. package/dist/cjs/apolloState.d.ts.map +0 -1
  25. package/dist/cjs/apolloState.js +0 -30
  26. package/dist/cjs/babelPlugins/babel-plugin-redwood-cell.d.ts +0 -5
  27. package/dist/cjs/babelPlugins/babel-plugin-redwood-cell.d.ts.map +0 -1
  28. package/dist/cjs/babelPlugins/babel-plugin-redwood-cell.js +0 -122
  29. package/dist/cjs/babelPlugins/babel-plugin-redwood-prerender-media-imports.d.ts +0 -5
  30. package/dist/cjs/babelPlugins/babel-plugin-redwood-prerender-media-imports.d.ts.map +0 -1
  31. package/dist/cjs/babelPlugins/babel-plugin-redwood-prerender-media-imports.js +0 -101
  32. package/dist/cjs/babelPlugins/utils.d.ts +0 -2
  33. package/dist/cjs/babelPlugins/utils.d.ts.map +0 -1
  34. package/dist/cjs/babelPlugins/utils.js +0 -49
  35. package/dist/cjs/browserUtils/index.d.ts +0 -8
  36. package/dist/cjs/browserUtils/index.d.ts.map +0 -1
  37. package/dist/cjs/browserUtils/index.js +0 -47
  38. package/dist/cjs/build-and-import/buildAndImport.js +0 -193
  39. package/dist/cjs/build-and-import/load-tsconfig.d.js +0 -1
  40. package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedar-remove-dev-fatal-error-page.js +0 -53
  41. package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-cell.js +0 -184
  42. package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-directory-named-imports.js +0 -83
  43. package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-external.js +0 -125
  44. package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-ignore-html-and-css-imports.js +0 -48
  45. package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-inject-file-globals.js +0 -66
  46. package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-prerender-media-imports.js +0 -118
  47. package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-routes-auto-loader.js +0 -146
  48. package/dist/cjs/build-and-import/rollupPlugins/utils.js +0 -78
  49. package/dist/cjs/build-and-import/utils.js +0 -68
  50. package/dist/cjs/detection/detection.d.ts +0 -11
  51. package/dist/cjs/detection/detection.d.ts.map +0 -1
  52. package/dist/cjs/detection/detection.js +0 -46
  53. package/dist/cjs/errors.d.ts +0 -19
  54. package/dist/cjs/errors.d.ts.map +0 -1
  55. package/dist/cjs/errors.js +0 -52
  56. package/dist/cjs/graphql/graphql.d.ts +0 -19
  57. package/dist/cjs/graphql/graphql.d.ts.map +0 -1
  58. package/dist/cjs/graphql/graphql.js +0 -152
  59. package/dist/cjs/graphql/node-runner.js +0 -97
  60. package/dist/cjs/graphql/vite-plugin-cedar-auto-import.js +0 -107
  61. package/dist/cjs/index.js +0 -22
  62. package/dist/cjs/internal.d.ts +0 -28
  63. package/dist/cjs/internal.d.ts.map +0 -1
  64. package/dist/cjs/internal.js +0 -135
  65. package/dist/cjs/package.json +0 -1
  66. package/dist/cjs/runPrerender.d.ts.map +0 -1
  67. package/dist/cjs/runPrerender.js +0 -311
  68. package/dist/cjs/runPrerenderEsm.js +0 -308
  69. package/dist/runPrerenderEsm.d.ts +0 -9
  70. package/dist/runPrerenderEsm.d.ts.map +0 -1
  71. /package/dist/{cjs/index.d.ts → index.d.ts} +0 -0
  72. /package/dist/{cjs/runPrerender.d.ts → runPrerender.d.ts} +0 -0
@@ -1,30 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var apolloState_exports = {};
20
- __export(apolloState_exports, {
21
- hasApolloState: () => hasApolloState
22
- });
23
- module.exports = __toCommonJS(apolloState_exports);
24
- function hasApolloState(state) {
25
- return typeof state === "object" && state !== null && Object.keys(state).length > 0;
26
- }
27
- // Annotate the CommonJS export names for ESM import in node:
28
- 0 && (module.exports = {
29
- hasApolloState
30
- });
@@ -1,5 +0,0 @@
1
- import type { PluginObj, types } from '@babel/core';
2
- export declare function babelPluginRedwoodCell({ types: t, }: {
3
- types: typeof types;
4
- }): PluginObj;
5
- //# sourceMappingURL=babel-plugin-redwood-cell.d.ts.map
@@ -1 +0,0 @@
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"}
@@ -1,122 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var babel_plugin_redwood_cell_exports = {};
20
- __export(babel_plugin_redwood_cell_exports, {
21
- babelPluginRedwoodCell: () => babelPluginRedwoodCell
22
- });
23
- module.exports = __toCommonJS(babel_plugin_redwood_cell_exports);
24
- var import_path = require("path");
25
- const EXPECTED_EXPORTS_FROM_CELL = [
26
- "beforeQuery",
27
- "QUERY",
28
- "FRAGMENT",
29
- "data",
30
- "isEmpty",
31
- "afterQuery",
32
- "Loading",
33
- "Success",
34
- "Failure",
35
- "Empty"
36
- ];
37
- function babelPluginRedwoodCell({
38
- types: t
39
- }) {
40
- let exportNames = [];
41
- let hasDefaultExport = false;
42
- return {
43
- name: "babel-plugin-redwood-cell",
44
- visitor: {
45
- ExportDefaultDeclaration() {
46
- hasDefaultExport = true;
47
- },
48
- ExportNamedDeclaration(path) {
49
- const declaration = path.node.declaration;
50
- if (!declaration) {
51
- return;
52
- }
53
- let name;
54
- if (declaration.type === "VariableDeclaration") {
55
- const id = declaration.declarations[0].id;
56
- name = id.name;
57
- }
58
- if (declaration.type === "FunctionDeclaration") {
59
- name = declaration?.id?.name;
60
- }
61
- if (name && EXPECTED_EXPORTS_FROM_CELL.includes(name)) {
62
- exportNames.push(name);
63
- }
64
- },
65
- Program: {
66
- enter() {
67
- exportNames = [];
68
- hasDefaultExport = false;
69
- },
70
- exit(path) {
71
- const hasQueryOrDataExport = exportNames.includes("QUERY") || exportNames.includes("FRAGMENT") || exportNames.includes("data");
72
- if (hasDefaultExport || !hasQueryOrDataExport) {
73
- return;
74
- }
75
- const createCellHookName = exportNames.includes("data") ? "createServerCell" : "createCell";
76
- const importFrom = exportNames.includes("data") ? "@cedarjs/web/dist/components/cell/createServerCell" : "@cedarjs/web";
77
- path.node.body.unshift(
78
- t.importDeclaration(
79
- [
80
- t.importSpecifier(
81
- t.identifier(createCellHookName),
82
- t.identifier(createCellHookName)
83
- )
84
- ],
85
- t.stringLiteral(importFrom)
86
- )
87
- );
88
- path.node.body.push(
89
- t.exportDefaultDeclaration(
90
- t.callExpression(t.identifier(createCellHookName), [
91
- t.objectExpression([
92
- ...exportNames.map(
93
- (name) => t.objectProperty(
94
- t.identifier(name),
95
- t.identifier(name),
96
- false,
97
- true
98
- )
99
- ),
100
- // Add the `displayName` property so we can name the Cell
101
- // after the filename.
102
- t.objectProperty(
103
- t.identifier("displayName"),
104
- t.stringLiteral(
105
- (0, import_path.parse)(this.file.opts.filename).name
106
- ),
107
- false,
108
- true
109
- )
110
- ])
111
- ])
112
- )
113
- );
114
- }
115
- }
116
- }
117
- };
118
- }
119
- // Annotate the CommonJS export names for ESM import in node:
120
- 0 && (module.exports = {
121
- babelPluginRedwoodCell
122
- });
@@ -1,5 +0,0 @@
1
- import type { PluginObj, types } from '@babel/core';
2
- export declare function babelPluginRedwoodPrerenderMediaImports({ types: t, }: {
3
- types: typeof types;
4
- }): PluginObj;
5
- //# sourceMappingURL=babel-plugin-redwood-prerender-media-imports.d.ts.map
@@ -1 +0,0 @@
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"}
@@ -1,101 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var babel_plugin_redwood_prerender_media_imports_exports = {};
20
- __export(babel_plugin_redwood_prerender_media_imports_exports, {
21
- babelPluginRedwoodPrerenderMediaImports: () => babelPluginRedwoodPrerenderMediaImports
22
- });
23
- module.exports = __toCommonJS(babel_plugin_redwood_prerender_media_imports_exports);
24
- var import_path = require("path");
25
- var import_project_config = require("@cedarjs/project-config");
26
- var import_utils = require("./utils.js");
27
- const defaultOptions = {
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
30
- extensions: [
31
- ".ico",
32
- ".jpg",
33
- ".jpeg",
34
- ".png",
35
- ".gif",
36
- ".svg",
37
- ".eot",
38
- ".otf",
39
- ".webp",
40
- ".ttf",
41
- ".woff",
42
- ".woff2",
43
- ".cur",
44
- ".ani",
45
- ".pdf",
46
- ".bmp"
47
- ]
48
- };
49
- function getVariableName(p) {
50
- if (p.node.specifiers?.[0]?.local) {
51
- return p.node.specifiers[0].local.name;
52
- }
53
- return null;
54
- }
55
- function babelPluginRedwoodPrerenderMediaImports({
56
- types: t
57
- }) {
58
- const manifestPath = (0, import_path.join)((0, import_project_config.getPaths)().web.dist, "client-build-manifest.json");
59
- const buildManifest = require(manifestPath);
60
- return {
61
- name: "babel-plugin-redwood-prerender-media-imports",
62
- visitor: {
63
- ImportDeclaration(p, state) {
64
- const importPath = p.node.source.value;
65
- const ext = (0, import_path.extname)(importPath);
66
- const options = {
67
- ...defaultOptions,
68
- ...state.opts
69
- };
70
- if (ext && options.extensions.includes(ext)) {
71
- const importConstName = getVariableName(p);
72
- if (state.filename === void 0) {
73
- return;
74
- }
75
- const absPath = (0, import_path.join)((0, import_path.dirname)(state.filename), p.node.source.value);
76
- const viteManifestKey = (0, import_project_config.ensurePosixPath)(
77
- (0, import_path.relative)((0, import_project_config.getPaths)().web.src, absPath)
78
- );
79
- const copiedAssetPath = buildManifest[viteManifestKey]?.file;
80
- const assetSrc = copiedAssetPath ?? (0, import_utils.convertToDataUrl)(
81
- (0, import_path.join)(state.file.opts.sourceRoot || "./", importPath)
82
- );
83
- if (importConstName) {
84
- p.replaceWith(
85
- t.variableDeclaration("const", [
86
- t.variableDeclarator(
87
- t.identifier(importConstName),
88
- t.stringLiteral(assetSrc)
89
- )
90
- ])
91
- );
92
- }
93
- }
94
- }
95
- }
96
- };
97
- }
98
- // Annotate the CommonJS export names for ESM import in node:
99
- 0 && (module.exports = {
100
- babelPluginRedwoodPrerenderMediaImports
101
- });
@@ -1,2 +0,0 @@
1
- export declare function convertToDataUrl(assetPath: string): string;
2
- //# sourceMappingURL=utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/babelPlugins/utils.ts"],"names":[],"mappings":"AAQA,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,UASjD"}
@@ -1,49 +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 utils_exports = {};
30
- __export(utils_exports, {
31
- convertToDataUrl: () => convertToDataUrl
32
- });
33
- module.exports = __toCommonJS(utils_exports);
34
- var import_node_fs = __toESM(require("node:fs"), 1);
35
- var import_mime_types = __toESM(require("mime-types"), 1);
36
- function convertToDataUrl(assetPath) {
37
- try {
38
- const base64AssetContents = import_node_fs.default.readFileSync(assetPath, "base64");
39
- const mimeType = import_mime_types.default.lookup(assetPath);
40
- return `data:${mimeType};base64,${base64AssetContents}`;
41
- } catch {
42
- console.warn(`Could not read file ${assetPath} for conversion to data uri`);
43
- return "";
44
- }
45
- }
46
- // Annotate the CommonJS export names for ESM import in node:
47
- 0 && (module.exports = {
48
- convertToDataUrl
49
- });
@@ -1,8 +0,0 @@
1
- import type { ReactElement } from 'react';
2
- export declare const isPrerendering: () => boolean;
3
- export declare const isBrowser: boolean;
4
- export declare const useIsBrowser: () => boolean;
5
- export declare const BrowserOnly: ({ children }: {
6
- children: ReactElement;
7
- }) => ReactElement<any, string | React.JSXElementConstructor<any>> | null;
8
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
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,wEAInE,CAAA"}
@@ -1,47 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var browserUtils_exports = {};
20
- __export(browserUtils_exports, {
21
- BrowserOnly: () => BrowserOnly,
22
- isBrowser: () => isBrowser,
23
- isPrerendering: () => isPrerendering,
24
- useIsBrowser: () => useIsBrowser
25
- });
26
- module.exports = __toCommonJS(browserUtils_exports);
27
- var import_react = require("react");
28
- const isPrerendering = () => {
29
- return globalThis.__REDWOOD__PRERENDERING ?? false;
30
- };
31
- const isBrowser = !isPrerendering();
32
- const useIsBrowser = () => {
33
- return (0, import_react.useMemo)(() => {
34
- return !globalThis?.__REDWOOD__PRERENDERING;
35
- }, []);
36
- };
37
- const BrowserOnly = ({ children }) => {
38
- const isBrowser2 = useIsBrowser();
39
- return isBrowser2 ? children : null;
40
- };
41
- // Annotate the CommonJS export names for ESM import in node:
42
- 0 && (module.exports = {
43
- BrowserOnly,
44
- isBrowser,
45
- isPrerendering,
46
- useIsBrowser
47
- });
@@ -1,193 +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 buildAndImport_exports = {};
30
- __export(buildAndImport_exports, {
31
- buildAndImport: () => buildAndImport
32
- });
33
- module.exports = __toCommonJS(buildAndImport_exports);
34
- var import_node_fs = __toESM(require("node:fs"), 1);
35
- var import_node_path = __toESM(require("node:path"), 1);
36
- var import_plugin_alias = __toESM(require("@rollup/plugin-alias"), 1);
37
- var import_plugin_commonjs = __toESM(require("@rollup/plugin-commonjs"), 1);
38
- var import_plugin_node_resolve = require("@rollup/plugin-node-resolve");
39
- var import_plugin_replace = __toESM(require("@rollup/plugin-replace"), 1);
40
- var import_rollup = require("rollup");
41
- var import_rollup_plugin_swc3 = require("rollup-plugin-swc3");
42
- var import_unplugin = __toESM(require("unimport/unplugin"), 1);
43
- var import_project_config = require("@cedarjs/project-config");
44
- var import_internal = require("../internal.js");
45
- var import_rollup_plugin_cedar_remove_dev_fatal_error_page = require("./rollupPlugins/rollup-plugin-cedar-remove-dev-fatal-error-page.js");
46
- var import_rollup_plugin_cedarjs_cell = require("./rollupPlugins/rollup-plugin-cedarjs-cell.js");
47
- var import_rollup_plugin_cedarjs_directory_named_imports = require("./rollupPlugins/rollup-plugin-cedarjs-directory-named-imports.js");
48
- var import_rollup_plugin_cedarjs_external = require("./rollupPlugins/rollup-plugin-cedarjs-external.js");
49
- var import_rollup_plugin_cedarjs_ignore_html_and_css_imports = require("./rollupPlugins/rollup-plugin-cedarjs-ignore-html-and-css-imports.js");
50
- var import_rollup_plugin_cedarjs_inject_file_globals = require("./rollupPlugins/rollup-plugin-cedarjs-inject-file-globals.js");
51
- var import_rollup_plugin_cedarjs_prerender_media_imports = require("./rollupPlugins/rollup-plugin-cedarjs-prerender-media-imports.js");
52
- var import_rollup_plugin_cedarjs_routes_auto_loader = require("./rollupPlugins/rollup-plugin-cedarjs-routes-auto-loader.js");
53
- var import_utils = require("./utils.js");
54
- const fix = (f) => f;
55
- const tsconfigPathsToRegExp = (paths) => {
56
- return Object.keys(paths || {}).map((key) => {
57
- return new RegExp(`^${key.replace(/\*/g, ".*")}$`);
58
- });
59
- };
60
- async function buildAndImport(options) {
61
- if (!(0, import_utils.isValidJsFile)(options.filepath)) {
62
- throw new Error(`${options.filepath} is not a valid JS file`);
63
- }
64
- const tsConfigs = (0, import_internal.parseTypeScriptConfigFiles)();
65
- const resolvePaths = tsconfigPathsToRegExp(
66
- tsConfigs.web?.compilerOptions?.paths || {}
67
- );
68
- const config = (0, import_project_config.getConfig)();
69
- const useTrustedDocumentsGqlTag = config.graphql.trustedDocuments;
70
- const webBase = (0, import_project_config.getPaths)().web.base;
71
- const outDir = import_node_path.default.join((0, import_project_config.getPaths)().web.dist, "__prerender");
72
- if (!import_node_fs.default.existsSync(outDir)) {
73
- import_node_fs.default.mkdirSync(outDir, { recursive: true });
74
- }
75
- const isEsm = (0, import_project_config.projectIsEsm)();
76
- const build = await (0, import_rollup.rollup)({
77
- input: [options.filepath],
78
- output: {
79
- dir: outDir
80
- },
81
- jsx: "react-jsx",
82
- logLevel: "debug",
83
- external: ["react", "react-dom"],
84
- plugins: [
85
- (0, import_rollup_plugin_cedarjs_external.externalPlugin)({
86
- notExternal: resolvePaths,
87
- filepath: options.filepath
88
- }),
89
- (0, import_plugin_node_resolve.nodeResolve)({
90
- preferBuiltins: true,
91
- exportConditions: ["node"],
92
- extensions: [".js", ".jsx", ".ts", ".tsx", ".mjs", ".cjs"]
93
- }),
94
- // @ts-expect-error - Ignore type errors for now
95
- (0, import_plugin_replace.default)({
96
- preventAssignment: true,
97
- "process.env.NODE_ENV": '"production"'
98
- }),
99
- fix(import_plugin_alias.default)({
100
- entries: [
101
- {
102
- find: "src",
103
- replacement: (0, import_project_config.getPaths)().web.src
104
- },
105
- {
106
- find: "$api",
107
- replacement: (0, import_project_config.getPaths)().api.base
108
- },
109
- ...(0, import_internal.getPathsFromTypeScriptConfig)(tsConfigs.web, webBase)
110
- ]
111
- }),
112
- // Handle JSON imports (e.g. .cedar/gqlorm-schema.json)
113
- {
114
- name: "json",
115
- transform(code, id) {
116
- if (!id.endsWith(".json")) {
117
- return null;
118
- }
119
- try {
120
- const parsed = JSON.parse(code);
121
- return {
122
- code: `export default ${JSON.stringify(parsed)}`,
123
- map: { mappings: "" }
124
- };
125
- } catch {
126
- return null;
127
- }
128
- }
129
- },
130
- (0, import_rollup_plugin_cedar_remove_dev_fatal_error_page.cedarRemoveDevFatalErrorPagePlugin)(),
131
- (0, import_rollup_plugin_cedarjs_ignore_html_and_css_imports.ignoreHtmlAndCssImportsPlugin)(),
132
- (0, import_rollup_plugin_cedarjs_cell.cellTransformPlugin)(),
133
- (0, import_rollup_plugin_cedarjs_routes_auto_loader.cedarjsRoutesAutoLoaderPlugin)(),
134
- (0, import_rollup_plugin_cedarjs_directory_named_imports.cedarjsDirectoryNamedImportPlugin)(),
135
- (0, import_rollup_plugin_cedarjs_prerender_media_imports.cedarjsPrerenderMediaImportsPlugin)(),
136
- fix(import_plugin_commonjs.default)(),
137
- (0, import_rollup_plugin_swc3.swc)({ sourceMaps: true }),
138
- import_unplugin.default.rollup({
139
- imports: [
140
- // import React from 'react'
141
- {
142
- name: "default",
143
- as: "React",
144
- from: "react"
145
- },
146
- // import { gql } from 'graphql-tag'
147
- !useTrustedDocumentsGqlTag && isEsm && {
148
- name: "gql",
149
- from: "graphql-tag"
150
- },
151
- // import gql from 'graphql-tag'
152
- !useTrustedDocumentsGqlTag && !isEsm && {
153
- name: "default",
154
- as: "gql",
155
- from: "graphql-tag"
156
- },
157
- // import { gql } from 'src/graphql/gql'
158
- useTrustedDocumentsGqlTag && {
159
- name: "gql",
160
- from: `src/graphql/gql.js`
161
- }
162
- ].filter((v) => Boolean(v))
163
- }),
164
- (0, import_rollup_plugin_cedarjs_inject_file_globals.injectFileGlobalsPlugin)()
165
- ]
166
- });
167
- try {
168
- const { output } = await build.generate({
169
- dir: outDir,
170
- format: (0, import_utils.getPkgType)() === "module" ? "es" : "cjs",
171
- exports: "auto",
172
- sourcemap: "inline"
173
- });
174
- for (const chunk of output) {
175
- if (chunk.type !== "chunk") {
176
- throw new Error("[bundle-require] Expected chunk output");
177
- }
178
- const chunkPath = import_node_path.default.join(outDir, chunk.fileName);
179
- await import_node_fs.default.promises.writeFile(chunkPath, chunk.code, "utf8");
180
- }
181
- const importPath = (0, import_utils.makeFilePath)(import_node_path.default.join(outDir, output[0].fileName));
182
- return import(importPath);
183
- } finally {
184
- if (!options.preserveTemporaryFile) {
185
- await import_node_fs.default.promises.rm(outDir, { recursive: true, force: true });
186
- }
187
- await build.close();
188
- }
189
- }
190
- // Annotate the CommonJS export names for ESM import in node:
191
- 0 && (module.exports = {
192
- buildAndImport
193
- });
@@ -1 +0,0 @@
1
- "use strict";
@@ -1,53 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var rollup_plugin_cedar_remove_dev_fatal_error_page_exports = {};
20
- __export(rollup_plugin_cedar_remove_dev_fatal_error_page_exports, {
21
- cedarRemoveDevFatalErrorPagePlugin: () => cedarRemoveDevFatalErrorPagePlugin
22
- });
23
- module.exports = __toCommonJS(rollup_plugin_cedar_remove_dev_fatal_error_page_exports);
24
- const DEV_FATAL_ERROR_PAGE_MODULE = "@cedarjs/web/dist/components/DevFatalErrorPage";
25
- function escapeRegExp(s) {
26
- return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
27
- }
28
- const ESCAPED_MODULE = escapeRegExp(DEV_FATAL_ERROR_PAGE_MODULE);
29
- const IMPORT_PATTERN = new RegExp(
30
- `import\\s*\\{[^}]*\\bDevFatalErrorPage\\b[^}]*\\}\\s*from\\s*['"]${ESCAPED_MODULE}['"]`
31
- );
32
- const cedarRemoveDevFatalErrorPagePlugin = () => {
33
- return {
34
- name: "cedar-remove-dev-fatal-error-page",
35
- transform(code) {
36
- if (!code.includes(DEV_FATAL_ERROR_PAGE_MODULE)) {
37
- return null;
38
- }
39
- const newCode = code.replace(
40
- IMPORT_PATTERN,
41
- "const DevFatalErrorPage = undefined"
42
- );
43
- if (newCode === code) {
44
- return null;
45
- }
46
- return { code: newCode, map: null };
47
- }
48
- };
49
- };
50
- // Annotate the CommonJS export names for ESM import in node:
51
- 0 && (module.exports = {
52
- cedarRemoveDevFatalErrorPagePlugin
53
- });