@cedarjs/prerender 7.0.0-canary.3258 → 7.0.0-rc.123
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/babelPlugins/babel-plugin-redwood-cell.d.ts +5 -0
- package/dist/babelPlugins/babel-plugin-redwood-cell.d.ts.map +1 -0
- package/dist/babelPlugins/babel-plugin-redwood-cell.js +98 -0
- package/dist/babelPlugins/babel-plugin-redwood-prerender-media-imports.d.ts +5 -0
- package/dist/babelPlugins/babel-plugin-redwood-prerender-media-imports.d.ts.map +1 -0
- package/dist/babelPlugins/babel-plugin-redwood-prerender-media-imports.js +77 -0
- package/dist/babelPlugins/utils.d.ts +2 -0
- package/dist/babelPlugins/utils.d.ts.map +1 -0
- package/dist/babelPlugins/utils.js +15 -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 +9 -2
- package/dist/build-and-import/rollupPlugins/rollup-plugin-cedarjs-routes-auto-loader.d.ts.map +1 -1
- package/dist/cjs/apolloState.d.ts +13 -0
- package/dist/cjs/apolloState.d.ts.map +1 -0
- package/dist/cjs/apolloState.js +30 -0
- package/dist/cjs/babelPlugins/babel-plugin-redwood-cell.d.ts +5 -0
- package/dist/cjs/babelPlugins/babel-plugin-redwood-cell.d.ts.map +1 -0
- package/dist/cjs/babelPlugins/babel-plugin-redwood-cell.js +122 -0
- package/dist/cjs/babelPlugins/babel-plugin-redwood-prerender-media-imports.d.ts +5 -0
- package/dist/cjs/babelPlugins/babel-plugin-redwood-prerender-media-imports.d.ts.map +1 -0
- package/dist/cjs/babelPlugins/babel-plugin-redwood-prerender-media-imports.js +101 -0
- package/dist/cjs/babelPlugins/utils.d.ts +2 -0
- package/dist/cjs/babelPlugins/utils.d.ts.map +1 -0
- package/dist/cjs/babelPlugins/utils.js +49 -0
- package/dist/cjs/browserUtils/index.d.ts +8 -0
- package/dist/cjs/browserUtils/index.d.ts.map +1 -0
- package/dist/cjs/browserUtils/index.js +47 -0
- package/dist/cjs/build-and-import/buildAndImport.js +193 -0
- package/dist/cjs/build-and-import/load-tsconfig.d.js +1 -0
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedar-remove-dev-fatal-error-page.js +53 -0
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-cell.js +184 -0
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-directory-named-imports.js +83 -0
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-external.js +125 -0
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-ignore-html-and-css-imports.js +48 -0
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-inject-file-globals.js +66 -0
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-prerender-media-imports.js +118 -0
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-routes-auto-loader.js +146 -0
- package/dist/cjs/build-and-import/rollupPlugins/utils.js +78 -0
- package/dist/cjs/build-and-import/utils.js +68 -0
- package/dist/cjs/detection/detection.d.ts +11 -0
- package/dist/cjs/detection/detection.d.ts.map +1 -0
- package/dist/cjs/detection/detection.js +46 -0
- package/dist/cjs/errors.d.ts +19 -0
- package/dist/cjs/errors.d.ts.map +1 -0
- package/dist/cjs/errors.js +52 -0
- package/dist/cjs/graphql/graphql.d.ts +19 -0
- package/dist/cjs/graphql/graphql.d.ts.map +1 -0
- package/dist/cjs/graphql/graphql.js +152 -0
- package/dist/cjs/graphql/node-runner.js +97 -0
- package/dist/cjs/graphql/vite-plugin-cedar-auto-import.js +107 -0
- package/dist/{index.d.ts.map → cjs/index.d.ts.map} +1 -1
- package/dist/cjs/index.js +22 -0
- package/dist/cjs/internal.d.ts +28 -0
- package/dist/cjs/internal.d.ts.map +1 -0
- package/dist/cjs/internal.js +135 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/runPrerender.d.ts.map +1 -0
- package/dist/cjs/runPrerender.js +311 -0
- package/dist/cjs/runPrerenderEsm.js +308 -0
- package/dist/graphql/graphql.d.ts +2 -17
- package/dist/graphql/graphql.d.ts.map +1 -1
- package/dist/runPrerenderEsm.d.ts +9 -0
- package/dist/runPrerenderEsm.d.ts.map +1 -0
- package/dist/{runPrerender.js → runPrerenderEsm.js} +56 -65
- package/package.json +51 -20
- package/dist/index.js +0 -1
- package/dist/runPrerender.d.ts.map +0 -1
- /package/dist/{index.d.ts → cjs/index.d.ts} +0 -0
- /package/dist/{runPrerender.d.ts → cjs/runPrerender.d.ts} +0 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { DocumentNode } from 'graphql';
|
|
2
|
+
export type FileImporter = (path: string) => Promise<any>;
|
|
3
|
+
/**
|
|
4
|
+
* Loads the graphql server, with all the user's settings
|
|
5
|
+
* And execute the query against it
|
|
6
|
+
*
|
|
7
|
+
* Note that this function does NOT throw errors, even when
|
|
8
|
+
* there is a GraphQL error. Instead, it returns the result with the graphql
|
|
9
|
+
* error.
|
|
10
|
+
*/
|
|
11
|
+
export declare function executeQuery(fileImporter: FileImporter, gqlHandler: (args: any) => Promise<any>, query: DocumentNode, variables?: Record<string, unknown>): Promise<any>;
|
|
12
|
+
/**
|
|
13
|
+
* Finds the graphql handler, returns a function
|
|
14
|
+
* that can be used to execute queries against it
|
|
15
|
+
*
|
|
16
|
+
* Throws GqlHandlerImportError, so that we can warn the user (but not blow up)
|
|
17
|
+
*/
|
|
18
|
+
export declare function getGqlHandler(fileImporter: FileImporter): Promise<(operation: Record<string, unknown>) => Promise<any>>;
|
|
19
|
+
//# sourceMappingURL=graphql.d.ts.map
|
|
@@ -0,0 +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;AASzD;;;;;;;GAOG;AACH,wBAAsB,YAAY,CAChC,YAAY,EAAE,YAAY,EAC1B,UAAU,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,EACvC,KAAK,EAAE,YAAY,EACnB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,gBAmCpC;AAED;;;;;GAKG;AACH,wBAAsB,aAAa,CAAC,YAAY,EAAE,YAAY,uBAMjC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,mBAUnD"}
|
|
@@ -0,0 +1,152 @@
|
|
|
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 graphql_exports = {};
|
|
30
|
+
__export(graphql_exports, {
|
|
31
|
+
executeQuery: () => executeQuery,
|
|
32
|
+
getGqlHandler: () => getGqlHandler
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(graphql_exports);
|
|
35
|
+
var import_path = __toESM(require("path"), 1);
|
|
36
|
+
var import_graphql = require("graphql");
|
|
37
|
+
var import_project_config = require("@cedarjs/project-config");
|
|
38
|
+
var import_graphql2 = require("@cedarjs/web/dist/graphql.js");
|
|
39
|
+
var import_errors = require("../errors.js");
|
|
40
|
+
async function executeQuery(fileImporter, gqlHandler, query, variables) {
|
|
41
|
+
const config = (0, import_project_config.getConfig)();
|
|
42
|
+
const operationName = (0, import_graphql2.getOperationName)(query);
|
|
43
|
+
const operation = {
|
|
44
|
+
operationName,
|
|
45
|
+
query: (0, import_graphql.print)(query),
|
|
46
|
+
variables
|
|
47
|
+
};
|
|
48
|
+
if (config.graphql.trustedDocuments) {
|
|
49
|
+
const documentsPath = import_path.default.join((0, import_project_config.getPaths)().web.graphql, "graphql");
|
|
50
|
+
const documents = await fileImporter(documentsPath);
|
|
51
|
+
const documentName = operationName[0].toUpperCase() + operationName.slice(1) + "Document";
|
|
52
|
+
const queryHash = documents?.[documentName]?.__meta__?.hash;
|
|
53
|
+
operation.query = void 0;
|
|
54
|
+
operation.extensions = {
|
|
55
|
+
persistedQuery: {
|
|
56
|
+
version: 1,
|
|
57
|
+
sha256Hash: queryHash
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
const handlerResult = await gqlHandler(operation);
|
|
62
|
+
return handlerResult?.body;
|
|
63
|
+
}
|
|
64
|
+
async function getGqlHandler(fileImporter) {
|
|
65
|
+
const gqlPath = import_path.default.join((0, import_project_config.getPaths)().api.functions, "graphql");
|
|
66
|
+
try {
|
|
67
|
+
const { handler } = await fileImporter(gqlPath);
|
|
68
|
+
return async (operation) => {
|
|
69
|
+
return await handler(buildApiEvent(operation), buildContext());
|
|
70
|
+
};
|
|
71
|
+
} catch {
|
|
72
|
+
return () => {
|
|
73
|
+
throw new import_errors.GqlHandlerImportError(
|
|
74
|
+
`Unable to import GraphQL handler at ${gqlPath}`
|
|
75
|
+
);
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function buildApiEvent(body) {
|
|
80
|
+
return {
|
|
81
|
+
body: JSON.stringify(body),
|
|
82
|
+
headers: {
|
|
83
|
+
origin: "http://localhost:8910",
|
|
84
|
+
"content-type": "application/json",
|
|
85
|
+
accept: "*/*",
|
|
86
|
+
host: "localhost:8910"
|
|
87
|
+
},
|
|
88
|
+
multiValueHeaders: {},
|
|
89
|
+
httpMethod: "POST",
|
|
90
|
+
isBase64Encoded: false,
|
|
91
|
+
path: "/graphql",
|
|
92
|
+
pathParameters: null,
|
|
93
|
+
queryStringParameters: {},
|
|
94
|
+
multiValueQueryStringParameters: null,
|
|
95
|
+
stageVariables: null,
|
|
96
|
+
resource: "",
|
|
97
|
+
requestContext: {
|
|
98
|
+
requestId: "req-3",
|
|
99
|
+
identity: {
|
|
100
|
+
sourceIp: "::1",
|
|
101
|
+
accessKey: null,
|
|
102
|
+
accountId: null,
|
|
103
|
+
apiKey: null,
|
|
104
|
+
apiKeyId: null,
|
|
105
|
+
caller: null,
|
|
106
|
+
clientCert: null,
|
|
107
|
+
cognitoAuthenticationProvider: null,
|
|
108
|
+
cognitoAuthenticationType: null,
|
|
109
|
+
cognitoIdentityId: null,
|
|
110
|
+
cognitoIdentityPoolId: null,
|
|
111
|
+
principalOrgId: null,
|
|
112
|
+
user: null,
|
|
113
|
+
userAgent: null,
|
|
114
|
+
userArn: null
|
|
115
|
+
},
|
|
116
|
+
authorizer: {},
|
|
117
|
+
protocol: "http",
|
|
118
|
+
httpMethod: "POST",
|
|
119
|
+
path: "/graphql",
|
|
120
|
+
stage: "",
|
|
121
|
+
requestTimeEpoch: 0,
|
|
122
|
+
resourceId: "",
|
|
123
|
+
resourcePath: "",
|
|
124
|
+
accountId: "",
|
|
125
|
+
apiId: ""
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
function buildContext() {
|
|
130
|
+
return {
|
|
131
|
+
callbackWaitsForEmptyEventLoop: false,
|
|
132
|
+
functionName: "",
|
|
133
|
+
functionVersion: "",
|
|
134
|
+
invokedFunctionArn: "",
|
|
135
|
+
memoryLimitInMB: "",
|
|
136
|
+
awsRequestId: "",
|
|
137
|
+
logGroupName: "",
|
|
138
|
+
logStreamName: "",
|
|
139
|
+
getRemainingTimeInMillis: () => 100,
|
|
140
|
+
done: () => {
|
|
141
|
+
},
|
|
142
|
+
fail: () => {
|
|
143
|
+
},
|
|
144
|
+
succeed: () => {
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
149
|
+
0 && (module.exports = {
|
|
150
|
+
executeQuery,
|
|
151
|
+
getGqlHandler
|
|
152
|
+
});
|
|
@@ -0,0 +1,97 @@
|
|
|
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 node_runner_exports = {};
|
|
20
|
+
__export(node_runner_exports, {
|
|
21
|
+
NodeRunner: () => NodeRunner
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(node_runner_exports);
|
|
24
|
+
var import_vite = require("vite");
|
|
25
|
+
var import_project_config = require("@cedarjs/project-config");
|
|
26
|
+
var import_vite2 = require("@cedarjs/vite");
|
|
27
|
+
var import_vite_plugin_cedar_auto_import = require("./vite-plugin-cedar-auto-import.js");
|
|
28
|
+
async function createViteServer(customConfig = {}) {
|
|
29
|
+
const defaultConfig = {
|
|
30
|
+
mode: "production",
|
|
31
|
+
optimizeDeps: {
|
|
32
|
+
noDiscovery: true,
|
|
33
|
+
include: void 0
|
|
34
|
+
},
|
|
35
|
+
server: {
|
|
36
|
+
hmr: false,
|
|
37
|
+
watch: null
|
|
38
|
+
},
|
|
39
|
+
environments: {
|
|
40
|
+
nodeRunnerEnv: {}
|
|
41
|
+
},
|
|
42
|
+
resolve: {
|
|
43
|
+
alias: [
|
|
44
|
+
{
|
|
45
|
+
find: /^src\/(.*?)(\.([jt]sx?))?$/,
|
|
46
|
+
replacement: (0, import_project_config.getPaths)().api.src + "/$1"
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
},
|
|
50
|
+
plugins: [
|
|
51
|
+
(0, import_vite2.cedarCjsCompatPlugin)(),
|
|
52
|
+
(0, import_vite2.cedarImportDirPlugin)(),
|
|
53
|
+
(0, import_vite_plugin_cedar_auto_import.cedarAutoImportsPlugin)(),
|
|
54
|
+
(0, import_vite2.cedarjsResolveCedarStyleImportsPlugin)(),
|
|
55
|
+
(0, import_vite2.cedarCellTransform)(),
|
|
56
|
+
(0, import_vite2.cedarjsJobPathInjectorPlugin)(),
|
|
57
|
+
(0, import_vite2.cedarSwapApolloProvider)()
|
|
58
|
+
]
|
|
59
|
+
};
|
|
60
|
+
const mergedConfig = (0, import_vite.mergeConfig)(defaultConfig, customConfig);
|
|
61
|
+
const server = await (0, import_vite.createServer)(mergedConfig);
|
|
62
|
+
return server;
|
|
63
|
+
}
|
|
64
|
+
class NodeRunner {
|
|
65
|
+
viteServer = void 0;
|
|
66
|
+
env = void 0;
|
|
67
|
+
customViteConfig;
|
|
68
|
+
constructor(customViteConfig = {}) {
|
|
69
|
+
this.customViteConfig = customViteConfig;
|
|
70
|
+
}
|
|
71
|
+
async init() {
|
|
72
|
+
this.viteServer = await createViteServer(this.customViteConfig);
|
|
73
|
+
const env = this.viteServer.environments.nodeRunnerEnv;
|
|
74
|
+
if (!env || !(0, import_vite.isRunnableDevEnvironment)(env)) {
|
|
75
|
+
await this.viteServer.close();
|
|
76
|
+
throw new Error("Vite environment is not runnable.");
|
|
77
|
+
}
|
|
78
|
+
this.env = env;
|
|
79
|
+
}
|
|
80
|
+
async importFile(filePath) {
|
|
81
|
+
if (!this.env) {
|
|
82
|
+
await this.init();
|
|
83
|
+
}
|
|
84
|
+
const env = this.env;
|
|
85
|
+
if (!env) {
|
|
86
|
+
throw new Error("NodeRunner failed to initialize");
|
|
87
|
+
}
|
|
88
|
+
return env.runner.import(filePath);
|
|
89
|
+
}
|
|
90
|
+
async close() {
|
|
91
|
+
await this.viteServer?.close();
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
95
|
+
0 && (module.exports = {
|
|
96
|
+
NodeRunner
|
|
97
|
+
});
|
|
@@ -0,0 +1,107 @@
|
|
|
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_auto_import_exports = {};
|
|
30
|
+
__export(vite_plugin_cedar_auto_import_exports, {
|
|
31
|
+
cedarAutoImportsPlugin: () => cedarAutoImportsPlugin
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(vite_plugin_cedar_auto_import_exports);
|
|
34
|
+
var import_node_path = __toESM(require("node:path"), 1);
|
|
35
|
+
var import_unplugin = __toESM(require("unimport/unplugin"), 1);
|
|
36
|
+
var import_vite = __toESM(require("unplugin-auto-import/vite"), 1);
|
|
37
|
+
var import_project_config = require("@cedarjs/project-config");
|
|
38
|
+
function cedarAutoImportsPlugin() {
|
|
39
|
+
const config = (0, import_project_config.getConfig)();
|
|
40
|
+
const cedarPaths = (0, import_project_config.getPaths)();
|
|
41
|
+
const useTrustedDocumentsGqlTag = config?.graphql?.trustedDocuments;
|
|
42
|
+
return [
|
|
43
|
+
(0, import_vite.default)({
|
|
44
|
+
// targets to transform
|
|
45
|
+
include: [
|
|
46
|
+
/web\/.*\.[tj]sx?$/,
|
|
47
|
+
// Assume we want the trusted documents gql tag import in all .jsx and
|
|
48
|
+
// .tsx files
|
|
49
|
+
/\.[tj]sx$/
|
|
50
|
+
],
|
|
51
|
+
// global imports to register
|
|
52
|
+
imports: [
|
|
53
|
+
// import gql from 'graphql-tag'
|
|
54
|
+
!useTrustedDocumentsGqlTag && {
|
|
55
|
+
"graphql-tag": ["gql"]
|
|
56
|
+
},
|
|
57
|
+
// import { gql } from 'src/graphql/gql'
|
|
58
|
+
useTrustedDocumentsGqlTag && {
|
|
59
|
+
[(0, import_project_config.importStatementPath)(
|
|
60
|
+
import_node_path.default.join(cedarPaths.web.base, "src", "graphql", "gql")
|
|
61
|
+
)]: ["gql"]
|
|
62
|
+
}
|
|
63
|
+
].filter((v) => Boolean(v)),
|
|
64
|
+
// Types aren't important since the output is ephemeral
|
|
65
|
+
dts: false
|
|
66
|
+
}),
|
|
67
|
+
(0, import_vite.default)({
|
|
68
|
+
// targets to transform
|
|
69
|
+
include: [/\.[tj]sx?$/],
|
|
70
|
+
// global imports to register
|
|
71
|
+
imports: [
|
|
72
|
+
{
|
|
73
|
+
"@cedarjs/context": ["context"]
|
|
74
|
+
}
|
|
75
|
+
],
|
|
76
|
+
// Types aren't important since the output is ephemeral
|
|
77
|
+
dts: false
|
|
78
|
+
}),
|
|
79
|
+
(0, import_vite.default)({
|
|
80
|
+
// targets to transform
|
|
81
|
+
include: [/api\/.*\.[tj]sx?$/],
|
|
82
|
+
// global imports to register
|
|
83
|
+
imports: [
|
|
84
|
+
// import gql from 'graphql-tag'
|
|
85
|
+
{
|
|
86
|
+
"graphql-tag": ["gql"]
|
|
87
|
+
}
|
|
88
|
+
],
|
|
89
|
+
// Types aren't important since the output is ephemeral
|
|
90
|
+
dts: false
|
|
91
|
+
}),
|
|
92
|
+
import_unplugin.default.vite({
|
|
93
|
+
imports: [
|
|
94
|
+
// import React from 'react'
|
|
95
|
+
{
|
|
96
|
+
name: "default",
|
|
97
|
+
as: "React",
|
|
98
|
+
from: "react"
|
|
99
|
+
}
|
|
100
|
+
]
|
|
101
|
+
})
|
|
102
|
+
];
|
|
103
|
+
}
|
|
104
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
105
|
+
0 && (module.exports = {
|
|
106
|
+
cedarAutoImportsPlugin
|
|
107
|
+
});
|
|
@@ -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"}
|
|
@@ -0,0 +1,22 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var index_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(index_exports);
|
|
18
|
+
__reExport(index_exports, require("./runPrerender.js"), module.exports);
|
|
19
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
20
|
+
0 && (module.exports = {
|
|
21
|
+
...require("./runPrerender.js")
|
|
22
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare const getRootHtmlPath: () => string;
|
|
2
|
+
export declare const registerShims: (routerPath: string) => void;
|
|
3
|
+
export declare const writeToDist: (outputHtmlPath: string, renderOutput: string) => void;
|
|
4
|
+
/**
|
|
5
|
+
* Finds, reads and parses the [ts|js]config.json file
|
|
6
|
+
* @returns The config object
|
|
7
|
+
*/
|
|
8
|
+
export declare const parseTypeScriptConfigFiles: () => {
|
|
9
|
+
api: any;
|
|
10
|
+
web: any;
|
|
11
|
+
};
|
|
12
|
+
type CompilerOptionsForPaths = {
|
|
13
|
+
compilerOptions: {
|
|
14
|
+
baseUrl: string;
|
|
15
|
+
paths: Record<string, string[]>;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Extracts and formats the paths from the [ts|js]config.json file
|
|
20
|
+
* @param config The config object
|
|
21
|
+
* @param rootDir {string} Where the jsconfig/tsconfig is loaded from
|
|
22
|
+
*/
|
|
23
|
+
export declare function getPathsFromTypeScriptConfig(config: CompilerOptionsForPaths, rootDir: string): {
|
|
24
|
+
find: string;
|
|
25
|
+
replacement: string;
|
|
26
|
+
}[];
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=internal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../src/internal.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,eAAe,cAM3B,CAAA;AAED,eAAO,MAAM,aAAa,GAAI,YAAY,MAAM,SAiC/C,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,gBAAgB,MAAM,EAAE,cAAc,MAAM,SAQvE,CAAA;AAGD;;;GAGG;AACH,eAAO,MAAM,0BAA0B;;;CA0BtC,CAAA;AAED,KAAK,uBAAuB,GAAG;IAC7B,eAAe,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;KAAE,CAAA;CACtE,CAAA;AAED;;;;GAIG;AACH,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,uBAAuB,EAC/B,OAAO,EAAE,MAAM;UAsBQ,MAAM;iBAAe,MAAM;IAkBnD"}
|
|
@@ -0,0 +1,135 @@
|
|
|
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 internal_exports = {};
|
|
30
|
+
__export(internal_exports, {
|
|
31
|
+
getPathsFromTypeScriptConfig: () => getPathsFromTypeScriptConfig,
|
|
32
|
+
getRootHtmlPath: () => getRootHtmlPath,
|
|
33
|
+
parseTypeScriptConfigFiles: () => parseTypeScriptConfigFiles,
|
|
34
|
+
registerShims: () => registerShims,
|
|
35
|
+
writeToDist: () => writeToDist
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(internal_exports);
|
|
38
|
+
var import_node_fs = __toESM(require("node:fs"), 1);
|
|
39
|
+
var import_path = __toESM(require("path"), 1);
|
|
40
|
+
var import_fetch = require("@whatwg-node/fetch");
|
|
41
|
+
var import_typescript = require("typescript");
|
|
42
|
+
var import_project_config = require("@cedarjs/project-config");
|
|
43
|
+
const INDEX_FILE = import_path.default.join((0, import_project_config.getPaths)().web.dist, "index.html");
|
|
44
|
+
const DEFAULT_INDEX = import_path.default.join((0, import_project_config.getPaths)().web.dist, "200.html");
|
|
45
|
+
const getRootHtmlPath = () => {
|
|
46
|
+
if (import_node_fs.default.existsSync(DEFAULT_INDEX)) {
|
|
47
|
+
return DEFAULT_INDEX;
|
|
48
|
+
} else {
|
|
49
|
+
return INDEX_FILE;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
const registerShims = (routerPath) => {
|
|
53
|
+
const rwjsConfig = (0, import_project_config.getConfig)();
|
|
54
|
+
globalThis.RWJS_ENV = {
|
|
55
|
+
RWJS_API_GRAPHQL_URL: rwjsConfig.web.apiGraphQLUrl ?? rwjsConfig.web.apiUrl + "/graphql",
|
|
56
|
+
RWJS_API_URL: rwjsConfig.web.apiUrl,
|
|
57
|
+
__REDWOOD__APP_TITLE: rwjsConfig.web.title
|
|
58
|
+
};
|
|
59
|
+
globalThis.RWJS_DEBUG_ENV = {
|
|
60
|
+
RWJS_SRC_ROOT: (0, import_project_config.getPaths)().web.src
|
|
61
|
+
};
|
|
62
|
+
globalThis.__REDWOOD__PRERENDERING = true;
|
|
63
|
+
globalThis.__REDWOOD__HELMET_CONTEXT = {};
|
|
64
|
+
process.env.__REDWOOD__PRERENDERING = "1";
|
|
65
|
+
globalThis.location = {
|
|
66
|
+
...globalThis.location,
|
|
67
|
+
pathname: routerPath
|
|
68
|
+
};
|
|
69
|
+
if (!globalThis.fetch) {
|
|
70
|
+
globalThis.fetch = import_fetch.fetch;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
const writeToDist = (outputHtmlPath, renderOutput) => {
|
|
74
|
+
const dirName = import_path.default.dirname(outputHtmlPath);
|
|
75
|
+
const exist = import_node_fs.default.existsSync(dirName);
|
|
76
|
+
if (!exist) {
|
|
77
|
+
import_node_fs.default.mkdirSync(dirName, { recursive: true });
|
|
78
|
+
}
|
|
79
|
+
import_node_fs.default.writeFileSync(outputHtmlPath, renderOutput);
|
|
80
|
+
};
|
|
81
|
+
const parseTypeScriptConfigFiles = () => {
|
|
82
|
+
const rwPaths = (0, import_project_config.getPaths)();
|
|
83
|
+
const parseConfigFile = (basePath) => {
|
|
84
|
+
let configPath = import_path.default.join(basePath, "tsconfig.json");
|
|
85
|
+
if (!import_node_fs.default.existsSync(configPath)) {
|
|
86
|
+
configPath = import_path.default.join(basePath, "jsconfig.json");
|
|
87
|
+
if (!import_node_fs.default.existsSync(configPath)) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return (0, import_typescript.parseConfigFileTextToJson)(
|
|
92
|
+
configPath,
|
|
93
|
+
import_node_fs.default.readFileSync(configPath, "utf-8")
|
|
94
|
+
);
|
|
95
|
+
};
|
|
96
|
+
const apiConfig = parseConfigFile(rwPaths.api.base);
|
|
97
|
+
const webConfig = parseConfigFile(rwPaths.web.base);
|
|
98
|
+
return {
|
|
99
|
+
api: apiConfig?.config ?? null,
|
|
100
|
+
web: webConfig?.config ?? null
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
function getPathsFromTypeScriptConfig(config, rootDir) {
|
|
104
|
+
if (!config) {
|
|
105
|
+
return [];
|
|
106
|
+
}
|
|
107
|
+
if (!config.compilerOptions?.paths) {
|
|
108
|
+
return [];
|
|
109
|
+
}
|
|
110
|
+
const { baseUrl, paths } = config.compilerOptions;
|
|
111
|
+
let absoluteBase;
|
|
112
|
+
if (baseUrl) {
|
|
113
|
+
absoluteBase = import_path.default.isAbsolute(baseUrl) ? baseUrl : import_path.default.join(rootDir, baseUrl);
|
|
114
|
+
} else {
|
|
115
|
+
absoluteBase = rootDir;
|
|
116
|
+
}
|
|
117
|
+
const aliases = [];
|
|
118
|
+
for (const [key, value] of Object.entries(paths)) {
|
|
119
|
+
if (key.match(/src\/|\$api\/\*|types\/\*|\@cedarjs\/.*/g)) {
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
const aliasKey = key.replace("/*", "");
|
|
123
|
+
const aliasValue = import_path.default.join(absoluteBase, value[0].replace("/*", ""));
|
|
124
|
+
aliases.push({ find: aliasKey, replacement: aliasValue });
|
|
125
|
+
}
|
|
126
|
+
return aliases;
|
|
127
|
+
}
|
|
128
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
129
|
+
0 && (module.exports = {
|
|
130
|
+
getPathsFromTypeScriptConfig,
|
|
131
|
+
getRootHtmlPath,
|
|
132
|
+
parseTypeScriptConfigFiles,
|
|
133
|
+
registerShims,
|
|
134
|
+
writeToDist
|
|
135
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runPrerender.d.ts","sourceRoot":"","sources":["../../src/runPrerender.tsx"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AA2O7C,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,CAuIzC,CAAA;AAGD,eAAO,MAAM,wBAAwB,GACnC,gBAAgB,MAAM,EACtB,SAAS,MAAM,SAchB,CAAA"}
|