@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.
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,184 +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_cell_exports = {};
30
- __export(rollup_plugin_cedarjs_cell_exports, {
31
- cellTransformPlugin: () => cellTransformPlugin
32
- });
33
- module.exports = __toCommonJS(rollup_plugin_cedarjs_cell_exports);
34
- var import_node_path = require("node:path");
35
- var import_generator = __toESM(require("@babel/generator"), 1);
36
- var import_parser = require("@babel/parser");
37
- var import_traverse = __toESM(require("@babel/traverse"), 1);
38
- const traverse = import_traverse.default.default;
39
- const generate = import_generator.default.default;
40
- const EXPECTED_EXPORTS_FROM_CELL = [
41
- "beforeQuery",
42
- "QUERY",
43
- "FRAGMENT",
44
- "data",
45
- "isEmpty",
46
- "afterQuery",
47
- "Loading",
48
- "Success",
49
- "Failure",
50
- "Empty"
51
- ];
52
- function cellTransformPlugin() {
53
- return {
54
- name: "cedar-cell-transform",
55
- transform(code, id) {
56
- if (!id.match(/Cell\.[jt]sx?$/)) {
57
- return null;
58
- }
59
- try {
60
- const ast = (0, import_parser.parse)(code, {
61
- sourceType: "module",
62
- plugins: [
63
- "jsx",
64
- "typescript",
65
- "decorators-legacy",
66
- "classProperties",
67
- "objectRestSpread",
68
- "asyncGenerators",
69
- "functionBind",
70
- "exportDefaultFrom",
71
- "exportNamespaceFrom",
72
- "dynamicImport",
73
- "nullishCoalescingOperator",
74
- "optionalChaining"
75
- ]
76
- });
77
- const exportNames = [];
78
- let hasDefaultExport = false;
79
- traverse(ast, {
80
- ExportDefaultDeclaration() {
81
- hasDefaultExport = true;
82
- },
83
- ExportNamedDeclaration(path) {
84
- const declaration = path.node.declaration;
85
- if (!declaration) {
86
- return;
87
- }
88
- let name;
89
- if (declaration.type === "VariableDeclaration") {
90
- const id2 = declaration.declarations[0].id;
91
- name = id2.name;
92
- }
93
- if (declaration.type === "FunctionDeclaration") {
94
- name = declaration?.id?.name;
95
- }
96
- if (name && EXPECTED_EXPORTS_FROM_CELL.includes(name)) {
97
- exportNames.push(name);
98
- }
99
- }
100
- });
101
- const hasQueryOrDataExport = exportNames.includes("QUERY") || exportNames.includes("FRAGMENT") || exportNames.includes("data");
102
- if (hasDefaultExport || !hasQueryOrDataExport) {
103
- return null;
104
- }
105
- const createCellHookName = exportNames.includes("data") ? "createServerCell" : "createCell";
106
- const importFrom = exportNames.includes("data") ? "@cedarjs/web/dist/components/cell/createServerCell" : "@cedarjs/web";
107
- traverse(ast, {
108
- Program(path) {
109
- const importDeclaration = {
110
- type: "ImportDeclaration",
111
- specifiers: [
112
- {
113
- type: "ImportSpecifier",
114
- imported: {
115
- type: "Identifier",
116
- name: createCellHookName
117
- },
118
- local: {
119
- type: "Identifier",
120
- name: createCellHookName
121
- }
122
- }
123
- ],
124
- source: { type: "StringLiteral", value: importFrom }
125
- };
126
- path.node.body.unshift(importDeclaration);
127
- const objectProperties = [
128
- ...exportNames.map((name) => ({
129
- type: "ObjectProperty",
130
- key: { type: "Identifier", name },
131
- value: { type: "Identifier", name },
132
- shorthand: true,
133
- computed: false
134
- })),
135
- // Add the displayName property
136
- {
137
- type: "ObjectProperty",
138
- key: { type: "Identifier", name: "displayName" },
139
- value: {
140
- type: "StringLiteral",
141
- value: (0, import_node_path.parse)(id).name
142
- },
143
- shorthand: false,
144
- computed: false
145
- }
146
- ];
147
- const exportDefaultDeclaration = {
148
- type: "ExportDefaultDeclaration",
149
- declaration: {
150
- type: "CallExpression",
151
- callee: {
152
- type: "Identifier",
153
- name: createCellHookName
154
- },
155
- arguments: [
156
- {
157
- type: "ObjectExpression",
158
- properties: objectProperties
159
- }
160
- ]
161
- }
162
- };
163
- path.node.body.push(exportDefaultDeclaration);
164
- }
165
- });
166
- const result = generate(ast, {
167
- retainLines: true,
168
- compact: false
169
- });
170
- return {
171
- code: result.code,
172
- map: result.map
173
- };
174
- } catch (error) {
175
- console.warn(`Failed to transform Cell file ${id}:`, error);
176
- return null;
177
- }
178
- }
179
- };
180
- }
181
- // Annotate the CommonJS export names for ESM import in node:
182
- 0 && (module.exports = {
183
- cellTransformPlugin
184
- });
@@ -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
- });