@cedarjs/prerender 6.0.0-canary.2798 → 6.0.0-canary.2800
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.
|
@@ -32,8 +32,9 @@ __export(vite_plugin_cedar_import_dir_exports, {
|
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(vite_plugin_cedar_import_dir_exports);
|
|
34
34
|
var import_node_path = __toESM(require("node:path"), 1);
|
|
35
|
-
var import_napi = require("@ast-grep/napi");
|
|
36
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");
|
|
37
38
|
var import_project_config = require("@cedarjs/project-config");
|
|
38
39
|
function cedarImportDirPlugin() {
|
|
39
40
|
return {
|
|
@@ -43,36 +44,32 @@ function cedarImportDirPlugin() {
|
|
|
43
44
|
if (!code.includes("/**/")) {
|
|
44
45
|
return null;
|
|
45
46
|
}
|
|
46
|
-
|
|
47
|
-
const language = ext === ".ts" || ext === ".tsx" ? import_napi.Lang.TypeScript : import_napi.Lang.JavaScript;
|
|
48
|
-
let ast;
|
|
47
|
+
let program;
|
|
49
48
|
try {
|
|
50
|
-
|
|
49
|
+
program = (0, import_oxc_parser.parseSync)(id, code).program;
|
|
51
50
|
} catch (error) {
|
|
52
51
|
console.warn("Failed to parse file:", id);
|
|
53
52
|
console.warn(error);
|
|
54
53
|
return null;
|
|
55
54
|
}
|
|
56
|
-
const root = ast.root();
|
|
57
55
|
let hasTransformations = false;
|
|
58
|
-
const
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
56
|
+
const s = new import_magic_string.default(code);
|
|
57
|
+
for (const node of program.body) {
|
|
58
|
+
if (node.type !== "ImportDeclaration") {
|
|
59
|
+
continue;
|
|
62
60
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
if (!sourceNode || !defaultImportNode) {
|
|
61
|
+
const defaultSpecifier = node.specifiers.find(
|
|
62
|
+
(specifier) => specifier.type === "ImportDefaultSpecifier"
|
|
63
|
+
);
|
|
64
|
+
if (!defaultSpecifier) {
|
|
68
65
|
continue;
|
|
69
66
|
}
|
|
70
|
-
const sourceValue =
|
|
67
|
+
const sourceValue = node.source.value;
|
|
71
68
|
if (!sourceValue.includes("/**/")) {
|
|
72
69
|
continue;
|
|
73
70
|
}
|
|
74
71
|
hasTransformations = true;
|
|
75
|
-
const importName =
|
|
72
|
+
const importName = defaultSpecifier.local.name;
|
|
76
73
|
const importGlob = (0, import_project_config.importStatementPath)(sourceValue);
|
|
77
74
|
const cwd = importGlob.startsWith("src/") ? (0, import_project_config.getPaths)().api.base : import_node_path.default.dirname(id);
|
|
78
75
|
try {
|
|
@@ -95,15 +92,14 @@ function cedarImportDirPlugin() {
|
|
|
95
92
|
replacement += `${importName}.${filePathVarName} = ${namespaceImportName};
|
|
96
93
|
`;
|
|
97
94
|
}
|
|
98
|
-
|
|
95
|
+
s.overwrite(node.start, node.end, replacement.trim());
|
|
99
96
|
} catch (error) {
|
|
100
97
|
console.warn(`Failed to process glob import: ${sourceValue}`, error);
|
|
101
98
|
}
|
|
102
99
|
}
|
|
103
|
-
if (hasTransformations
|
|
104
|
-
const transformedCode = root.commitEdits(edits);
|
|
100
|
+
if (hasTransformations) {
|
|
105
101
|
return {
|
|
106
|
-
code:
|
|
102
|
+
code: s.toString(),
|
|
107
103
|
map: null
|
|
108
104
|
// For simplicity, not generating source maps
|
|
109
105
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite-plugin-cedar-import-dir.d.ts","sourceRoot":"","sources":["../../src/graphql/vite-plugin-cedar-import-dir.ts"],"names":[],"mappings":"
|
|
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,6 +1,7 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import { parse, Lang } from "@ast-grep/napi";
|
|
3
2
|
import fg from "fast-glob";
|
|
3
|
+
import MagicString from "magic-string";
|
|
4
|
+
import { parseSync } from "oxc-parser";
|
|
4
5
|
import { importStatementPath, getPaths } from "@cedarjs/project-config";
|
|
5
6
|
function cedarImportDirPlugin() {
|
|
6
7
|
return {
|
|
@@ -10,36 +11,32 @@ function cedarImportDirPlugin() {
|
|
|
10
11
|
if (!code.includes("/**/")) {
|
|
11
12
|
return null;
|
|
12
13
|
}
|
|
13
|
-
|
|
14
|
-
const language = ext === ".ts" || ext === ".tsx" ? Lang.TypeScript : Lang.JavaScript;
|
|
15
|
-
let ast;
|
|
14
|
+
let program;
|
|
16
15
|
try {
|
|
17
|
-
|
|
16
|
+
program = parseSync(id, code).program;
|
|
18
17
|
} catch (error) {
|
|
19
18
|
console.warn("Failed to parse file:", id);
|
|
20
19
|
console.warn(error);
|
|
21
20
|
return null;
|
|
22
21
|
}
|
|
23
|
-
const root = ast.root();
|
|
24
22
|
let hasTransformations = false;
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
const s = new MagicString(code);
|
|
24
|
+
for (const node of program.body) {
|
|
25
|
+
if (node.type !== "ImportDeclaration") {
|
|
26
|
+
continue;
|
|
29
27
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (!sourceNode || !defaultImportNode) {
|
|
28
|
+
const defaultSpecifier = node.specifiers.find(
|
|
29
|
+
(specifier) => specifier.type === "ImportDefaultSpecifier"
|
|
30
|
+
);
|
|
31
|
+
if (!defaultSpecifier) {
|
|
35
32
|
continue;
|
|
36
33
|
}
|
|
37
|
-
const sourceValue =
|
|
34
|
+
const sourceValue = node.source.value;
|
|
38
35
|
if (!sourceValue.includes("/**/")) {
|
|
39
36
|
continue;
|
|
40
37
|
}
|
|
41
38
|
hasTransformations = true;
|
|
42
|
-
const importName =
|
|
39
|
+
const importName = defaultSpecifier.local.name;
|
|
43
40
|
const importGlob = importStatementPath(sourceValue);
|
|
44
41
|
const cwd = importGlob.startsWith("src/") ? getPaths().api.base : path.dirname(id);
|
|
45
42
|
try {
|
|
@@ -62,15 +59,14 @@ function cedarImportDirPlugin() {
|
|
|
62
59
|
replacement += `${importName}.${filePathVarName} = ${namespaceImportName};
|
|
63
60
|
`;
|
|
64
61
|
}
|
|
65
|
-
|
|
62
|
+
s.overwrite(node.start, node.end, replacement.trim());
|
|
66
63
|
} catch (error) {
|
|
67
64
|
console.warn(`Failed to process glob import: ${sourceValue}`, error);
|
|
68
65
|
}
|
|
69
66
|
}
|
|
70
|
-
if (hasTransformations
|
|
71
|
-
const transformedCode = root.commitEdits(edits);
|
|
67
|
+
if (hasTransformations) {
|
|
72
68
|
return {
|
|
73
|
-
code:
|
|
69
|
+
code: s.toString(),
|
|
74
70
|
map: null
|
|
75
71
|
// For simplicity, not generating source maps
|
|
76
72
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/prerender",
|
|
3
|
-
"version": "6.0.0-canary.
|
|
3
|
+
"version": "6.0.0-canary.2800",
|
|
4
4
|
"description": "CedarJS prerender",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -67,14 +67,13 @@
|
|
|
67
67
|
"test:watch": "vitest watch"
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@ast-grep/napi": "0.45.0",
|
|
71
70
|
"@babel/generator": "7.29.7",
|
|
72
71
|
"@babel/parser": "7.29.7",
|
|
73
72
|
"@babel/traverse": "7.29.7",
|
|
74
|
-
"@cedarjs/babel-config": "6.0.0-canary.
|
|
75
|
-
"@cedarjs/project-config": "6.0.0-canary.
|
|
76
|
-
"@cedarjs/structure": "6.0.0-canary.
|
|
77
|
-
"@cedarjs/vite": "6.0.0-canary.
|
|
73
|
+
"@cedarjs/babel-config": "6.0.0-canary.2800",
|
|
74
|
+
"@cedarjs/project-config": "6.0.0-canary.2800",
|
|
75
|
+
"@cedarjs/structure": "6.0.0-canary.2800",
|
|
76
|
+
"@cedarjs/vite": "6.0.0-canary.2800",
|
|
78
77
|
"@rollup/plugin-alias": "5.1.1",
|
|
79
78
|
"@rollup/plugin-commonjs": "28.0.9",
|
|
80
79
|
"@rollup/plugin-node-resolve": "16.0.3",
|
|
@@ -84,7 +83,9 @@
|
|
|
84
83
|
"babel-plugin-ignore-html-and-css-imports": "0.1.0",
|
|
85
84
|
"cheerio": "1.2.0",
|
|
86
85
|
"graphql": "16.14.2",
|
|
86
|
+
"magic-string": "0.30.21",
|
|
87
87
|
"mime-types": "2.1.35",
|
|
88
|
+
"oxc-parser": "0.141.0",
|
|
88
89
|
"rollup": "4.60.4",
|
|
89
90
|
"rollup-plugin-swc3": "0.12.1",
|
|
90
91
|
"unimport": "5.7.0",
|
|
@@ -92,9 +93,9 @@
|
|
|
92
93
|
"vite": "7.3.6"
|
|
93
94
|
},
|
|
94
95
|
"devDependencies": {
|
|
95
|
-
"@cedarjs/framework-tools": "6.0.0-canary.
|
|
96
|
-
"@cedarjs/router": "6.0.0-canary.
|
|
97
|
-
"@cedarjs/web": "6.0.0-canary.
|
|
96
|
+
"@cedarjs/framework-tools": "6.0.0-canary.2800",
|
|
97
|
+
"@cedarjs/router": "6.0.0-canary.2800",
|
|
98
|
+
"@cedarjs/web": "6.0.0-canary.2800",
|
|
98
99
|
"@types/mime-types": "2.1.4",
|
|
99
100
|
"@types/react": "^18.2.55",
|
|
100
101
|
"babel-plugin-tester": "11.0.4",
|
|
@@ -104,8 +105,8 @@
|
|
|
104
105
|
"vitest": "4.1.10"
|
|
105
106
|
},
|
|
106
107
|
"peerDependencies": {
|
|
107
|
-
"@cedarjs/router": "6.0.0-canary.
|
|
108
|
-
"@cedarjs/web": "6.0.0-canary.
|
|
108
|
+
"@cedarjs/router": "6.0.0-canary.2800",
|
|
109
|
+
"@cedarjs/web": "6.0.0-canary.2800",
|
|
109
110
|
"react": "19.2.3",
|
|
110
111
|
"react-dom": "19.2.3"
|
|
111
112
|
},
|