@cedarjs/prerender 7.0.0-canary.2989 → 7.0.0-canary.2994

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 (66) hide show
  1. package/dist/build-and-import/buildAndImport.d.ts +1 -1
  2. package/dist/build-and-import/buildAndImport.d.ts.map +1 -1
  3. package/dist/{cjs/index.d.ts.map → index.d.ts.map} +1 -1
  4. package/dist/index.js +1 -0
  5. package/dist/runPrerender.d.ts.map +1 -0
  6. package/dist/{runPrerenderEsm.js → runPrerender.js} +47 -41
  7. package/package.json +18 -40
  8. package/dist/babelPlugins/babel-plugin-redwood-cell.d.ts +0 -5
  9. package/dist/babelPlugins/babel-plugin-redwood-cell.d.ts.map +0 -1
  10. package/dist/babelPlugins/babel-plugin-redwood-cell.js +0 -98
  11. package/dist/babelPlugins/babel-plugin-redwood-prerender-media-imports.d.ts +0 -5
  12. package/dist/babelPlugins/babel-plugin-redwood-prerender-media-imports.d.ts.map +0 -1
  13. package/dist/babelPlugins/babel-plugin-redwood-prerender-media-imports.js +0 -77
  14. package/dist/babelPlugins/utils.d.ts +0 -2
  15. package/dist/babelPlugins/utils.d.ts.map +0 -1
  16. package/dist/babelPlugins/utils.js +0 -15
  17. package/dist/cjs/apolloState.d.ts +0 -13
  18. package/dist/cjs/apolloState.d.ts.map +0 -1
  19. package/dist/cjs/apolloState.js +0 -30
  20. package/dist/cjs/babelPlugins/babel-plugin-redwood-cell.d.ts +0 -5
  21. package/dist/cjs/babelPlugins/babel-plugin-redwood-cell.d.ts.map +0 -1
  22. package/dist/cjs/babelPlugins/babel-plugin-redwood-cell.js +0 -122
  23. package/dist/cjs/babelPlugins/babel-plugin-redwood-prerender-media-imports.d.ts +0 -5
  24. package/dist/cjs/babelPlugins/babel-plugin-redwood-prerender-media-imports.d.ts.map +0 -1
  25. package/dist/cjs/babelPlugins/babel-plugin-redwood-prerender-media-imports.js +0 -101
  26. package/dist/cjs/babelPlugins/utils.d.ts +0 -2
  27. package/dist/cjs/babelPlugins/utils.d.ts.map +0 -1
  28. package/dist/cjs/babelPlugins/utils.js +0 -49
  29. package/dist/cjs/browserUtils/index.d.ts +0 -8
  30. package/dist/cjs/browserUtils/index.d.ts.map +0 -1
  31. package/dist/cjs/browserUtils/index.js +0 -47
  32. package/dist/cjs/build-and-import/buildAndImport.js +0 -186
  33. package/dist/cjs/build-and-import/load-tsconfig.d.js +0 -1
  34. package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedar-remove-dev-fatal-error-page.js +0 -53
  35. package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-cell.js +0 -184
  36. package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-directory-named-imports.js +0 -83
  37. package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-external.js +0 -125
  38. package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-ignore-html-and-css-imports.js +0 -48
  39. package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-inject-file-globals.js +0 -66
  40. package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-prerender-media-imports.js +0 -118
  41. package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-routes-auto-loader.js +0 -146
  42. package/dist/cjs/build-and-import/rollupPlugins/utils.js +0 -78
  43. package/dist/cjs/build-and-import/utils.js +0 -68
  44. package/dist/cjs/detection/detection.d.ts +0 -11
  45. package/dist/cjs/detection/detection.d.ts.map +0 -1
  46. package/dist/cjs/detection/detection.js +0 -46
  47. package/dist/cjs/errors.d.ts +0 -19
  48. package/dist/cjs/errors.d.ts.map +0 -1
  49. package/dist/cjs/errors.js +0 -52
  50. package/dist/cjs/graphql/graphql.d.ts +0 -19
  51. package/dist/cjs/graphql/graphql.d.ts.map +0 -1
  52. package/dist/cjs/graphql/graphql.js +0 -152
  53. package/dist/cjs/graphql/node-runner.js +0 -97
  54. package/dist/cjs/graphql/vite-plugin-cedar-auto-import.js +0 -107
  55. package/dist/cjs/index.js +0 -22
  56. package/dist/cjs/internal.d.ts +0 -28
  57. package/dist/cjs/internal.d.ts.map +0 -1
  58. package/dist/cjs/internal.js +0 -135
  59. package/dist/cjs/package.json +0 -1
  60. package/dist/cjs/runPrerender.d.ts.map +0 -1
  61. package/dist/cjs/runPrerender.js +0 -313
  62. package/dist/cjs/runPrerenderEsm.js +0 -310
  63. package/dist/runPrerenderEsm.d.ts +0 -9
  64. package/dist/runPrerenderEsm.d.ts.map +0 -1
  65. /package/dist/{cjs/index.d.ts → index.d.ts} +0 -0
  66. /package/dist/{cjs/runPrerender.d.ts → runPrerender.d.ts} +0 -0
