@cedarjs/prerender 9.0.0-canary.1784 → 9.0.0-canary.3124
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/dist/apolloState.d.ts +13 -0
- package/dist/apolloState.d.ts.map +1 -0
- package/dist/apolloState.js +6 -0
- package/dist/browserUtils/index.d.ts +1 -1
- package/dist/browserUtils/index.d.ts.map +1 -1
- package/dist/build-and-import/buildAndImport.d.ts +1 -1
- package/dist/build-and-import/buildAndImport.d.ts.map +1 -1
- package/dist/build-and-import/buildAndImport.js +22 -9
- package/dist/build-and-import/rollupPlugins/rollup-plugin-cedar-remove-dev-fatal-error-page.d.ts +14 -0
- package/dist/build-and-import/rollupPlugins/rollup-plugin-cedar-remove-dev-fatal-error-page.d.ts.map +1 -0
- package/dist/build-and-import/rollupPlugins/rollup-plugin-cedar-remove-dev-fatal-error-page.js +29 -0
- package/dist/build-and-import/rollupPlugins/rollup-plugin-cedarjs-cell.d.ts.map +1 -1
- package/dist/build-and-import/rollupPlugins/rollup-plugin-cedarjs-cell.js +2 -1
- package/dist/build-and-import/rollupPlugins/rollup-plugin-cedarjs-ignore-html-and-css-imports.d.ts +4 -3
- package/dist/build-and-import/rollupPlugins/rollup-plugin-cedarjs-ignore-html-and-css-imports.d.ts.map +1 -1
- package/dist/build-and-import/rollupPlugins/rollup-plugin-cedarjs-prerender-media-imports.d.ts.map +1 -1
- package/dist/build-and-import/rollupPlugins/rollup-plugin-cedarjs-routes-auto-loader.d.ts.map +1 -1
- package/dist/detection/detection.d.ts.map +1 -1
- package/dist/detection/detection.js +1 -3
- package/dist/graphql/graphql.d.ts +17 -2
- package/dist/graphql/graphql.d.ts.map +1 -1
- package/dist/graphql/node-runner.d.ts +1 -1
- package/dist/graphql/node-runner.d.ts.map +1 -1
- package/dist/graphql/node-runner.js +27 -37
- package/dist/{cjs/index.d.ts.map → index.d.ts.map} +1 -1
- package/dist/index.js +1 -0
- package/dist/runPrerender.d.ts.map +1 -0
- package/dist/{runPrerenderEsm.js → runPrerender.js} +76 -63
- package/package.json +36 -65
- package/LICENSE +0 -21
- package/dist/babelPlugins/babel-plugin-redwood-cell.d.ts +0 -5
- package/dist/babelPlugins/babel-plugin-redwood-cell.d.ts.map +0 -1
- package/dist/babelPlugins/babel-plugin-redwood-cell.js +0 -97
- package/dist/babelPlugins/babel-plugin-redwood-prerender-media-imports.d.ts +0 -5
- package/dist/babelPlugins/babel-plugin-redwood-prerender-media-imports.d.ts.map +0 -1
- package/dist/babelPlugins/babel-plugin-redwood-prerender-media-imports.js +0 -76
- package/dist/babelPlugins/utils.d.ts +0 -2
- package/dist/babelPlugins/utils.d.ts.map +0 -1
- package/dist/babelPlugins/utils.js +0 -15
- package/dist/cjs/babelPlugins/babel-plugin-redwood-cell.d.ts +0 -5
- package/dist/cjs/babelPlugins/babel-plugin-redwood-cell.d.ts.map +0 -1
- package/dist/cjs/babelPlugins/babel-plugin-redwood-cell.js +0 -121
- package/dist/cjs/babelPlugins/babel-plugin-redwood-prerender-media-imports.d.ts +0 -5
- package/dist/cjs/babelPlugins/babel-plugin-redwood-prerender-media-imports.d.ts.map +0 -1
- package/dist/cjs/babelPlugins/babel-plugin-redwood-prerender-media-imports.js +0 -100
- package/dist/cjs/babelPlugins/utils.d.ts +0 -2
- package/dist/cjs/babelPlugins/utils.d.ts.map +0 -1
- package/dist/cjs/babelPlugins/utils.js +0 -49
- package/dist/cjs/browserUtils/index.d.ts +0 -8
- package/dist/cjs/browserUtils/index.d.ts.map +0 -1
- package/dist/cjs/browserUtils/index.js +0 -47
- package/dist/cjs/build-and-import/buildAndImport.js +0 -173
- package/dist/cjs/build-and-import/load-tsconfig.d.js +0 -1
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-cell.js +0 -183
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-directory-named-imports.js +0 -83
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-external.js +0 -125
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-ignore-html-and-css-imports.js +0 -48
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-inject-file-globals.js +0 -66
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-prerender-media-imports.js +0 -118
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-routes-auto-loader.js +0 -146
- package/dist/cjs/build-and-import/rollupPlugins/utils.js +0 -78
- package/dist/cjs/build-and-import/utils.js +0 -68
- package/dist/cjs/detection/detection.d.ts +0 -11
- package/dist/cjs/detection/detection.d.ts.map +0 -1
- package/dist/cjs/detection/detection.js +0 -48
- package/dist/cjs/errors.d.ts +0 -19
- package/dist/cjs/errors.d.ts.map +0 -1
- package/dist/cjs/errors.js +0 -52
- package/dist/cjs/graphql/graphql.d.ts +0 -19
- package/dist/cjs/graphql/graphql.d.ts.map +0 -1
- package/dist/cjs/graphql/graphql.js +0 -152
- package/dist/cjs/graphql/node-runner.js +0 -109
- package/dist/cjs/graphql/vite-plugin-cedar-auto-import.js +0 -107
- package/dist/cjs/graphql/vite-plugin-cedar-import-dir.js +0 -118
- package/dist/cjs/index.js +0 -22
- package/dist/cjs/internal.d.ts +0 -28
- package/dist/cjs/internal.d.ts.map +0 -1
- package/dist/cjs/internal.js +0 -135
- package/dist/cjs/package.json +0 -1
- package/dist/cjs/runPrerender.d.ts.map +0 -1
- package/dist/cjs/runPrerender.js +0 -307
- package/dist/cjs/runPrerenderEsm.js +0 -304
- package/dist/graphql/vite-plugin-cedar-import-dir.d.ts +0 -19
- package/dist/graphql/vite-plugin-cedar-import-dir.d.ts.map +0 -1
- package/dist/graphql/vite-plugin-cedar-import-dir.js +0 -84
- package/dist/runPrerenderEsm.d.ts +0 -9
- package/dist/runPrerenderEsm.d.ts.map +0 -1
- /package/dist/{cjs/index.d.ts → index.d.ts} +0 -0
- /package/dist/{cjs/runPrerender.d.ts → runPrerender.d.ts} +0 -0
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { DocumentNode } from 'graphql';
|
|
2
|
-
export type FileImporter = (path: string) => Promise<any>;
|
|
3
|
-
/**
|
|
4
|
-
* Loads the graphql server, with all the user's settings
|
|
5
|
-
* And execute the query against it
|
|
6
|
-
*
|
|
7
|
-
* Note that this function does NOT throw errors, even when
|
|
8
|
-
* there is a GraphQL error. Instead, it returns the result with the graphql
|
|
9
|
-
* error.
|
|
10
|
-
*/
|
|
11
|
-
export declare function executeQuery(fileImporter: FileImporter, gqlHandler: (args: any) => Promise<any>, query: DocumentNode, variables?: Record<string, unknown>): Promise<any>;
|
|
12
|
-
/**
|
|
13
|
-
* Finds the graphql handler, returns a function
|
|
14
|
-
* that can be used to execute queries against it
|
|
15
|
-
*
|
|
16
|
-
* Throws GqlHandlerImportError, so that we can warn the user (but not blow up)
|
|
17
|
-
*/
|
|
18
|
-
export declare function getGqlHandler(fileImporter: FileImporter): Promise<(operation: Record<string, unknown>) => Promise<any>>;
|
|
19
|
-
//# sourceMappingURL=graphql.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"graphql.d.ts","sourceRoot":"","sources":["../../../src/graphql/graphql.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAS3C,MAAM,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;AASzD;;;;;;;GAOG;AACH,wBAAsB,YAAY,CAChC,YAAY,EAAE,YAAY,EAC1B,UAAU,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,EACvC,KAAK,EAAE,YAAY,EACnB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,gBAmCpC;AAED;;;;;GAKG;AACH,wBAAsB,aAAa,CAAC,YAAY,EAAE,YAAY,uBAMjC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,mBAUnD"}
|
|
@@ -1,152 +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 graphql_exports = {};
|
|
30
|
-
__export(graphql_exports, {
|
|
31
|
-
executeQuery: () => executeQuery,
|
|
32
|
-
getGqlHandler: () => getGqlHandler
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(graphql_exports);
|
|
35
|
-
var import_path = __toESM(require("path"), 1);
|
|
36
|
-
var import_graphql = require("graphql");
|
|
37
|
-
var import_project_config = require("@cedarjs/project-config");
|
|
38
|
-
var import_graphql2 = require("@cedarjs/web/dist/graphql.js");
|
|
39
|
-
var import_errors = require("../errors.js");
|
|
40
|
-
async function executeQuery(fileImporter, gqlHandler, query, variables) {
|
|
41
|
-
const config = (0, import_project_config.getConfig)();
|
|
42
|
-
const operationName = (0, import_graphql2.getOperationName)(query);
|
|
43
|
-
const operation = {
|
|
44
|
-
operationName,
|
|
45
|
-
query: (0, import_graphql.print)(query),
|
|
46
|
-
variables
|
|
47
|
-
};
|
|
48
|
-
if (config.graphql.trustedDocuments) {
|
|
49
|
-
const documentsPath = import_path.default.join((0, import_project_config.getPaths)().web.graphql, "graphql");
|
|
50
|
-
const documents = await fileImporter(documentsPath);
|
|
51
|
-
const documentName = operationName[0].toUpperCase() + operationName.slice(1) + "Document";
|
|
52
|
-
const queryHash = documents?.[documentName]?.__meta__?.hash;
|
|
53
|
-
operation.query = void 0;
|
|
54
|
-
operation.extensions = {
|
|
55
|
-
persistedQuery: {
|
|
56
|
-
version: 1,
|
|
57
|
-
sha256Hash: queryHash
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
const handlerResult = await gqlHandler(operation);
|
|
62
|
-
return handlerResult?.body;
|
|
63
|
-
}
|
|
64
|
-
async function getGqlHandler(fileImporter) {
|
|
65
|
-
const gqlPath = import_path.default.join((0, import_project_config.getPaths)().api.functions, "graphql");
|
|
66
|
-
try {
|
|
67
|
-
const { handler } = await fileImporter(gqlPath);
|
|
68
|
-
return async (operation) => {
|
|
69
|
-
return await handler(buildApiEvent(operation), buildContext());
|
|
70
|
-
};
|
|
71
|
-
} catch {
|
|
72
|
-
return () => {
|
|
73
|
-
throw new import_errors.GqlHandlerImportError(
|
|
74
|
-
`Unable to import GraphQL handler at ${gqlPath}`
|
|
75
|
-
);
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
function buildApiEvent(body) {
|
|
80
|
-
return {
|
|
81
|
-
body: JSON.stringify(body),
|
|
82
|
-
headers: {
|
|
83
|
-
origin: "http://localhost:8910",
|
|
84
|
-
"content-type": "application/json",
|
|
85
|
-
accept: "*/*",
|
|
86
|
-
host: "localhost:8910"
|
|
87
|
-
},
|
|
88
|
-
multiValueHeaders: {},
|
|
89
|
-
httpMethod: "POST",
|
|
90
|
-
isBase64Encoded: false,
|
|
91
|
-
path: "/graphql",
|
|
92
|
-
pathParameters: null,
|
|
93
|
-
queryStringParameters: {},
|
|
94
|
-
multiValueQueryStringParameters: null,
|
|
95
|
-
stageVariables: null,
|
|
96
|
-
resource: "",
|
|
97
|
-
requestContext: {
|
|
98
|
-
requestId: "req-3",
|
|
99
|
-
identity: {
|
|
100
|
-
sourceIp: "::1",
|
|
101
|
-
accessKey: null,
|
|
102
|
-
accountId: null,
|
|
103
|
-
apiKey: null,
|
|
104
|
-
apiKeyId: null,
|
|
105
|
-
caller: null,
|
|
106
|
-
clientCert: null,
|
|
107
|
-
cognitoAuthenticationProvider: null,
|
|
108
|
-
cognitoAuthenticationType: null,
|
|
109
|
-
cognitoIdentityId: null,
|
|
110
|
-
cognitoIdentityPoolId: null,
|
|
111
|
-
principalOrgId: null,
|
|
112
|
-
user: null,
|
|
113
|
-
userAgent: null,
|
|
114
|
-
userArn: null
|
|
115
|
-
},
|
|
116
|
-
authorizer: {},
|
|
117
|
-
protocol: "http",
|
|
118
|
-
httpMethod: "POST",
|
|
119
|
-
path: "/graphql",
|
|
120
|
-
stage: "",
|
|
121
|
-
requestTimeEpoch: 0,
|
|
122
|
-
resourceId: "",
|
|
123
|
-
resourcePath: "",
|
|
124
|
-
accountId: "",
|
|
125
|
-
apiId: ""
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
function buildContext() {
|
|
130
|
-
return {
|
|
131
|
-
callbackWaitsForEmptyEventLoop: false,
|
|
132
|
-
functionName: "",
|
|
133
|
-
functionVersion: "",
|
|
134
|
-
invokedFunctionArn: "",
|
|
135
|
-
memoryLimitInMB: "",
|
|
136
|
-
awsRequestId: "",
|
|
137
|
-
logGroupName: "",
|
|
138
|
-
logStreamName: "",
|
|
139
|
-
getRemainingTimeInMillis: () => 100,
|
|
140
|
-
done: () => {
|
|
141
|
-
},
|
|
142
|
-
fail: () => {
|
|
143
|
-
},
|
|
144
|
-
succeed: () => {
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
149
|
-
0 && (module.exports = {
|
|
150
|
-
executeQuery,
|
|
151
|
-
getGqlHandler
|
|
152
|
-
});
|
|
@@ -1,109 +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 node_runner_exports = {};
|
|
20
|
-
__export(node_runner_exports, {
|
|
21
|
-
NodeRunner: () => NodeRunner
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(node_runner_exports);
|
|
24
|
-
var import_vite = require("vite");
|
|
25
|
-
var import_client = require("vite-node/client");
|
|
26
|
-
var import_server = require("vite-node/server");
|
|
27
|
-
var import_source_map = require("vite-node/source-map");
|
|
28
|
-
var import_project_config = require("@cedarjs/project-config");
|
|
29
|
-
var import_vite2 = require("@cedarjs/vite");
|
|
30
|
-
var import_vite_plugin_cedar_auto_import = require("./vite-plugin-cedar-auto-import.js");
|
|
31
|
-
var import_vite_plugin_cedar_import_dir = require("./vite-plugin-cedar-import-dir.js");
|
|
32
|
-
async function createViteServer(customConfig = {}) {
|
|
33
|
-
const defaultConfig = {
|
|
34
|
-
mode: "production",
|
|
35
|
-
optimizeDeps: {
|
|
36
|
-
// This is recommended in the vite-node readme
|
|
37
|
-
noDiscovery: true,
|
|
38
|
-
include: void 0
|
|
39
|
-
},
|
|
40
|
-
resolve: {
|
|
41
|
-
alias: [
|
|
42
|
-
{
|
|
43
|
-
find: /^src\/(.*?)(\.([jt]sx?))?$/,
|
|
44
|
-
replacement: (0, import_project_config.getPaths)().api.src + "/$1"
|
|
45
|
-
}
|
|
46
|
-
]
|
|
47
|
-
},
|
|
48
|
-
plugins: [
|
|
49
|
-
(0, import_vite_plugin_cedar_import_dir.cedarImportDirPlugin)(),
|
|
50
|
-
(0, import_vite_plugin_cedar_auto_import.cedarAutoImportsPlugin)(),
|
|
51
|
-
(0, import_vite2.cedarjsDirectoryNamedImportPlugin)(),
|
|
52
|
-
(0, import_vite2.cedarCellTransform)(),
|
|
53
|
-
(0, import_vite2.cedarjsJobPathInjectorPlugin)(),
|
|
54
|
-
(0, import_vite2.cedarSwapApolloProvider)()
|
|
55
|
-
]
|
|
56
|
-
};
|
|
57
|
-
const mergedConfig = (0, import_vite.mergeConfig)(defaultConfig, customConfig);
|
|
58
|
-
const server = await (0, import_vite.createServer)(mergedConfig);
|
|
59
|
-
if (Number(import_vite.version.split(".")[0]) < 6) {
|
|
60
|
-
await server.pluginContainer.buildStart({});
|
|
61
|
-
}
|
|
62
|
-
return server;
|
|
63
|
-
}
|
|
64
|
-
class NodeRunner {
|
|
65
|
-
viteServer = void 0;
|
|
66
|
-
runner = void 0;
|
|
67
|
-
customViteConfig;
|
|
68
|
-
constructor(customViteConfig = {}) {
|
|
69
|
-
this.customViteConfig = customViteConfig;
|
|
70
|
-
}
|
|
71
|
-
async init() {
|
|
72
|
-
this.viteServer = await createViteServer(this.customViteConfig);
|
|
73
|
-
const nodeServer = new import_server.ViteNodeServer(this.viteServer, {
|
|
74
|
-
transformMode: {
|
|
75
|
-
ssr: [/.*/],
|
|
76
|
-
web: [/\/web\//]
|
|
77
|
-
},
|
|
78
|
-
deps: {
|
|
79
|
-
fallbackCJS: true
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
(0, import_source_map.installSourcemapsSupport)({
|
|
83
|
-
getSourceMap: (source) => nodeServer?.getSourceMap(source)
|
|
84
|
-
});
|
|
85
|
-
this.runner = new import_client.ViteNodeRunner({
|
|
86
|
-
root: this.viteServer.config.root,
|
|
87
|
-
base: this.viteServer.config.base,
|
|
88
|
-
fetchModule(id) {
|
|
89
|
-
return nodeServer.fetchModule(id);
|
|
90
|
-
},
|
|
91
|
-
resolveId(id, importer) {
|
|
92
|
-
return nodeServer.resolveId(id, importer);
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
async importFile(filePath) {
|
|
97
|
-
if (!this.runner) {
|
|
98
|
-
await this.init();
|
|
99
|
-
}
|
|
100
|
-
return this.runner?.executeFile(filePath);
|
|
101
|
-
}
|
|
102
|
-
async close() {
|
|
103
|
-
await this.viteServer?.close();
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
107
|
-
0 && (module.exports = {
|
|
108
|
-
NodeRunner
|
|
109
|
-
});
|
|
@@ -1,107 +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_auto_import_exports = {};
|
|
30
|
-
__export(vite_plugin_cedar_auto_import_exports, {
|
|
31
|
-
cedarAutoImportsPlugin: () => cedarAutoImportsPlugin
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(vite_plugin_cedar_auto_import_exports);
|
|
34
|
-
var import_node_path = __toESM(require("node:path"), 1);
|
|
35
|
-
var import_unplugin = __toESM(require("unimport/unplugin"), 1);
|
|
36
|
-
var import_vite = __toESM(require("unplugin-auto-import/vite"), 1);
|
|
37
|
-
var import_project_config = require("@cedarjs/project-config");
|
|
38
|
-
function cedarAutoImportsPlugin() {
|
|
39
|
-
const config = (0, import_project_config.getConfig)();
|
|
40
|
-
const cedarPaths = (0, import_project_config.getPaths)();
|
|
41
|
-
const useTrustedDocumentsGqlTag = config?.graphql?.trustedDocuments;
|
|
42
|
-
return [
|
|
43
|
-
(0, import_vite.default)({
|
|
44
|
-
// targets to transform
|
|
45
|
-
include: [
|
|
46
|
-
/web\/.*\.[tj]sx?$/,
|
|
47
|
-
// Assume we want the trusted documents gql tag import in all .jsx and
|
|
48
|
-
// .tsx files
|
|
49
|
-
/\.[tj]sx$/
|
|
50
|
-
],
|
|
51
|
-
// global imports to register
|
|
52
|
-
imports: [
|
|
53
|
-
// import gql from 'graphql-tag'
|
|
54
|
-
!useTrustedDocumentsGqlTag && {
|
|
55
|
-
"graphql-tag": ["gql"]
|
|
56
|
-
},
|
|
57
|
-
// import { gql } from 'src/graphql/gql'
|
|
58
|
-
useTrustedDocumentsGqlTag && {
|
|
59
|
-
[(0, import_project_config.importStatementPath)(
|
|
60
|
-
import_node_path.default.join(cedarPaths.web.base, "src", "graphql", "gql")
|
|
61
|
-
)]: ["gql"]
|
|
62
|
-
}
|
|
63
|
-
].filter((v) => Boolean(v)),
|
|
64
|
-
// Types aren't important since the output is ephemeral
|
|
65
|
-
dts: false
|
|
66
|
-
}),
|
|
67
|
-
(0, import_vite.default)({
|
|
68
|
-
// targets to transform
|
|
69
|
-
include: [/\.[tj]sx?$/],
|
|
70
|
-
// global imports to register
|
|
71
|
-
imports: [
|
|
72
|
-
{
|
|
73
|
-
"@cedarjs/context": ["context"]
|
|
74
|
-
}
|
|
75
|
-
],
|
|
76
|
-
// Types aren't important since the output is ephemeral
|
|
77
|
-
dts: false
|
|
78
|
-
}),
|
|
79
|
-
(0, import_vite.default)({
|
|
80
|
-
// targets to transform
|
|
81
|
-
include: [/api\/.*\.[tj]sx?$/],
|
|
82
|
-
// global imports to register
|
|
83
|
-
imports: [
|
|
84
|
-
// import gql from 'graphql-tag'
|
|
85
|
-
{
|
|
86
|
-
"graphql-tag": ["gql"]
|
|
87
|
-
}
|
|
88
|
-
],
|
|
89
|
-
// Types aren't important since the output is ephemeral
|
|
90
|
-
dts: false
|
|
91
|
-
}),
|
|
92
|
-
import_unplugin.default.vite({
|
|
93
|
-
imports: [
|
|
94
|
-
// import React from 'react'
|
|
95
|
-
{
|
|
96
|
-
name: "default",
|
|
97
|
-
as: "React",
|
|
98
|
-
from: "react"
|
|
99
|
-
}
|
|
100
|
-
]
|
|
101
|
-
})
|
|
102
|
-
];
|
|
103
|
-
}
|
|
104
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
105
|
-
0 && (module.exports = {
|
|
106
|
-
cedarAutoImportsPlugin
|
|
107
|
-
});
|
|
@@ -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 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_napi = require("@ast-grep/napi");
|
|
36
|
-
var import_fast_glob = __toESM(require("fast-glob"), 1);
|
|
37
|
-
var import_project_config = require("@cedarjs/project-config");
|
|
38
|
-
function cedarImportDirPlugin() {
|
|
39
|
-
return {
|
|
40
|
-
name: "vite-plugin-cedar-import-dir",
|
|
41
|
-
enforce: "pre",
|
|
42
|
-
async transform(code, id) {
|
|
43
|
-
if (!code.includes("/**/")) {
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
const ext = import_node_path.default.extname(id);
|
|
47
|
-
const language = ext === ".ts" || ext === ".tsx" ? import_napi.Lang.TypeScript : import_napi.Lang.JavaScript;
|
|
48
|
-
let ast;
|
|
49
|
-
try {
|
|
50
|
-
ast = (0, import_napi.parse)(language, code);
|
|
51
|
-
} catch (error) {
|
|
52
|
-
console.warn("Failed to parse file:", id);
|
|
53
|
-
console.warn(error);
|
|
54
|
-
return null;
|
|
55
|
-
}
|
|
56
|
-
const root = ast.root();
|
|
57
|
-
let hasTransformations = false;
|
|
58
|
-
const edits = [];
|
|
59
|
-
const globImports = root.findAll({
|
|
60
|
-
rule: {
|
|
61
|
-
pattern: "import $DEFAULT_IMPORT from $SOURCE"
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
for (const importNode of globImports) {
|
|
65
|
-
const sourceNode = importNode.getMatch("SOURCE");
|
|
66
|
-
const defaultImportNode = importNode.getMatch("DEFAULT_IMPORT");
|
|
67
|
-
if (!sourceNode || !defaultImportNode) {
|
|
68
|
-
continue;
|
|
69
|
-
}
|
|
70
|
-
const sourceValue = sourceNode.text().slice(1, -1);
|
|
71
|
-
if (!sourceValue.includes("/**/")) {
|
|
72
|
-
continue;
|
|
73
|
-
}
|
|
74
|
-
hasTransformations = true;
|
|
75
|
-
const importName = defaultImportNode.text();
|
|
76
|
-
const importGlob = (0, import_project_config.importStatementPath)(sourceValue);
|
|
77
|
-
const cwd = importGlob.startsWith("src/") ? (0, import_project_config.getPaths)().api.base : import_node_path.default.dirname(id);
|
|
78
|
-
try {
|
|
79
|
-
const dirFiles = import_fast_glob.default.sync(importGlob, { cwd }).filter(
|
|
80
|
-
(n) => !n.includes(".test.") && !n.includes(".scenarios.") && !n.includes(".d.ts")
|
|
81
|
-
);
|
|
82
|
-
const staticGlob = importGlob.split("*")[0];
|
|
83
|
-
const filePathToVarName = (filePath) => {
|
|
84
|
-
return filePath.replace(staticGlob, "").replace(/\.(js|ts)$/, "").replace(/[^a-zA-Z0-9]/g, "_");
|
|
85
|
-
};
|
|
86
|
-
let replacement = `let ${importName} = {};
|
|
87
|
-
`;
|
|
88
|
-
for (const filePath of dirFiles) {
|
|
89
|
-
const { dir: fileDir, name: fileName } = import_node_path.default.parse(filePath);
|
|
90
|
-
const fileImportPath = fileDir + "/" + fileName;
|
|
91
|
-
const filePathVarName = filePathToVarName(filePath);
|
|
92
|
-
const namespaceImportName = `${importName}_${filePathVarName}`;
|
|
93
|
-
replacement += `import * as ${namespaceImportName} from '${fileImportPath}';
|
|
94
|
-
`;
|
|
95
|
-
replacement += `${importName}.${filePathVarName} = ${namespaceImportName};
|
|
96
|
-
`;
|
|
97
|
-
}
|
|
98
|
-
edits.push(importNode.replace(replacement.trim()));
|
|
99
|
-
} catch (error) {
|
|
100
|
-
console.warn(`Failed to process glob import: ${sourceValue}`, error);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
if (hasTransformations && edits.length > 0) {
|
|
104
|
-
const transformedCode = root.commitEdits(edits);
|
|
105
|
-
return {
|
|
106
|
-
code: transformedCode,
|
|
107
|
-
map: null
|
|
108
|
-
// For simplicity, not generating source maps
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
return null;
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
116
|
-
0 && (module.exports = {
|
|
117
|
-
cedarImportDirPlugin
|
|
118
|
-
});
|
package/dist/cjs/index.js
DELETED
|
@@ -1,22 +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 __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
-
for (let key of __getOwnPropNames(from))
|
|
9
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
-
var src_exports = {};
|
|
17
|
-
module.exports = __toCommonJS(src_exports);
|
|
18
|
-
__reExport(src_exports, require("./runPrerender.js"), module.exports);
|
|
19
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
20
|
-
0 && (module.exports = {
|
|
21
|
-
...require("./runPrerender.js")
|
|
22
|
-
});
|
package/dist/cjs/internal.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export declare const getRootHtmlPath: () => string;
|
|
2
|
-
export declare const registerShims: (routerPath: string) => void;
|
|
3
|
-
export declare const writeToDist: (outputHtmlPath: string, renderOutput: string) => void;
|
|
4
|
-
/**
|
|
5
|
-
* Finds, reads and parses the [ts|js]config.json file
|
|
6
|
-
* @returns The config object
|
|
7
|
-
*/
|
|
8
|
-
export declare const parseTypeScriptConfigFiles: () => {
|
|
9
|
-
api: any;
|
|
10
|
-
web: any;
|
|
11
|
-
};
|
|
12
|
-
type CompilerOptionsForPaths = {
|
|
13
|
-
compilerOptions: {
|
|
14
|
-
baseUrl: string;
|
|
15
|
-
paths: Record<string, string[]>;
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* Extracts and formats the paths from the [ts|js]config.json file
|
|
20
|
-
* @param config The config object
|
|
21
|
-
* @param rootDir {string} Where the jsconfig/tsconfig is loaded from
|
|
22
|
-
*/
|
|
23
|
-
export declare function getPathsFromTypeScriptConfig(config: CompilerOptionsForPaths, rootDir: string): {
|
|
24
|
-
find: string;
|
|
25
|
-
replacement: string;
|
|
26
|
-
}[];
|
|
27
|
-
export {};
|
|
28
|
-
//# sourceMappingURL=internal.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../src/internal.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,eAAe,cAM3B,CAAA;AAED,eAAO,MAAM,aAAa,GAAI,YAAY,MAAM,SAiC/C,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,gBAAgB,MAAM,EAAE,cAAc,MAAM,SAQvE,CAAA;AAGD;;;GAGG;AACH,eAAO,MAAM,0BAA0B;;;CA0BtC,CAAA;AAED,KAAK,uBAAuB,GAAG;IAC7B,eAAe,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;KAAE,CAAA;CACtE,CAAA;AAED;;;;GAIG;AACH,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,uBAAuB,EAC/B,OAAO,EAAE,MAAM;UAsBQ,MAAM;iBAAe,MAAM;IAkBnD"}
|