@cedarjs/prerender 7.0.0-rc.128 → 8.0.0-canary.3263
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/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 +2 -9
- package/dist/build-and-import/rollupPlugins/rollup-plugin-cedarjs-routes-auto-loader.d.ts.map +1 -1
- package/dist/graphql/graphql.d.ts +17 -2
- package/dist/graphql/graphql.d.ts.map +1 -1
- package/dist/{cjs/index.d.ts.map → index.d.ts.map} +1 -1
- package/dist/index.js +1 -0
- package/dist/runPrerender.d.ts.map +1 -0
- package/dist/{runPrerenderEsm.js → runPrerender.js} +65 -56
- package/package.json +20 -51
- package/dist/babelPlugins/babel-plugin-redwood-cell.d.ts +0 -5
- package/dist/babelPlugins/babel-plugin-redwood-cell.d.ts.map +0 -1
- package/dist/babelPlugins/babel-plugin-redwood-cell.js +0 -98
- package/dist/babelPlugins/babel-plugin-redwood-prerender-media-imports.d.ts +0 -5
- package/dist/babelPlugins/babel-plugin-redwood-prerender-media-imports.d.ts.map +0 -1
- package/dist/babelPlugins/babel-plugin-redwood-prerender-media-imports.js +0 -77
- package/dist/babelPlugins/utils.d.ts +0 -2
- package/dist/babelPlugins/utils.d.ts.map +0 -1
- package/dist/babelPlugins/utils.js +0 -15
- package/dist/cjs/apolloState.d.ts +0 -13
- package/dist/cjs/apolloState.d.ts.map +0 -1
- package/dist/cjs/apolloState.js +0 -30
- package/dist/cjs/babelPlugins/babel-plugin-redwood-cell.d.ts +0 -5
- package/dist/cjs/babelPlugins/babel-plugin-redwood-cell.d.ts.map +0 -1
- package/dist/cjs/babelPlugins/babel-plugin-redwood-cell.js +0 -122
- package/dist/cjs/babelPlugins/babel-plugin-redwood-prerender-media-imports.d.ts +0 -5
- package/dist/cjs/babelPlugins/babel-plugin-redwood-prerender-media-imports.d.ts.map +0 -1
- package/dist/cjs/babelPlugins/babel-plugin-redwood-prerender-media-imports.js +0 -101
- package/dist/cjs/babelPlugins/utils.d.ts +0 -2
- package/dist/cjs/babelPlugins/utils.d.ts.map +0 -1
- package/dist/cjs/babelPlugins/utils.js +0 -49
- package/dist/cjs/browserUtils/index.d.ts +0 -8
- package/dist/cjs/browserUtils/index.d.ts.map +0 -1
- package/dist/cjs/browserUtils/index.js +0 -47
- package/dist/cjs/build-and-import/buildAndImport.js +0 -193
- package/dist/cjs/build-and-import/load-tsconfig.d.js +0 -1
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedar-remove-dev-fatal-error-page.js +0 -53
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-cell.js +0 -184
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-directory-named-imports.js +0 -83
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-external.js +0 -125
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-ignore-html-and-css-imports.js +0 -48
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-inject-file-globals.js +0 -66
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-prerender-media-imports.js +0 -118
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-routes-auto-loader.js +0 -146
- package/dist/cjs/build-and-import/rollupPlugins/utils.js +0 -78
- package/dist/cjs/build-and-import/utils.js +0 -68
- package/dist/cjs/detection/detection.d.ts +0 -11
- package/dist/cjs/detection/detection.d.ts.map +0 -1
- package/dist/cjs/detection/detection.js +0 -46
- package/dist/cjs/errors.d.ts +0 -19
- package/dist/cjs/errors.d.ts.map +0 -1
- package/dist/cjs/errors.js +0 -52
- package/dist/cjs/graphql/graphql.d.ts +0 -19
- package/dist/cjs/graphql/graphql.d.ts.map +0 -1
- package/dist/cjs/graphql/graphql.js +0 -152
- package/dist/cjs/graphql/node-runner.js +0 -97
- package/dist/cjs/graphql/vite-plugin-cedar-auto-import.js +0 -107
- package/dist/cjs/index.js +0 -22
- package/dist/cjs/internal.d.ts +0 -28
- package/dist/cjs/internal.d.ts.map +0 -1
- package/dist/cjs/internal.js +0 -135
- package/dist/cjs/package.json +0 -1
- package/dist/cjs/runPrerender.d.ts.map +0 -1
- package/dist/cjs/runPrerender.js +0 -311
- package/dist/cjs/runPrerenderEsm.js +0 -308
- package/dist/runPrerenderEsm.d.ts +0 -9
- package/dist/runPrerenderEsm.d.ts.map +0 -1
- /package/dist/{cjs/index.d.ts → index.d.ts} +0 -0
- /package/dist/{cjs/runPrerender.d.ts → runPrerender.d.ts} +0 -0
|
@@ -1,97 +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 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
|
-
});
|
|
@@ -1,107 +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_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
|
-
});
|
package/dist/cjs/index.js
DELETED
|
@@ -1,22 +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 __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
|
-
});
|
package/dist/cjs/internal.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/cjs/internal.js
DELETED
|
@@ -1,135 +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 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
|
-
});
|
package/dist/cjs/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type":"commonjs"}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|