@@ -1,83 +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 rollup_plugin_cedarjs_directory_named_imports_exports = {};
30
- __export(rollup_plugin_cedarjs_directory_named_imports_exports, {
31
- cedarjsDirectoryNamedImportPlugin: () => cedarjsDirectoryNamedImportPlugin
32
- });
33
- module.exports = __toCommonJS(rollup_plugin_cedarjs_directory_named_imports_exports);
34
- var import_node_fs = __toESM(require("node:fs"), 1);
35
- var import_node_path = __toESM(require("node:path"), 1);
36
- var import_project_config = require("@cedarjs/project-config");
37
- function getNewPath(value, filename) {
38
- const dirname = import_node_path.default.dirname(value);
39
- const basename = import_node_path.default.basename(value);
40
- const indexImportPath = [dirname, basename, "index"].join("/");
41
- const resolvedFile = (0, import_project_config.resolveFile)(
42
- import_node_path.default.resolve(import_node_path.default.dirname(filename), indexImportPath)
43
- );
44
- if (resolvedFile) {
45
- return resolvedFile;
46
- } else {
47
- const dirnameImportPath = [dirname, basename, basename].join("/");
48
- const dirnameResolvedFile = (0, import_project_config.resolveFile)(
49
- import_node_path.default.resolve(import_node_path.default.dirname(filename), dirnameImportPath)
50
- );
51
- if (dirnameResolvedFile) {
52
- return dirnameResolvedFile;
53
- }
54
- }
55
- return null;
56
- }
57
- function cedarjsDirectoryNamedImportPlugin() {
58
- return {
59
- name: "cedarjs-directory-named-import",
60
- resolveId(id, importer) {
61
- if (!importer || importer.includes("/node_modules/")) {
62
- return null;
63
- }
64
- const resolvedPath = import_node_path.default.resolve(import_node_path.default.dirname(importer), id);
65
- if (import_node_fs.default.existsSync(resolvedPath)) {
66
- const stats = import_node_fs.default.statSync(resolvedPath);
67
- if (stats.isFile()) {
68
- return null;
69
- }
70
- }
71
- const newPath = getNewPath(id, importer);
72
- if (!newPath) {
73
- return null;
74
- }
75
- const resolvedDirnamePath = import_node_path.default.resolve(import_node_path.default.dirname(importer), newPath);
76
- return resolvedDirnamePath;
77
- }
78
- };
79
- }
80
- // Annotate the CommonJS export names for ESM import in node:
81
- 0 && (module.exports = {
82
- cedarjsDirectoryNamedImportPlugin
83
- });
@@ -1,125 +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 rollup_plugin_cedarjs_external_exports = {};
30
- __export(rollup_plugin_cedarjs_external_exports, {
31
- externalPlugin: () => externalPlugin
32
- });
33
- module.exports = __toCommonJS(rollup_plugin_cedarjs_external_exports);
34
- var import_node_path = __toESM(require("node:path"), 1);
35
- var import_node_url = require("node:url");
36
- const PATH_NODE_MODULES_RE = /[\/\\]node_modules[\/\\]/;
37
- const externalPlugin = ({
38
- external,
39
- notExternal,
40
- filepath,
41
- externalNodeModules = true
42
- }) => {
43
- const extNodeModules = externalNodeModules ?? !filepath.match(PATH_NODE_MODULES_RE);
44
- const builtinModules = /* @__PURE__ */ new Set([
45
- "assert",
46
- "buffer",
47
- "child_process",
48
- "cluster",
49
- "crypto",
50
- "dgram",
51
- "dns",
52
- "domain",
53
- "events",
54
- "fs",
55
- "http",
56
- "https",
57
- "net",
58
- "os",
59
- "path",
60
- "punycode",
61
- "querystring",
62
- "readline",
63
- "stream",
64
- "string_decoder",
65
- "tls",
66
- "tty",
67
- "url",
68
- "util",
69
- "v8",
70
- "vm",
71
- "zlib",
72
- "constants",
73
- "sys",
74
- "module",
75
- "process",
76
- "inspector",
77
- "async_hooks",
78
- "http2",
79
- "perf_hooks",
80
- "trace_events",
81
- "worker_threads",
82
- "repl",
83
- "timers"
84
- ]);
85
- return {
86
- name: "bundle-require:external",
87
- resolveId(id, importer) {
88
- if (builtinModules.has(id) || id.startsWith("node:")) {
89
- return { id, external: true };
90
- }
91
- if (match(id, external)) {
92
- return { id, external: true };
93
- }
94
- if (match(id, notExternal)) {
95
- return null;
96
- }
97
- if (extNodeModules && id.match(PATH_NODE_MODULES_RE)) {
98
- const resolved = id.startsWith(".") && importer ? import_node_path.default.resolve(import_node_path.default.dirname(importer), id) : id;
99
- return {
100
- id: (0, import_node_url.pathToFileURL)(resolved).toString(),
101
- external: true
102
- };
103
- }
104
- if (id.startsWith(".") || import_node_path.default.isAbsolute(id)) {
105
- return null;
106
- }
107
- return { id, external: true };
108
- }
109
- };
110
- };
111
- function match(id, patterns) {
112
- if (!patterns) {
113
- return false;
114
- }
115
- return patterns.some((p) => {
116
- if (p instanceof RegExp) {
117
- return p.test(id);
118
- }
119
- return id === p || id.startsWith(p + "/");
120
- });
121
- }
122
- // Annotate the CommonJS export names for ESM import in node:
123
- 0 && (module.exports = {
124
- externalPlugin
125
- });
@@ -1,48 +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_cedarjs_ignore_html_and_css_imports_exports = {};
20
- __export(rollup_plugin_cedarjs_ignore_html_and_css_imports_exports, {
21
- ignoreHtmlAndCssImportsPlugin: () => ignoreHtmlAndCssImportsPlugin
22
- });
23
- module.exports = __toCommonJS(rollup_plugin_cedarjs_ignore_html_and_css_imports_exports);
24
- const ignoreHtmlAndCssImportsPlugin = () => {
25
- const fileTypes = [".html", ".scss", ".css"];
26
- return {
27
- name: "ignore-html-and-css-imports",
28
- resolveId(id) {
29
- if (fileTypes.some((ext) => id.endsWith(ext))) {
30
- return {
31
- id: `\0virtual:ignore-${id}`,
32
- external: false
33
- };
34
- }
35
- return null;
36
- },
37
- load(id) {
38
- if (id.startsWith("\0virtual:ignore-")) {
39
- return "export default {};";
40
- }
41
- return null;
42
- }
43
- };
44
- };
45
- // Annotate the CommonJS export names for ESM import in node:
46
- 0 && (module.exports = {
47
- ignoreHtmlAndCssImportsPlugin
48
- });
@@ -1,66 +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 rollup_plugin_cedarjs_inject_file_globals_exports = {};
30
- __export(rollup_plugin_cedarjs_inject_file_globals_exports, {
31
- injectFileGlobalsPlugin: () => injectFileGlobalsPlugin
32
- });
33
- module.exports = __toCommonJS(rollup_plugin_cedarjs_inject_file_globals_exports);
34
- var import_node_path = __toESM(require("node:path"), 1);
35
- var import_node_url = require("node:url");
36
- var import_utils = require("../utils.js");
37
- const DIRNAME_VAR_NAME = "__injected_dirname__";
38
- const FILENAME_VAR_NAME = "__injected_filename__";
39
- const IMPORT_META_URL_VAR_NAME = "__injected_import_meta_url__";
40
- const injectFileGlobalsPlugin = () => {
41
- return {
42
- name: "bundle-require:inject-file-globals",
43
- transform(code, id) {
44
- if (!import_utils.JS_EXT_RE.test(id)) {
45
- return null;
46
- }
47
- const transformedCode = code.replace(/\b__filename\b/g, FILENAME_VAR_NAME).replace(/\b__dirname\b/g, DIRNAME_VAR_NAME).replace(/\bimport\.meta\.url\b/g, IMPORT_META_URL_VAR_NAME);
48
- const injectLines = [
49
- `const ${FILENAME_VAR_NAME} = ${JSON.stringify(id)};`,
50
- `const ${DIRNAME_VAR_NAME} = ${JSON.stringify(import_node_path.default.dirname(id))};`,
51
- `const ${IMPORT_META_URL_VAR_NAME} = ${JSON.stringify(
52
- (0, import_node_url.pathToFileURL)(id).href
53
- )};`
54
- ];
55
- return {
56
- code: injectLines.join("\n") + "\n" + transformedCode,
57
- // TODO: Generate a proper source map
58
- map: { mappings: "" }
59
- };
60
- }
61
- };
62
- };
63
- // Annotate the CommonJS export names for ESM import in node:
64
- 0 && (module.exports = {
65
- injectFileGlobalsPlugin
66
- });
@@ -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 rollup_plugin_cedarjs_prerender_media_imports_exports = {};
30
- __export(rollup_plugin_cedarjs_prerender_media_imports_exports, {
31
- cedarjsPrerenderMediaImportsPlugin: () => cedarjsPrerenderMediaImportsPlugin
32
- });
33
- module.exports = __toCommonJS(rollup_plugin_cedarjs_prerender_media_imports_exports);
34
- var import_node_fs = __toESM(require("node:fs"), 1);
35
- var import_node_path = require("node:path");
36
- var import_project_config = require("@cedarjs/project-config");
37
- var import_utils = require("./utils.js");
38
- const defaultExtensions = [
39
- ".ico",
40
- ".jpg",
41
- ".jpeg",
42
- ".png",
43
- ".gif",
44
- ".svg",
45
- ".eot",
46
- ".otf",
47
- ".webp",
48
- ".ttf",
49
- ".woff",
50
- ".woff2",
51
- ".cur",
52
- ".ani",
53
- ".pdf",
54
- ".bmp"
55
- ];
56
- function cedarjsPrerenderMediaImportsPlugin(options = {}) {
57
- const extensions = options.extensions || defaultExtensions;
58
- let buildManifest = null;
59
- return {
60
- name: "cedarjs-prerender-media-imports",
61
- buildStart() {
62
- try {
63
- const manifestPath = (0, import_node_path.join)(
64
- (0, import_project_config.getPaths)().web.dist,
65
- "client-build-manifest.json"
66
- );
67
- buildManifest = JSON.parse(import_node_fs.default.readFileSync(manifestPath, "utf-8"));
68
- } catch {
69
- buildManifest = {};
70
- }
71
- },
72
- resolveId(source, _importer) {
73
- const ext = (0, import_node_path.extname)(source);
74
- if (!ext || !extensions.includes(ext)) {
75
- return null;
76
- }
77
- return {
78
- id: source,
79
- external: false
80
- };
81
- },
82
- load(id) {
83
- const ext = (0, import_node_path.extname)(id);
84
- if (!ext || !extensions.includes(ext)) {
85
- return null;
86
- }
87
- const importerModule = Array.from(this.getModuleIds()).find(
88
- (moduleId) => {
89
- const moduleInfo = this.getModuleInfo(moduleId);
90
- return moduleInfo?.importedIds?.includes(id);
91
- }
92
- );
93
- let absPath;
94
- let viteManifestKey;
95
- if (importerModule && importerModule !== "entry.js") {
96
- const importerDir = (0, import_node_path.dirname)(importerModule);
97
- absPath = (0, import_node_path.join)(importerDir, id);
98
- viteManifestKey = (0, import_project_config.ensurePosixPath)((0, import_node_path.relative)((0, import_project_config.getPaths)().web.src, absPath));
99
- } else {
100
- const normalizedId = id.startsWith("./") ? id.slice(2) : id;
101
- absPath = (0, import_node_path.join)((0, import_project_config.getPaths)().web.src, normalizedId);
102
- viteManifestKey = (0, import_project_config.ensurePosixPath)(normalizedId);
103
- }
104
- const copiedAssetPath = buildManifest?.[viteManifestKey]?.file;
105
- let assetSrc;
106
- if (copiedAssetPath) {
107
- assetSrc = copiedAssetPath;
108
- } else {
109
- assetSrc = (0, import_utils.convertToDataUrl)(absPath);
110
- }
111
- return `export default ${JSON.stringify(assetSrc)};`;
112
- }
113
- };
114
- }
115
- // Annotate the CommonJS export names for ESM import in node:
116
- 0 && (module.exports = {
117
- cedarjsPrerenderMediaImportsPlugin
118
- });
@@ -1,146 +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 rollup_plugin_cedarjs_routes_auto_loader_exports = {};
30
- __export(rollup_plugin_cedarjs_routes_auto_loader_exports, {
31
- cedarjsRoutesAutoLoaderPlugin: () => cedarjsRoutesAutoLoaderPlugin
32
- });
33
- module.exports = __toCommonJS(rollup_plugin_cedarjs_routes_auto_loader_exports);
34
- var import_path = __toESM(require("path"), 1);
35
- var import_pluginutils = require("@rollup/pluginutils");
36
- var import_project_config = require("@cedarjs/project-config");
37
- var import_utils = require("./utils.js");
38
- function getPathRelativeToSrc(maybeAbsolutePath) {
39
- if (!import_path.default.isAbsolute(maybeAbsolutePath)) {
40
- return maybeAbsolutePath;
41
- }
42
- return `./${import_path.default.relative((0, import_project_config.getPaths)().web.src, maybeAbsolutePath)}`;
43
- }
44
- function withRelativeImports(page) {
45
- return {
46
- ...page,
47
- relativeImport: (0, import_project_config.ensurePosixPath)(getPathRelativeToSrc(page.importPath))
48
- };
49
- }
50
- function cedarjsRoutesAutoLoaderPlugin() {
51
- let pages = (0, import_project_config.processPagesDir)().map(withRelativeImports);
52
- const duplicatePageImportNames = /* @__PURE__ */ new Set();
53
- const sortedPageImportNames = pages.map((page) => page.importName).sort();
54
- for (let i = 0; i < sortedPageImportNames.length - 1; i++) {
55
- if (sortedPageImportNames[i + 1] === sortedPageImportNames[i]) {
56
- duplicatePageImportNames.add(sortedPageImportNames[i]);
57
- }
58
- }
59
- if (duplicatePageImportNames.size > 0) {
60
- const dirList = Array.from(duplicatePageImportNames).map((name) => `'${name}'`).join(", ");
61
- throw new Error(
62
- `Unable to find only a single file ending in 'Page.{js,jsx,ts,tsx}' in the following page directories: ${dirList}`
63
- );
64
- }
65
- const filter = (0, import_pluginutils.createFilter)(["**/src/Routes.{tsx,jsx,js}"]);
66
- return {
67
- name: "cedarjs-routes-auto-loader",
68
- buildStart() {
69
- pages = (0, import_project_config.processPagesDir)().map(withRelativeImports);
70
- },
71
- transform(code, id) {
72
- if (!filter(id)) {
73
- return null;
74
- }
75
- let currentPages = [...pages];
76
- const importRegex = /import\s+(\w+)\s+from\s+['"]([^'"]+)['"]/g;
77
- let match;
78
- const excludedPages = /* @__PURE__ */ new Set();
79
- while ((match = importRegex.exec(code)) !== null) {
80
- const [_fullMatch, defaultImportName, importPath] = match;
81
- const importPathWithoutExtension = importPath.replace(
82
- /\.(js|jsx|ts|tsx)$/,
83
- ""
84
- );
85
- const normalizedPathBase = importPathWithoutExtension.replace(
86
- /\/[^/]+$/,
87
- ""
88
- );
89
- const normalizedPathFull = importPathWithoutExtension;
90
- const userImportRelativePaths = [
91
- getPathRelativeToSrc((0, import_project_config.importStatementPath)(normalizedPathBase)),
92
- getPathRelativeToSrc((0, import_project_config.importStatementPath)(normalizedPathFull))
93
- ];
94
- const pageThatUserImported = currentPages.find((page) => {
95
- const pageRelativeImport = page.relativeImport.replace(
96
- /\.(js|jsx|ts|tsx)$/,
97
- ""
98
- );
99
- const importNameMatches = page.importName === defaultImportName;
100
- const pathMatches = userImportRelativePaths.some(
101
- (path2) => pageRelativeImport === (0, import_project_config.ensurePosixPath)(path2) || pageRelativeImport.endsWith(`/${path2.split("/").pop()}`)
102
- );
103
- return importNameMatches || pathMatches;
104
- });
105
- if (pageThatUserImported) {
106
- excludedPages.add(pageThatUserImported.importName);
107
- currentPages = currentPages.filter(
108
- (page) => page !== pageThatUserImported
109
- );
110
- }
111
- }
112
- if (currentPages.length === 0) {
113
- return { code, map: null };
114
- }
115
- const imports = [];
116
- const declarations = [];
117
- imports.push(`import { lazy } from 'react'`);
118
- for (const { importName, relativeImport } of currentPages) {
119
- if (excludedPages.has(importName)) {
120
- continue;
121
- }
122
- imports.push(
123
- `import __cedarjs_prerender__${importName} from '${relativeImport}';`
124
- );
125
- const declaration = (0, import_utils.dedent)(8)`const ${importName} = {
126
- name: "${importName}",
127
- prerenderLoader: (name) => ({ default: __cedarjs_prerender__${importName} }),
128
- LazyComponent: lazy(() => import("${relativeImport}"))
129
- }`;
130
- declarations.push(declaration);
131
- }
132
- const autoLoaderCode = imports.join("\n") + "\n\n" + declarations.join("\n\n");
133
- const finalCode = `${autoLoaderCode}
134
-
135
- ${code}`;
136
- return {
137
- code: finalCode,
138
- map: null
139
- };
140
- }
141
- };
142
- }
143
- // Annotate the CommonJS export names for ESM import in node:
144
- 0 && (module.exports = {
145
- cedarjsRoutesAutoLoaderPlugin
146
- });
@@ -1,78 +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
- dedent: () => dedent
33
- });
34
- module.exports = __toCommonJS(utils_exports);
35
- var import_node_fs = __toESM(require("node:fs"), 1);
36
- var import_mime_types = __toESM(require("mime-types"), 1);
37
- function convertToDataUrl(assetPath) {
38
- try {
39
- const base64AssetContents = import_node_fs.default.readFileSync(assetPath, "base64");
40
- const mimeType = import_mime_types.default.lookup(assetPath);
41
- return `data:${mimeType};base64,${base64AssetContents}`;
42
- } catch {
43
- console.warn(`Could not read file ${assetPath} for conversion to data uri`);
44
- return "";
45
- }
46
- }
47
- function dedent(indentLevel) {
48
- return (strings, ...values) => {
49
- let result = strings[0];
50
- for (let i = 0; i < values.length; i++) {
51
- result += values[i] + strings[i + 1];
52
- }
53
- const lines = result.split("\n");
54
- while (lines.length > 0 && lines[0].trim() === "") {
55
- lines.shift();
56
- }
57
- while (lines.length > 0 && lines[lines.length - 1].trim() === "") {
58
- lines.pop();
59
- }
60
- const minIndent = indentLevel;
61
- const dedentedLines = lines.map((line) => {
62
- if (line.trim() === "") {
63
- return "";
64
- }
65
- const match = line.match(/^(\s*)/);
66
- if (match && match[1].length >= minIndent) {
67
- return line.slice(minIndent);
68
- }
69
- return line;
70
- });
71
- return dedentedLines.join("\n");
72
- };
73
- }
74
- // Annotate the CommonJS export names for ESM import in node:
75
- 0 && (module.exports = {
76
- convertToDataUrl,
77
- dedent
78
- });