@cedarjs/prerender 6.0.0-canary.2804 → 6.0.0-canary.2805

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.
@@ -25,7 +25,6 @@ var import_vite = require("vite");
25
25
  var import_project_config = require("@cedarjs/project-config");
26
26
  var import_vite2 = require("@cedarjs/vite");
27
27
  var import_vite_plugin_cedar_auto_import = require("./vite-plugin-cedar-auto-import.js");
28
- var import_vite_plugin_cedar_import_dir = require("./vite-plugin-cedar-import-dir.js");
29
28
  async function createViteServer(customConfig = {}) {
30
29
  const defaultConfig = {
31
30
  mode: "production",
@@ -50,7 +49,7 @@ async function createViteServer(customConfig = {}) {
50
49
  },
51
50
  plugins: [
52
51
  (0, import_vite2.cedarCjsCompatPlugin)(),
53
- (0, import_vite_plugin_cedar_import_dir.cedarImportDirPlugin)(),
52
+ (0, import_vite2.cedarImportDirPlugin)(),
54
53
  (0, import_vite_plugin_cedar_auto_import.cedarAutoImportsPlugin)(),
55
54
  (0, import_vite2.cedarjsResolveCedarStyleImportsPlugin)(),
56
55
  (0, import_vite2.cedarCellTransform)(),
@@ -5,10 +5,10 @@ import {
5
5
  cedarjsResolveCedarStyleImportsPlugin,
6
6
  cedarjsJobPathInjectorPlugin,
7
7
  cedarSwapApolloProvider,
8
- cedarCjsCompatPlugin
8
+ cedarCjsCompatPlugin,
9
+ cedarImportDirPlugin
9
10
  } from "@cedarjs/vite";
10
11
  import { cedarAutoImportsPlugin } from "./vite-plugin-cedar-auto-import.js";
11
- import { cedarImportDirPlugin } from "./vite-plugin-cedar-import-dir.js";
12
12
  async function createViteServer(customConfig = {}) {
13
13
  const defaultConfig = {
14
14
  mode: "production",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/prerender",
3
- "version": "6.0.0-canary.2804",
3
+ "version": "6.0.0-canary.2805",
4
4
  "description": "CedarJS prerender",
5
5
  "repository": {
6
6
  "type": "git",
@@ -70,10 +70,10 @@
70
70
  "@babel/generator": "7.29.7",
71
71
  "@babel/parser": "7.29.7",
72
72
  "@babel/traverse": "7.29.7",
73
- "@cedarjs/babel-config": "6.0.0-canary.2804",
74
- "@cedarjs/project-config": "6.0.0-canary.2804",
75
- "@cedarjs/structure": "6.0.0-canary.2804",
76
- "@cedarjs/vite": "6.0.0-canary.2804",
73
+ "@cedarjs/babel-config": "6.0.0-canary.2805",
74
+ "@cedarjs/project-config": "6.0.0-canary.2805",
75
+ "@cedarjs/structure": "6.0.0-canary.2805",
76
+ "@cedarjs/vite": "6.0.0-canary.2805",
77
77
  "@rollup/plugin-alias": "5.1.1",
78
78
  "@rollup/plugin-commonjs": "28.0.9",
79
79
  "@rollup/plugin-node-resolve": "16.0.3",
@@ -83,9 +83,7 @@
83
83
  "babel-plugin-ignore-html-and-css-imports": "0.1.0",
84
84
  "cheerio": "1.2.0",
85
85
  "graphql": "16.14.2",
86
- "magic-string": "0.30.21",
87
86
  "mime-types": "2.1.35",
88
- "oxc-parser": "0.141.0",
89
87
  "rollup": "4.60.4",
90
88
  "rollup-plugin-swc3": "0.12.1",
91
89
  "unimport": "5.7.0",
@@ -93,9 +91,9 @@
93
91
  "vite": "7.3.6"
94
92
  },
95
93
  "devDependencies": {
96
- "@cedarjs/framework-tools": "6.0.0-canary.2804",
97
- "@cedarjs/router": "6.0.0-canary.2804",
98
- "@cedarjs/web": "6.0.0-canary.2804",
94
+ "@cedarjs/framework-tools": "6.0.0-canary.2805",
95
+ "@cedarjs/router": "6.0.0-canary.2805",
96
+ "@cedarjs/web": "6.0.0-canary.2805",
99
97
  "@types/mime-types": "2.1.4",
100
98
  "@types/react": "^18.2.55",
101
99
  "babel-plugin-tester": "11.0.4",
@@ -105,8 +103,8 @@
105
103
  "vitest": "4.1.10"
106
104
  },
107
105
  "peerDependencies": {
108
- "@cedarjs/router": "6.0.0-canary.2804",
109
- "@cedarjs/web": "6.0.0-canary.2804",
106
+ "@cedarjs/router": "6.0.0-canary.2805",
107
+ "@cedarjs/web": "6.0.0-canary.2805",
110
108
  "react": "19.2.3",
111
109
  "react-dom": "19.2.3"
112
110
  },
@@ -1,114 +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_import_dir_exports = {};
30
- __export(vite_plugin_cedar_import_dir_exports, {
31
- cedarImportDirPlugin: () => cedarImportDirPlugin
32
- });
33
- module.exports = __toCommonJS(vite_plugin_cedar_import_dir_exports);
34
- var import_node_path = __toESM(require("node:path"), 1);
35
- var import_fast_glob = __toESM(require("fast-glob"), 1);
36
- var import_magic_string = __toESM(require("magic-string"), 1);
37
- var import_oxc_parser = require("oxc-parser");
38
- var import_project_config = require("@cedarjs/project-config");
39
- function cedarImportDirPlugin() {
40
- return {
41
- name: "vite-plugin-cedar-import-dir",
42
- enforce: "pre",
43
- async transform(code, id) {
44
- if (!code.includes("/**/")) {
45
- return null;
46
- }
47
- let program;
48
- try {
49
- program = (0, import_oxc_parser.parseSync)(id, code).program;
50
- } catch (error) {
51
- console.warn("Failed to parse file:", id);
52
- console.warn(error);
53
- return null;
54
- }
55
- let hasTransformations = false;
56
- const s = new import_magic_string.default(code);
57
- for (const node of program.body) {
58
- if (node.type !== "ImportDeclaration") {
59
- continue;
60
- }
61
- const defaultSpecifier = node.specifiers.find(
62
- (specifier) => specifier.type === "ImportDefaultSpecifier"
63
- );
64
- if (!defaultSpecifier) {
65
- continue;
66
- }
67
- const sourceValue = node.source.value;
68
- if (!sourceValue.includes("/**/")) {
69
- continue;
70
- }
71
- hasTransformations = true;
72
- const importName = defaultSpecifier.local.name;
73
- const importGlob = (0, import_project_config.importStatementPath)(sourceValue);
74
- const cwd = importGlob.startsWith("src/") ? (0, import_project_config.getPaths)().api.base : import_node_path.default.dirname(id);
75
- try {
76
- const dirFiles = import_fast_glob.default.sync(importGlob, { cwd }).filter(
77
- (n) => !n.includes(".test.") && !n.includes(".scenarios.") && !n.includes(".d.ts")
78
- );
79
- const staticGlob = importGlob.split("*")[0];
80
- const filePathToVarName = (filePath) => {
81
- return filePath.replace(staticGlob, "").replace(/\.(js|ts)$/, "").replace(/[^a-zA-Z0-9]/g, "_");
82
- };
83
- let replacement = `let ${importName} = {};
84
- `;
85
- for (const filePath of dirFiles) {
86
- const { dir: fileDir, name: fileName } = import_node_path.default.parse(filePath);
87
- const fileImportPath = fileDir + "/" + fileName;
88
- const filePathVarName = filePathToVarName(filePath);
89
- const namespaceImportName = `${importName}_${filePathVarName}`;
90
- replacement += `import * as ${namespaceImportName} from '${fileImportPath}';
91
- `;
92
- replacement += `${importName}.${filePathVarName} = ${namespaceImportName};
93
- `;
94
- }
95
- s.overwrite(node.start, node.end, replacement.trim());
96
- } catch (error) {
97
- console.warn(`Failed to process glob import: ${sourceValue}`, error);
98
- }
99
- }
100
- if (hasTransformations) {
101
- return {
102
- code: s.toString(),
103
- map: null
104
- // For simplicity, not generating source maps
105
- };
106
- }
107
- return null;
108
- }
109
- };
110
- }
111
- // Annotate the CommonJS export names for ESM import in node:
112
- 0 && (module.exports = {
113
- cedarImportDirPlugin
114
- });
@@ -1,19 +0,0 @@
1
- import type { Plugin } from 'vite';
2
- /**
3
- * This Vite plugin will search for import statements that include a glob double
4
- * star `**` in the source part of the statement. The files that are matched are
5
- * imported and appended to an object.
6
- *
7
- * @example
8
- * Given a directory "src/services" that contains "a.js", "b.ts" and
9
- * "nested/c.js" will produce the following results:
10
- * ```js
11
- * import services from 'src/services/**\/*.{js,ts}'
12
- * console.log(services)
13
- * // services.a = import('src/services/a')
14
- * // services.b = import('src/services/b')
15
- * // services.nested_c = import('src/services/nested/c')
16
- * ```
17
- */
18
- export declare function cedarImportDirPlugin(): Plugin;
19
- //# sourceMappingURL=vite-plugin-cedar-import-dir.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"vite-plugin-cedar-import-dir.d.ts","sourceRoot":"","sources":["../../src/graphql/vite-plugin-cedar-import-dir.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAIlC;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAuG7C"}
@@ -1,80 +0,0 @@
1
- import path from "node:path";
2
- import fg from "fast-glob";
3
- import MagicString from "magic-string";
4
- import { parseSync } from "oxc-parser";
5
- import { importStatementPath, getPaths } from "@cedarjs/project-config";
6
- function cedarImportDirPlugin() {
7
- return {
8
- name: "vite-plugin-cedar-import-dir",
9
- enforce: "pre",
10
- async transform(code, id) {
11
- if (!code.includes("/**/")) {
12
- return null;
13
- }
14
- let program;
15
- try {
16
- program = parseSync(id, code).program;
17
- } catch (error) {
18
- console.warn("Failed to parse file:", id);
19
- console.warn(error);
20
- return null;
21
- }
22
- let hasTransformations = false;
23
- const s = new MagicString(code);
24
- for (const node of program.body) {
25
- if (node.type !== "ImportDeclaration") {
26
- continue;
27
- }
28
- const defaultSpecifier = node.specifiers.find(
29
- (specifier) => specifier.type === "ImportDefaultSpecifier"
30
- );
31
- if (!defaultSpecifier) {
32
- continue;
33
- }
34
- const sourceValue = node.source.value;
35
- if (!sourceValue.includes("/**/")) {
36
- continue;
37
- }
38
- hasTransformations = true;
39
- const importName = defaultSpecifier.local.name;
40
- const importGlob = importStatementPath(sourceValue);
41
- const cwd = importGlob.startsWith("src/") ? getPaths().api.base : path.dirname(id);
42
- try {
43
- const dirFiles = fg.sync(importGlob, { cwd }).filter(
44
- (n) => !n.includes(".test.") && !n.includes(".scenarios.") && !n.includes(".d.ts")
45
- );
46
- const staticGlob = importGlob.split("*")[0];
47
- const filePathToVarName = (filePath) => {
48
- return filePath.replace(staticGlob, "").replace(/\.(js|ts)$/, "").replace(/[^a-zA-Z0-9]/g, "_");
49
- };
50
- let replacement = `let ${importName} = {};
51
- `;
52
- for (const filePath of dirFiles) {
53
- const { dir: fileDir, name: fileName } = path.parse(filePath);
54
- const fileImportPath = fileDir + "/" + fileName;
55
- const filePathVarName = filePathToVarName(filePath);
56
- const namespaceImportName = `${importName}_${filePathVarName}`;
57
- replacement += `import * as ${namespaceImportName} from '${fileImportPath}';
58
- `;
59
- replacement += `${importName}.${filePathVarName} = ${namespaceImportName};
60
- `;
61
- }
62
- s.overwrite(node.start, node.end, replacement.trim());
63
- } catch (error) {
64
- console.warn(`Failed to process glob import: ${sourceValue}`, error);
65
- }
66
- }
67
- if (hasTransformations) {
68
- return {
69
- code: s.toString(),
70
- map: null
71
- // For simplicity, not generating source maps
72
- };
73
- }
74
- return null;
75
- }
76
- };
77
- }
78
- export {
79
- cedarImportDirPlugin
80
- };