@cedarjs/vite 5.0.7-next.338 → 5.0.7
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/bins/cedar-vite-dev.mjs +1 -14
- package/dist/api/vite-plugin-cedar-vitest-api-preset.d.ts.map +1 -1
- package/dist/api/vite-plugin-cedar-vitest-api-preset.js +0 -4
- package/dist/apiDevMiddleware.d.ts.map +1 -1
- package/dist/apiDevMiddleware.js +15 -117
- package/dist/buildApp.d.ts.map +1 -1
- package/dist/buildApp.js +18 -77
- package/dist/buildRouteHooks.d.ts.map +1 -1
- package/dist/buildRouteHooks.js +4 -36
- package/dist/bundled/react-server-dom-webpack.server.js +99 -192
- package/dist/cedar-unified-dev.d.ts +0 -19
- package/dist/cedar-unified-dev.d.ts.map +1 -1
- package/dist/cedar-unified-dev.js +9 -74
- package/dist/cjs/ClientRouter.d.ts +1 -0
- package/dist/cjs/api/vite-plugin-cedar-vitest-api-preset.js +37 -0
- package/dist/cjs/apiDevMiddleware.js +371 -0
- package/dist/cjs/build/build.d.ts +1 -0
- package/dist/cjs/build/build.js +58 -0
- package/dist/cjs/buildApp.js +306 -0
- package/dist/cjs/buildFeServer.d.ts +1 -0
- package/dist/cjs/buildFeServer.js +63 -0
- package/dist/cjs/buildRouteHooks.js +80 -0
- package/dist/cjs/buildRouteManifest.js +92 -0
- package/dist/cjs/buildRscClientAndServer.js +54 -0
- package/dist/cjs/cedar-unified-dev.js +310 -0
- package/dist/cjs/client.d.ts +1 -0
- package/dist/cjs/clientSsr.d.ts +1 -0
- package/dist/cjs/devFeServer.js +157 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +141 -0
- package/dist/cjs/lib/StatusError.js +37 -0
- package/dist/cjs/lib/entries.js +52 -0
- package/dist/cjs/lib/getMergedConfig.js +185 -0
- package/dist/cjs/lib/onWarn.js +36 -0
- package/dist/cjs/lib/registerFwGlobalsAndShims.js +102 -0
- package/dist/cjs/lib/workspacePackageAliases.js +107 -0
- package/dist/cjs/middleware/index.js +22 -0
- package/dist/cjs/middleware/invokeMiddleware.js +52 -0
- package/dist/cjs/middleware/register.js +105 -0
- package/dist/cjs/middleware/types.js +16 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/plugins/vite-plugin-cedar-auto-import.js +107 -0
- package/dist/cjs/plugins/vite-plugin-cedar-cell.js +183 -0
- package/dist/cjs/plugins/vite-plugin-cedar-cjs-compat.js +341 -0
- package/dist/cjs/plugins/vite-plugin-cedar-context-wrapping.js +95 -0
- package/dist/cjs/plugins/vite-plugin-cedar-entry-injection.js +107 -0
- package/dist/cjs/plugins/vite-plugin-cedar-html-env.js +67 -0
- package/dist/cjs/plugins/vite-plugin-cedar-import-dir.js +118 -0
- package/dist/cjs/plugins/vite-plugin-cedar-node-polyfills.js +43 -0
- package/dist/cjs/plugins/vite-plugin-cedar-remove-dev-fatal-error-page.js +61 -0
- package/dist/cjs/plugins/vite-plugin-cedar-remove-from-bundle.js +76 -0
- package/dist/cjs/plugins/vite-plugin-cedar-routes-auto-loader.js +126 -0
- package/dist/cjs/plugins/vite-plugin-cedar-universal-deploy.js +346 -0
- package/dist/cjs/plugins/vite-plugin-cedar-wait-for-api-server.js +134 -0
- package/dist/cjs/plugins/vite-plugin-cedarjs-job-path-injector.js +134 -0
- package/dist/cjs/plugins/vite-plugin-cedarjs-resolve-cedar-style-imports.js +106 -0
- package/dist/cjs/plugins/vite-plugin-jsx-loader.js +42 -0
- package/dist/cjs/plugins/vite-plugin-merged-config.js +39 -0
- package/dist/cjs/plugins/vite-plugin-rsc-analyze.js +104 -0
- package/dist/cjs/plugins/vite-plugin-rsc-reload.js +75 -0
- package/dist/cjs/plugins/vite-plugin-rsc-routes-auto-loader.js +159 -0
- package/dist/cjs/plugins/vite-plugin-rsc-routes-imports.js +125 -0
- package/dist/cjs/plugins/vite-plugin-rsc-ssr-router-import.js +75 -0
- package/dist/cjs/plugins/vite-plugin-rsc-transform-client.js +228 -0
- package/dist/cjs/plugins/vite-plugin-rsc-transform-server.js +398 -0
- package/dist/cjs/plugins/vite-plugin-swap-apollo-provider.js +46 -0
- package/dist/cjs/rsc/rscBuildAnalyze.js +126 -0
- package/dist/cjs/rsc/rscBuildClient.js +91 -0
- package/dist/cjs/rsc/rscBuildCopyCssAssets.js +56 -0
- package/dist/cjs/rsc/rscBuildEntriesFile.js +115 -0
- package/dist/cjs/rsc/rscBuildForServer.js +168 -0
- package/dist/cjs/rsc/rscBuildForSsr.js +173 -0
- package/dist/cjs/rsc/rscBuildRwEnvVars.js +56 -0
- package/dist/cjs/rsc/rscRenderer.js +165 -0
- package/dist/cjs/rsc/rscRequestHandler.js +162 -0
- package/dist/cjs/rsc/rscStudioHandlers.js +156 -0
- package/dist/cjs/runFeServer.js +165 -0
- package/dist/cjs/streaming/buildForStreamingServer.js +65 -0
- package/dist/cjs/streaming/collectCss.js +52 -0
- package/dist/cjs/streaming/createReactStreamingHandler.js +173 -0
- package/dist/cjs/streaming/streamHelpers.js +230 -0
- package/dist/cjs/streaming/transforms/bufferedTransform.js +61 -0
- package/dist/cjs/streaming/transforms/cancelTimeoutTransform.js +34 -0
- package/dist/cjs/streaming/transforms/encode-decode.js +36 -0
- package/dist/cjs/streaming/transforms/serverInjectionTransform.js +84 -0
- package/dist/cjs/streaming/triggerRouteHooks.js +96 -0
- package/dist/cjs/types.js +16 -0
- package/dist/cjs/utils.js +92 -0
- package/dist/devFeServer.js +8 -3
- package/dist/index.d.ts +4 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -51
- package/dist/lib/getMergedConfig.d.ts.map +1 -1
- package/dist/lib/getMergedConfig.js +6 -16
- package/dist/lib/registerFwGlobalsAndShims.d.ts.map +1 -1
- package/dist/lib/registerFwGlobalsAndShims.js +4 -14
- package/dist/package.json +1 -0
- package/dist/plugins/vite-plugin-cedar-auto-import.d.ts +1 -1
- package/dist/plugins/vite-plugin-cedar-auto-import.d.ts.map +1 -1
- package/dist/plugins/vite-plugin-cedar-auto-import.js +1 -8
- package/dist/plugins/vite-plugin-cedar-cell.d.ts.map +1 -1
- package/dist/plugins/vite-plugin-cedar-cell.js +1 -2
- package/dist/plugins/{vite-plugin-handler-als-wrapping.d.ts → vite-plugin-cedar-context-wrapping.d.ts} +12 -12
- package/dist/plugins/vite-plugin-cedar-context-wrapping.d.ts.map +1 -0
- package/dist/plugins/{vite-plugin-handler-als-wrapping.js → vite-plugin-cedar-context-wrapping.js} +16 -16
- package/dist/plugins/vite-plugin-cedar-import-dir.d.ts.map +1 -1
- package/dist/plugins/vite-plugin-cedar-import-dir.js +31 -44
- package/dist/plugins/vite-plugin-cedar-node-polyfills.d.ts +3 -0
- package/dist/plugins/vite-plugin-cedar-node-polyfills.d.ts.map +1 -0
- package/dist/plugins/vite-plugin-cedar-node-polyfills.js +19 -0
- package/dist/plugins/vite-plugin-cedar-universal-deploy.d.ts.map +1 -1
- package/dist/plugins/vite-plugin-cedar-universal-deploy.js +90 -92
- package/dist/plugins/vite-plugin-cedarjs-job-path-injector.d.ts +0 -29
- package/dist/plugins/vite-plugin-cedarjs-job-path-injector.d.ts.map +1 -1
- package/dist/plugins/vite-plugin-cedarjs-job-path-injector.js +81 -63
- package/dist/plugins/vite-plugin-cedarjs-resolve-cedar-style-imports.d.ts.map +1 -1
- package/dist/plugins/vite-plugin-cedarjs-resolve-cedar-style-imports.js +0 -14
- package/dist/plugins/vite-plugin-rsc-analyze.js +1 -2
- package/dist/plugins/vite-plugin-swap-apollo-provider.d.ts +0 -3
- package/dist/plugins/vite-plugin-swap-apollo-provider.d.ts.map +1 -1
- package/dist/plugins/vite-plugin-swap-apollo-provider.js +2 -2
- package/dist/rsc/rscBuildForSsr.d.ts.map +1 -1
- package/dist/rsc/rscBuildForSsr.js +5 -3
- package/dist/streaming/buildForStreamingServer.d.ts.map +1 -1
- package/dist/streaming/buildForStreamingServer.js +5 -3
- package/package.json +57 -47
- package/dist/jobsDevMiddleware.d.ts +0 -17
- package/dist/jobsDevMiddleware.d.ts.map +0 -1
- package/dist/jobsDevMiddleware.js +0 -106
- package/dist/lib/generateDiffSourceMap.d.ts +0 -18
- package/dist/lib/generateDiffSourceMap.d.ts.map +0 -1
- package/dist/lib/generateDiffSourceMap.js +0 -151
- package/dist/plugins/vite-plugin-cedar-api-import-guard.d.ts +0 -13
- package/dist/plugins/vite-plugin-cedar-api-import-guard.d.ts.map +0 -1
- package/dist/plugins/vite-plugin-cedar-api-import-guard.js +0 -17
- package/dist/plugins/vite-plugin-cedar-data-uri-shim.d.ts +0 -3
- package/dist/plugins/vite-plugin-cedar-data-uri-shim.d.ts.map +0 -1
- package/dist/plugins/vite-plugin-cedar-data-uri-shim.js +0 -43
- package/dist/plugins/vite-plugin-cedar-directory-named-import.d.ts +0 -12
- package/dist/plugins/vite-plugin-cedar-directory-named-import.d.ts.map +0 -1
- package/dist/plugins/vite-plugin-cedar-directory-named-import.js +0 -35
- package/dist/plugins/vite-plugin-cedar-gqlorm-inject.d.ts +0 -29
- package/dist/plugins/vite-plugin-cedar-gqlorm-inject.d.ts.map +0 -1
- package/dist/plugins/vite-plugin-cedar-gqlorm-inject.js +0 -76
- package/dist/plugins/vite-plugin-cedar-graphql-options-extract.d.ts +0 -42
- package/dist/plugins/vite-plugin-cedar-graphql-options-extract.d.ts.map +0 -1
- package/dist/plugins/vite-plugin-cedar-graphql-options-extract.js +0 -103
- package/dist/plugins/vite-plugin-cedar-log-formatter-dev.d.ts +0 -28
- package/dist/plugins/vite-plugin-cedar-log-formatter-dev.d.ts.map +0 -1
- package/dist/plugins/vite-plugin-cedar-log-formatter-dev.js +0 -67
- package/dist/plugins/vite-plugin-cedar-mock-cell-data.d.ts +0 -28
- package/dist/plugins/vite-plugin-cedar-mock-cell-data.d.ts.map +0 -1
- package/dist/plugins/vite-plugin-cedar-mock-cell-data.js +0 -247
- package/dist/plugins/vite-plugin-cedar-otel-wrapping.d.ts +0 -39
- package/dist/plugins/vite-plugin-cedar-otel-wrapping.d.ts.map +0 -1
- package/dist/plugins/vite-plugin-cedar-otel-wrapping.js +0 -200
- package/dist/plugins/vite-plugin-handler-als-wrapping.d.ts.map +0 -1
|
@@ -0,0 +1,134 @@
|
|
|
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_cedarjs_job_path_injector_exports = {};
|
|
30
|
+
__export(vite_plugin_cedarjs_job_path_injector_exports, {
|
|
31
|
+
cedarjsJobPathInjectorPlugin: () => cedarjsJobPathInjectorPlugin
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(vite_plugin_cedarjs_job_path_injector_exports);
|
|
34
|
+
var import_node_path = __toESM(require("node:path"), 1);
|
|
35
|
+
var import_napi = require("@ast-grep/napi");
|
|
36
|
+
var import_project_config = require("@cedarjs/project-config");
|
|
37
|
+
function cedarjsJobPathInjectorPlugin() {
|
|
38
|
+
return {
|
|
39
|
+
name: "cedarjs-job-path-injector",
|
|
40
|
+
transform(code, id) {
|
|
41
|
+
if (!code.includes("createJob")) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
const isTypescript = id.endsWith(".ts") || id.endsWith(".tsx");
|
|
45
|
+
const language = isTypescript ? import_napi.Lang.TypeScript : import_napi.Lang.JavaScript;
|
|
46
|
+
let ast;
|
|
47
|
+
try {
|
|
48
|
+
ast = (0, import_napi.parse)(language, code);
|
|
49
|
+
} catch (error) {
|
|
50
|
+
console.warn("Failed to parse file:", id);
|
|
51
|
+
console.warn(error);
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
const paths = (0, import_project_config.getPaths)();
|
|
55
|
+
const edits = [];
|
|
56
|
+
const root = ast.root();
|
|
57
|
+
const createJobCalls = root.findAll({
|
|
58
|
+
rule: {
|
|
59
|
+
pattern: "export const $VAR_NAME = $OBJ.createJob({ $$$PROPS })"
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
for (const callNode of createJobCalls) {
|
|
63
|
+
const varNameNode = callNode.getMatch("VAR_NAME");
|
|
64
|
+
const propsNodes = callNode.getMultipleMatches("PROPS");
|
|
65
|
+
if (!varNameNode) {
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
const importName = varNameNode.text();
|
|
69
|
+
const importPath = import_node_path.default.relative(paths.api.jobs, id);
|
|
70
|
+
const importPathWithoutExtension = importPath.replace(/\.[^/.]+$/, "");
|
|
71
|
+
const pathProperty = `path: ${JSON.stringify(importPathWithoutExtension)}`;
|
|
72
|
+
const nameProperty = `name: ${JSON.stringify(importName)}`;
|
|
73
|
+
let insertText = "";
|
|
74
|
+
if (propsNodes.length > 0) {
|
|
75
|
+
const objectLiteral = callNode.find({
|
|
76
|
+
rule: {
|
|
77
|
+
kind: "object",
|
|
78
|
+
inside: {
|
|
79
|
+
kind: "arguments"
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
if (objectLiteral) {
|
|
84
|
+
insertText = `, ${pathProperty}, ${nameProperty}`;
|
|
85
|
+
const objectText = objectLiteral.text();
|
|
86
|
+
const closeBraceIndex = objectText.lastIndexOf("}");
|
|
87
|
+
if (closeBraceIndex !== -1) {
|
|
88
|
+
const range = objectLiteral.range();
|
|
89
|
+
edits.push({
|
|
90
|
+
startPos: range.start.index + closeBraceIndex,
|
|
91
|
+
endPos: range.start.index + closeBraceIndex,
|
|
92
|
+
insertedText: insertText
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
} else {
|
|
97
|
+
const objectLiteral = callNode.find({
|
|
98
|
+
rule: {
|
|
99
|
+
kind: "object",
|
|
100
|
+
inside: {
|
|
101
|
+
kind: "arguments"
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
if (objectLiteral) {
|
|
106
|
+
insertText = `${pathProperty}, ${nameProperty}`;
|
|
107
|
+
const objectText = objectLiteral.text();
|
|
108
|
+
const openBraceIndex = objectText.indexOf("{");
|
|
109
|
+
if (openBraceIndex !== -1) {
|
|
110
|
+
const range = objectLiteral.range();
|
|
111
|
+
edits.push({
|
|
112
|
+
startPos: range.start.index + openBraceIndex + 1,
|
|
113
|
+
endPos: range.start.index + openBraceIndex + 1,
|
|
114
|
+
insertedText: insertText
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (edits.length === 0) {
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
const modifiedCode = root.commitEdits(edits);
|
|
124
|
+
return {
|
|
125
|
+
code: modifiedCode,
|
|
126
|
+
map: null
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
132
|
+
0 && (module.exports = {
|
|
133
|
+
cedarjsJobPathInjectorPlugin
|
|
134
|
+
});
|
|
@@ -0,0 +1,106 @@
|
|
|
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_cedarjs_resolve_cedar_style_imports_exports = {};
|
|
30
|
+
__export(vite_plugin_cedarjs_resolve_cedar_style_imports_exports, {
|
|
31
|
+
cedarjsResolveCedarStyleImportsPlugin: () => cedarjsResolveCedarStyleImportsPlugin
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(vite_plugin_cedarjs_resolve_cedar_style_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_vite = require("vite");
|
|
37
|
+
var import_project_config = require("@cedarjs/project-config");
|
|
38
|
+
function resolveFromAbsolutePath(absolutePath) {
|
|
39
|
+
const ext = import_node_path.default.extname(absolutePath);
|
|
40
|
+
const pathToResolve = ext ? absolutePath.slice(0, -ext.length) : absolutePath;
|
|
41
|
+
const direct = (0, import_project_config.resolveFile)(pathToResolve);
|
|
42
|
+
if (direct) {
|
|
43
|
+
return direct;
|
|
44
|
+
}
|
|
45
|
+
const indexFile = (0, import_project_config.resolveFile)(import_node_path.default.join(pathToResolve, "index"));
|
|
46
|
+
if (indexFile) {
|
|
47
|
+
return indexFile;
|
|
48
|
+
}
|
|
49
|
+
const dirNamedFile = (0, import_project_config.resolveFile)(
|
|
50
|
+
import_node_path.default.join(pathToResolve, import_node_path.default.basename(pathToResolve))
|
|
51
|
+
);
|
|
52
|
+
if (dirNamedFile) {
|
|
53
|
+
return dirNamedFile;
|
|
54
|
+
}
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
function cedarjsResolveCedarStyleImportsPlugin() {
|
|
58
|
+
let cedarPaths;
|
|
59
|
+
try {
|
|
60
|
+
cedarPaths = (0, import_project_config.getPaths)();
|
|
61
|
+
} catch {
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
name: "cedarjs-resolve-cedar-style-imports",
|
|
65
|
+
resolveId(id, importer) {
|
|
66
|
+
if (!importer || (0, import_vite.normalizePath)(importer).includes("/node_modules/")) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
if (cedarPaths && id.startsWith("src/")) {
|
|
70
|
+
const normalizedImporter = (0, import_vite.normalizePath)(importer);
|
|
71
|
+
const normalizedWebSrc = (0, import_vite.normalizePath)(cedarPaths.web.src);
|
|
72
|
+
const normalizedApiSrc = (0, import_vite.normalizePath)(cedarPaths.api.src);
|
|
73
|
+
let srcDir;
|
|
74
|
+
if (normalizedImporter.startsWith(normalizedWebSrc)) {
|
|
75
|
+
srcDir = cedarPaths.web.src;
|
|
76
|
+
} else if (normalizedImporter.startsWith(normalizedApiSrc)) {
|
|
77
|
+
srcDir = cedarPaths.api.src;
|
|
78
|
+
}
|
|
79
|
+
if (srcDir) {
|
|
80
|
+
const resolved = resolveFromAbsolutePath(
|
|
81
|
+
import_node_path.default.join(srcDir, id.slice("src/".length))
|
|
82
|
+
);
|
|
83
|
+
if (resolved) {
|
|
84
|
+
return (0, import_vite.normalizePath)(resolved);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const resolvedPath = import_node_path.default.resolve(import_node_path.default.dirname(importer), id);
|
|
89
|
+
if (import_node_fs.default.existsSync(resolvedPath)) {
|
|
90
|
+
const stats = import_node_fs.default.statSync(resolvedPath);
|
|
91
|
+
if (stats.isFile()) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
const newPath = resolveFromAbsolutePath(resolvedPath);
|
|
96
|
+
if (!newPath) {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
return (0, import_vite.normalizePath)(newPath);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
104
|
+
0 && (module.exports = {
|
|
105
|
+
cedarjsResolveCedarStyleImportsPlugin
|
|
106
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
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 vite_plugin_jsx_loader_exports = {};
|
|
20
|
+
__export(vite_plugin_jsx_loader_exports, {
|
|
21
|
+
cedarTransformJsAsJsx: () => cedarTransformJsAsJsx
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(vite_plugin_jsx_loader_exports);
|
|
24
|
+
var import_vite = require("vite");
|
|
25
|
+
function cedarTransformJsAsJsx() {
|
|
26
|
+
return {
|
|
27
|
+
name: "transform-js-files-as-jsx",
|
|
28
|
+
async transform(code, id) {
|
|
29
|
+
if (!id.match(/src\/.*\.js$/)) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
return (0, import_vite.transformWithEsbuild)(code, id, {
|
|
33
|
+
loader: "jsx",
|
|
34
|
+
jsx: "automatic"
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
40
|
+
0 && (module.exports = {
|
|
41
|
+
cedarTransformJsAsJsx
|
|
42
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
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 vite_plugin_merged_config_exports = {};
|
|
20
|
+
__export(vite_plugin_merged_config_exports, {
|
|
21
|
+
cedarMergedConfig: () => cedarMergedConfig
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(vite_plugin_merged_config_exports);
|
|
24
|
+
var import_project_config = require("@cedarjs/project-config");
|
|
25
|
+
var import_getMergedConfig = require("../lib/getMergedConfig.js");
|
|
26
|
+
function cedarMergedConfig() {
|
|
27
|
+
const rwPaths = (0, import_project_config.getPaths)();
|
|
28
|
+
const rwConfig = (0, import_project_config.getConfig)();
|
|
29
|
+
return {
|
|
30
|
+
name: "vite-plugin-cedar",
|
|
31
|
+
// Using the config hook here lets us modify the config but returning
|
|
32
|
+
// plugins will **not** work
|
|
33
|
+
config: (0, import_getMergedConfig.getMergedConfig)(rwConfig, rwPaths)
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
37
|
+
0 && (module.exports = {
|
|
38
|
+
cedarMergedConfig
|
|
39
|
+
});
|
|
@@ -0,0 +1,104 @@
|
|
|
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_rsc_analyze_exports = {};
|
|
30
|
+
__export(vite_plugin_rsc_analyze_exports, {
|
|
31
|
+
rscAnalyzePlugin: () => rscAnalyzePlugin
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(vite_plugin_rsc_analyze_exports);
|
|
34
|
+
var import_node_path = __toESM(require("node:path"), 1);
|
|
35
|
+
var swc = __toESM(require("@swc/core"), 1);
|
|
36
|
+
function rscAnalyzePlugin(clientEntryCallback, serverEntryCallback) {
|
|
37
|
+
return {
|
|
38
|
+
name: "redwood-rsc-analyze-plugin",
|
|
39
|
+
transform(code, id) {
|
|
40
|
+
const ext = import_node_path.default.extname(id);
|
|
41
|
+
if ([".ts", ".tsx", ".js", ".jsx"].includes(ext)) {
|
|
42
|
+
const mod = swc.parseSync(code, {
|
|
43
|
+
syntax: ext === ".ts" || ext === ".tsx" ? "typescript" : "ecmascript",
|
|
44
|
+
tsx: ext === ".tsx"
|
|
45
|
+
});
|
|
46
|
+
let directiveFound = false;
|
|
47
|
+
for (const item of mod.body) {
|
|
48
|
+
if (item.type === "ExpressionStatement" && item.expression.type === "StringLiteral") {
|
|
49
|
+
if (item.expression.value === "use client") {
|
|
50
|
+
clientEntryCallback(id);
|
|
51
|
+
directiveFound = true;
|
|
52
|
+
} else if (item.expression.value === "use server") {
|
|
53
|
+
serverEntryCallback(id);
|
|
54
|
+
directiveFound = true;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (!directiveFound && code.includes("use server") && containsServerAction(mod)) {
|
|
59
|
+
serverEntryCallback(id);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return code;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function isServerAction(node) {
|
|
67
|
+
return node.body?.type === "BlockStatement" && node.body.stmts.some(
|
|
68
|
+
(s) => s.type === "ExpressionStatement" && s.expression.type === "StringLiteral" && s.expression.value === "use server"
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
function isFunctionDeclaration(node) {
|
|
72
|
+
return node.type === "FunctionDeclaration";
|
|
73
|
+
}
|
|
74
|
+
function isFunctionExpression(node) {
|
|
75
|
+
return node.type === "FunctionExpression";
|
|
76
|
+
}
|
|
77
|
+
function isArrowFunctionExpression(node) {
|
|
78
|
+
return node.type === "ArrowFunctionExpression";
|
|
79
|
+
}
|
|
80
|
+
function containsServerAction(mod) {
|
|
81
|
+
function walk(node) {
|
|
82
|
+
if (isFunctionDeclaration(node) || isFunctionExpression(node) || isArrowFunctionExpression(node)) {
|
|
83
|
+
if (isServerAction(node)) {
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return Object.values(node).some(
|
|
88
|
+
(value) => (Array.isArray(value) ? value : [value]).some((v) => {
|
|
89
|
+
if (typeof v?.type === "string") {
|
|
90
|
+
return walk(v);
|
|
91
|
+
}
|
|
92
|
+
if (typeof v?.expression?.type === "string") {
|
|
93
|
+
return walk(v.expression);
|
|
94
|
+
}
|
|
95
|
+
return false;
|
|
96
|
+
})
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
return walk(mod);
|
|
100
|
+
}
|
|
101
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
102
|
+
0 && (module.exports = {
|
|
103
|
+
rscAnalyzePlugin
|
|
104
|
+
});
|
|
@@ -0,0 +1,75 @@
|
|
|
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_rsc_reload_exports = {};
|
|
30
|
+
__export(vite_plugin_rsc_reload_exports, {
|
|
31
|
+
rscReloadPlugin: () => rscReloadPlugin
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(vite_plugin_rsc_reload_exports);
|
|
34
|
+
var import_node_path = __toESM(require("node:path"), 1);
|
|
35
|
+
var swc = __toESM(require("@swc/core"), 1);
|
|
36
|
+
function rscReloadPlugin(fn) {
|
|
37
|
+
let enabled = false;
|
|
38
|
+
const isClientEntry = (id, code) => {
|
|
39
|
+
const ext = import_node_path.default.extname(id);
|
|
40
|
+
if ([".ts", ".tsx", ".js", ".jsx"].includes(ext)) {
|
|
41
|
+
const mod = swc.parseSync(code, {
|
|
42
|
+
syntax: ext === ".ts" || ext === ".tsx" ? "typescript" : "ecmascript",
|
|
43
|
+
tsx: ext === ".tsx"
|
|
44
|
+
});
|
|
45
|
+
for (const item of mod.body) {
|
|
46
|
+
if (item.type === "ExpressionStatement" && item.expression.type === "StringLiteral" && item.expression.value === "use client") {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return false;
|
|
52
|
+
};
|
|
53
|
+
return {
|
|
54
|
+
name: "reload-plugin",
|
|
55
|
+
configResolved(config) {
|
|
56
|
+
if (config.mode === "development") {
|
|
57
|
+
enabled = true;
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
async handleHotUpdate(ctx) {
|
|
61
|
+
if (!enabled) {
|
|
62
|
+
return [];
|
|
63
|
+
}
|
|
64
|
+
if (ctx.modules.length && !isClientEntry(ctx.file, await ctx.read())) {
|
|
65
|
+
return fn("full-reload");
|
|
66
|
+
} else {
|
|
67
|
+
return [];
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
73
|
+
0 && (module.exports = {
|
|
74
|
+
rscReloadPlugin
|
|
75
|
+
});
|
|
@@ -0,0 +1,159 @@
|
|
|
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_rsc_routes_auto_loader_exports = {};
|
|
30
|
+
__export(vite_plugin_rsc_routes_auto_loader_exports, {
|
|
31
|
+
rscRoutesAutoLoader: () => rscRoutesAutoLoader
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(vite_plugin_rsc_routes_auto_loader_exports);
|
|
34
|
+
var import_node_path = __toESM(require("node:path"), 1);
|
|
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
|
+
var t = __toESM(require("@babel/types"), 1);
|
|
39
|
+
var import_vite = require("vite");
|
|
40
|
+
var import_project_config = require("@cedarjs/project-config");
|
|
41
|
+
const generate = import_generator.default.default;
|
|
42
|
+
const traverse = import_traverse.default.default;
|
|
43
|
+
const getPathRelativeToSrc = (maybeAbsolutePath) => {
|
|
44
|
+
if (!import_node_path.default.isAbsolute(maybeAbsolutePath)) {
|
|
45
|
+
return maybeAbsolutePath;
|
|
46
|
+
}
|
|
47
|
+
return `./${import_node_path.default.relative((0, import_project_config.getPaths)().web.src, maybeAbsolutePath)}`;
|
|
48
|
+
};
|
|
49
|
+
const withRelativeImports = (page) => {
|
|
50
|
+
return {
|
|
51
|
+
...page,
|
|
52
|
+
relativeImport: (0, import_project_config.ensurePosixPath)(getPathRelativeToSrc(page.importPath))
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
function rscRoutesAutoLoader() {
|
|
56
|
+
const routesFileId = (0, import_vite.normalizePath)((0, import_project_config.getPaths)().web.routes);
|
|
57
|
+
const pages = (0, import_project_config.processPagesDir)().map(withRelativeImports);
|
|
58
|
+
const duplicatePageImportNames = /* @__PURE__ */ new Set();
|
|
59
|
+
const sortedPageImportNames = pages.map((page) => page.importName).sort();
|
|
60
|
+
for (let i = 0; i < sortedPageImportNames.length - 1; i++) {
|
|
61
|
+
if (sortedPageImportNames[i + 1] === sortedPageImportNames[i]) {
|
|
62
|
+
duplicatePageImportNames.add(sortedPageImportNames[i]);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (duplicatePageImportNames.size > 0) {
|
|
66
|
+
const pageNames = Array.from(duplicatePageImportNames).map((name) => `'${name}'`).join(", ");
|
|
67
|
+
throw new Error(
|
|
68
|
+
`Unable to find only a single file ending in 'Page.{js,jsx,ts,tsx}' in the following page directories: ${pageNames}`
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
name: "rsc-routes-auto-loader-dev",
|
|
73
|
+
transform: async function(code, id) {
|
|
74
|
+
if (id !== routesFileId) {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
if (pages.length === 0) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
const ext = import_node_path.default.extname(id);
|
|
81
|
+
const plugins = [];
|
|
82
|
+
if (ext === ".jsx") {
|
|
83
|
+
plugins.push("jsx");
|
|
84
|
+
}
|
|
85
|
+
const ast = (0, import_parser.parse)(code, {
|
|
86
|
+
sourceType: "unambiguous",
|
|
87
|
+
plugins
|
|
88
|
+
});
|
|
89
|
+
const importedNames = /* @__PURE__ */ new Set();
|
|
90
|
+
const allImports = /* @__PURE__ */ new Map();
|
|
91
|
+
const wrappers = /* @__PURE__ */ new Set();
|
|
92
|
+
traverse(ast, {
|
|
93
|
+
ImportDeclaration(path2) {
|
|
94
|
+
const importPath = path2.node.source.value;
|
|
95
|
+
if (importPath === null) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const userImportRelativePath = getPathRelativeToSrc(
|
|
99
|
+
(0, import_project_config.importStatementPath)(importPath)
|
|
100
|
+
);
|
|
101
|
+
const defaultSpecifier = path2.node.specifiers.find(
|
|
102
|
+
(specifier) => t.isImportDefaultSpecifier(specifier)
|
|
103
|
+
);
|
|
104
|
+
if (userImportRelativePath && defaultSpecifier) {
|
|
105
|
+
importedNames.add(defaultSpecifier.local.name);
|
|
106
|
+
}
|
|
107
|
+
path2.node.specifiers.forEach((specifier) => {
|
|
108
|
+
allImports.set(specifier.local.name, path2.node);
|
|
109
|
+
});
|
|
110
|
+
},
|
|
111
|
+
JSXElement() {
|
|
112
|
+
},
|
|
113
|
+
CallExpression(path2) {
|
|
114
|
+
if ((t.isIdentifier(path2.node.callee, { name: "jsxs" }) || t.isIdentifier(path2.node.callee, { name: "jsx" })) && t.isIdentifier(path2.node.arguments[0]) && path2.node.arguments[0].name === "Set") {
|
|
115
|
+
const jsxArgs = path2.node.arguments;
|
|
116
|
+
if (t.isObjectExpression(jsxArgs[1])) {
|
|
117
|
+
const wrapProp = jsxArgs[1].properties.find(
|
|
118
|
+
(prop) => t.isObjectProperty(prop) && t.isIdentifier(prop.key, { name: "wrap" })
|
|
119
|
+
);
|
|
120
|
+
if (t.isArrayExpression(wrapProp?.value)) {
|
|
121
|
+
wrapProp.value.elements.forEach((element) => {
|
|
122
|
+
if (t.isIdentifier(element)) {
|
|
123
|
+
wrappers.add(element.name);
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
} else if (t.isIdentifier(wrapProp?.value)) {
|
|
127
|
+
wrappers.add(wrapProp.value.name);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
const nonImportedPages = pages.filter(
|
|
134
|
+
(page) => !importedNames.has(page.importName)
|
|
135
|
+
);
|
|
136
|
+
wrappers.forEach((wrapper) => {
|
|
137
|
+
const wrapperImport = allImports.get(wrapper);
|
|
138
|
+
if (wrapperImport) {
|
|
139
|
+
wrapperImport.source.value = "@cedarjs/router/dist/dummyComponent";
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
for (const page of nonImportedPages) {
|
|
143
|
+
ast.program.body.unshift(
|
|
144
|
+
t.variableDeclaration("const", [
|
|
145
|
+
t.variableDeclarator(
|
|
146
|
+
t.identifier(page.constName),
|
|
147
|
+
t.arrowFunctionExpression([], t.nullLiteral())
|
|
148
|
+
)
|
|
149
|
+
])
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
return generate(ast).code;
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
157
|
+
0 && (module.exports = {
|
|
158
|
+
rscRoutesAutoLoader
|
|
159
|
+
});
|