@cedarjs/internal 6.0.0-canary.2771 → 6.0.0-canary.2773
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/package.json +23 -80
- package/dist/cjs/ast.d.ts +0 -27
- package/dist/cjs/ast.d.ts.map +0 -1
- package/dist/cjs/ast.js +0 -223
- package/dist/cjs/build/api-graphql-transforms.d.ts +0 -34
- package/dist/cjs/build/api-graphql-transforms.d.ts.map +0 -1
- package/dist/cjs/build/api-graphql-transforms.js +0 -150
- package/dist/cjs/build/api.d.ts +0 -9
- package/dist/cjs/build/api.d.ts.map +0 -1
- package/dist/cjs/build/api.js +0 -407
- package/dist/cjs/build/auto-import.d.ts +0 -10
- package/dist/cjs/build/auto-import.d.ts.map +0 -1
- package/dist/cjs/build/auto-import.js +0 -144
- package/dist/cjs/build/directory-named-import.d.ts +0 -2
- package/dist/cjs/build/directory-named-import.d.ts.map +0 -1
- package/dist/cjs/build/directory-named-import.js +0 -60
- package/dist/cjs/build/esbuild-plugin-api-graphql.d.ts +0 -6
- package/dist/cjs/build/esbuild-plugin-api-graphql.d.ts.map +0 -1
- package/dist/cjs/build/esbuild-plugin-api-graphql.js +0 -107
- package/dist/cjs/build/esbuild-plugin-cedar-otel-wrapping.d.ts +0 -13
- package/dist/cjs/build/esbuild-plugin-cedar-otel-wrapping.d.ts.map +0 -1
- package/dist/cjs/build/esbuild-plugin-cedar-otel-wrapping.js +0 -214
- package/dist/cjs/build/esbuild-plugin-handler-als-wrapping.d.ts +0 -4
- package/dist/cjs/build/esbuild-plugin-handler-als-wrapping.d.ts.map +0 -1
- package/dist/cjs/build/esbuild-plugin-handler-als-wrapping.js +0 -59
- package/dist/cjs/build/esm-extensions.d.ts +0 -33
- package/dist/cjs/build/esm-extensions.d.ts.map +0 -1
- package/dist/cjs/build/esm-extensions.js +0 -71
- package/dist/cjs/build/import-dir.d.ts +0 -22
- package/dist/cjs/build/import-dir.d.ts.map +0 -1
- package/dist/cjs/build/import-dir.js +0 -88
- package/dist/cjs/build/job-path-injector.d.ts +0 -15
- package/dist/cjs/build/job-path-injector.d.ts.map +0 -1
- package/dist/cjs/build/job-path-injector.js +0 -103
- package/dist/cjs/build/src-alias.d.ts +0 -14
- package/dist/cjs/build/src-alias.d.ts.map +0 -1
- package/dist/cjs/build/src-alias.js +0 -51
- package/dist/cjs/build/tsconfig-paths.d.ts +0 -2
- package/dist/cjs/build/tsconfig-paths.d.ts.map +0 -1
- package/dist/cjs/build/tsconfig-paths.js +0 -106
- package/dist/cjs/cliLogger.d.ts +0 -11
- package/dist/cjs/cliLogger.d.ts.map +0 -1
- package/dist/cjs/cliLogger.js +0 -36
- package/dist/cjs/dev.d.ts +0 -2
- package/dist/cjs/dev.d.ts.map +0 -1
- package/dist/cjs/dev.js +0 -41
- package/dist/cjs/files.d.ts +0 -56
- package/dist/cjs/files.d.ts.map +0 -1
- package/dist/cjs/files.js +0 -230
- package/dist/cjs/generate/clientPreset.d.ts +0 -17
- package/dist/cjs/generate/clientPreset.d.ts.map +0 -1
- package/dist/cjs/generate/clientPreset.js +0 -101
- package/dist/cjs/generate/generate.d.ts +0 -10
- package/dist/cjs/generate/generate.d.ts.map +0 -1
- package/dist/cjs/generate/generate.js +0 -97
- package/dist/cjs/generate/gqlormSchema.d.ts +0 -113
- package/dist/cjs/generate/gqlormSchema.d.ts.map +0 -1
- package/dist/cjs/generate/gqlormSchema.js +0 -1061
- package/dist/cjs/generate/graphqlCodeGen.d.ts +0 -16
- package/dist/cjs/generate/graphqlCodeGen.d.ts.map +0 -1
- package/dist/cjs/generate/graphqlCodeGen.js +0 -380
- package/dist/cjs/generate/graphqlSchema.d.ts +0 -8
- package/dist/cjs/generate/graphqlSchema.d.ts.map +0 -1
- package/dist/cjs/generate/graphqlSchema.js +0 -157
- package/dist/cjs/generate/plugins/rw-typescript-resolvers/index.d.ts +0 -7
- package/dist/cjs/generate/plugins/rw-typescript-resolvers/index.d.ts.map +0 -1
- package/dist/cjs/generate/plugins/rw-typescript-resolvers/index.js +0 -65
- package/dist/cjs/generate/plugins/rw-typescript-resolvers/visitor.d.ts +0 -10
- package/dist/cjs/generate/plugins/rw-typescript-resolvers/visitor.d.ts.map +0 -1
- package/dist/cjs/generate/plugins/rw-typescript-resolvers/visitor.js +0 -92
- package/dist/cjs/generate/possibleTypes.d.ts +0 -36
- package/dist/cjs/generate/possibleTypes.d.ts.map +0 -1
- package/dist/cjs/generate/possibleTypes.js +0 -106
- package/dist/cjs/generate/templates/all-currentUser.d.ts.template +0 -30
- package/dist/cjs/generate/templates/all-gqlorm.d.ts.template +0 -7
- package/dist/cjs/generate/templates/api-globImports.d.ts.template +0 -9
- package/dist/cjs/generate/templates/api-globalContext.d.ts.template +0 -7
- package/dist/cjs/generate/templates/api-scenarios.d.ts.template +0 -10
- package/dist/cjs/generate/templates/api-test-globals.d.ts.template +0 -5
- package/dist/cjs/generate/templates/mirror-cell-fragment.d.ts.template +0 -18
- package/dist/cjs/generate/templates/mirror-cell.d.ts.template +0 -13
- package/dist/cjs/generate/templates/mirror-directoryNamedModule.d.ts.template +0 -5
- package/dist/cjs/generate/templates/web-routerRoutes.d.ts.template +0 -20
- package/dist/cjs/generate/templates/web-routesPages.d.ts.template +0 -13
- package/dist/cjs/generate/templates/web-test-globals.d.ts.template +0 -7
- package/dist/cjs/generate/templates.d.ts +0 -6
- package/dist/cjs/generate/templates.d.ts.map +0 -1
- package/dist/cjs/generate/templates.js +0 -68
- package/dist/cjs/generate/trustedDocuments.d.ts +0 -3
- package/dist/cjs/generate/trustedDocuments.d.ts.map +0 -1
- package/dist/cjs/generate/trustedDocuments.js +0 -95
- package/dist/cjs/generate/typeDefinitions.d.ts +0 -31
- package/dist/cjs/generate/typeDefinitions.d.ts.map +0 -1
- package/dist/cjs/generate/typeDefinitions.js +0 -381
- package/dist/cjs/generate/types.d.ts +0 -6
- package/dist/cjs/generate/types.d.ts.map +0 -1
- package/dist/cjs/generate/types.js +0 -16
- package/dist/cjs/generate/watch.d.ts +0 -3
- package/dist/cjs/generate/watch.d.ts.map +0 -1
- package/dist/cjs/generate/watch.js +0 -132
- package/dist/cjs/gql.d.ts +0 -34
- package/dist/cjs/gql.d.ts.map +0 -1
- package/dist/cjs/gql.js +0 -134
- package/dist/cjs/index.d.ts +0 -11
- package/dist/cjs/index.d.ts.map +0 -1
- package/dist/cjs/index.js +0 -49
- package/dist/cjs/jsx.d.ts +0 -16
- package/dist/cjs/jsx.d.ts.map +0 -1
- package/dist/cjs/jsx.js +0 -101
- package/dist/cjs/jsxAttributeValue.d.ts +0 -2
- package/dist/cjs/jsxAttributeValue.d.ts.map +0 -1
- package/dist/cjs/jsxAttributeValue.js +0 -129
- package/dist/cjs/package.json +0 -1
- package/dist/cjs/project.d.ts +0 -8
- package/dist/cjs/project.d.ts.map +0 -1
- package/dist/cjs/project.js +0 -82
- package/dist/cjs/routes.d.ts +0 -42
- package/dist/cjs/routes.d.ts.map +0 -1
- package/dist/cjs/routes.js +0 -111
- package/dist/cjs/ts2js.d.ts +0 -40
- package/dist/cjs/ts2js.d.ts.map +0 -1
- package/dist/cjs/ts2js.js +0 -159
- package/dist/cjs/validateSchema.d.ts +0 -14
- package/dist/cjs/validateSchema.d.ts.map +0 -1
- package/dist/cjs/validateSchema.js +0 -195
|
@@ -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 esbuild_plugin_api_graphql_exports = {};
|
|
30
|
-
__export(esbuild_plugin_api_graphql_exports, {
|
|
31
|
-
cedarApiGraphqlPlugin: () => cedarApiGraphqlPlugin
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(esbuild_plugin_api_graphql_exports);
|
|
34
|
-
var import_node_fs = __toESM(require("node:fs"), 1);
|
|
35
|
-
var import_node_path = __toESM(require("node:path"), 1);
|
|
36
|
-
var import_babel_config = require("@cedarjs/babel-config");
|
|
37
|
-
var import_project_config = require("@cedarjs/project-config");
|
|
38
|
-
var import_api_graphql_transforms = require("./api-graphql-transforms.js");
|
|
39
|
-
var import_auto_import = require("./auto-import.js");
|
|
40
|
-
var import_directory_named_import = require("./directory-named-import.js");
|
|
41
|
-
var import_esbuild_plugin_cedar_otel_wrapping = require("./esbuild-plugin-cedar-otel-wrapping.js");
|
|
42
|
-
var import_esbuild_plugin_handler_als_wrapping = require("./esbuild-plugin-handler-als-wrapping.js");
|
|
43
|
-
var import_esm_extensions = require("./esm-extensions.js");
|
|
44
|
-
var import_import_dir = require("./import-dir.js");
|
|
45
|
-
var import_src_alias = require("./src-alias.js");
|
|
46
|
-
var import_tsconfig_paths = require("./tsconfig-paths.js");
|
|
47
|
-
const cedarApiGraphqlPlugin = {
|
|
48
|
-
name: "cedar-api-graphql",
|
|
49
|
-
setup(build) {
|
|
50
|
-
build.onLoad({ filter: /[/\\]graphql\.(ts|js)$/ }, async (args) => {
|
|
51
|
-
const cedarConfig = (0, import_project_config.getConfig)();
|
|
52
|
-
let fileContents = await import_node_fs.default.promises.readFile(args.path, "utf-8");
|
|
53
|
-
fileContents = (0, import_src_alias.applySrcAlias)(
|
|
54
|
-
fileContents,
|
|
55
|
-
import_node_path.default.dirname(
|
|
56
|
-
import_node_path.default.relative(build.initialOptions.absWorkingDir + "/src", args.path)
|
|
57
|
-
)
|
|
58
|
-
);
|
|
59
|
-
fileContents = (0, import_tsconfig_paths.applyTsconfigPaths)(
|
|
60
|
-
fileContents,
|
|
61
|
-
args.path,
|
|
62
|
-
(0, import_project_config.getPaths)().api.base
|
|
63
|
-
);
|
|
64
|
-
fileContents = (0, import_directory_named_import.applyDirectoryNamedImport)(fileContents, args.path);
|
|
65
|
-
fileContents = (0, import_api_graphql_transforms.applyGraphqlOptionsExtract)(fileContents) ?? fileContents;
|
|
66
|
-
fileContents = (0, import_api_graphql_transforms.applyGqlormInject)(fileContents, args.path, ".js") ?? fileContents;
|
|
67
|
-
fileContents = (0, import_auto_import.applyAutoImports)(fileContents);
|
|
68
|
-
fileContents = (0, import_import_dir.applyImportDir)(fileContents, args.path)?.code ?? fileContents;
|
|
69
|
-
const apiBabelConfigPath = (0, import_babel_config.getApiSideBabelConfigPath)();
|
|
70
|
-
let code = fileContents;
|
|
71
|
-
if (apiBabelConfigPath) {
|
|
72
|
-
const transformedCode = await (0, import_babel_config.transformWithBabel)(
|
|
73
|
-
fileContents,
|
|
74
|
-
args.path,
|
|
75
|
-
(0, import_babel_config.getApiSideBabelPluginsForVite)(),
|
|
76
|
-
"inline",
|
|
77
|
-
true
|
|
78
|
-
);
|
|
79
|
-
if (!transformedCode?.code) {
|
|
80
|
-
throw new Error(`Could not transform file: ${args.path}`);
|
|
81
|
-
}
|
|
82
|
-
code = transformedCode.code;
|
|
83
|
-
}
|
|
84
|
-
if ((0, import_project_config.projectSideIsEsm)("api")) {
|
|
85
|
-
code = (0, import_esm_extensions.applyEsmExtensions)(code, args.path);
|
|
86
|
-
}
|
|
87
|
-
if (cedarConfig.experimental?.opentelemetry?.enabled && cedarConfig.experimental?.opentelemetry?.wrapApi) {
|
|
88
|
-
code = (0, import_esbuild_plugin_cedar_otel_wrapping.applyOtelWrapping)(code, args.path, (0, import_project_config.getPaths)().api.src) ?? code;
|
|
89
|
-
}
|
|
90
|
-
code = (0, import_esbuild_plugin_handler_als_wrapping.applyHandlerAlsWrapping)(code, {
|
|
91
|
-
projectIsEsm: (0, import_project_config.projectSideIsEsm)("api")
|
|
92
|
-
}) ?? code;
|
|
93
|
-
return {
|
|
94
|
-
contents: code,
|
|
95
|
-
// Babel output is always plain JS. Without Babel the contents are
|
|
96
|
-
// still TypeScript when the source file is graphql.ts, so pick the
|
|
97
|
-
// matching loader and let esbuild do the stripping. (The onLoad
|
|
98
|
-
// filter only matches .ts and .js files.)
|
|
99
|
-
loader: !apiBabelConfigPath && args.path.endsWith(".ts") ? "ts" : "js"
|
|
100
|
-
};
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
105
|
-
0 && (module.exports = {
|
|
106
|
-
cedarApiGraphqlPlugin
|
|
107
|
-
});
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Standalone esbuild equivalent of the Vite cedarOtelWrappingPlugin. Applied
|
|
3
|
-
* inline in the esbuild API build and the standalone-Vite API build so neither
|
|
4
|
-
* path depends on a Babel OTel plugin.
|
|
5
|
-
*
|
|
6
|
-
* For each `export const fn = (async?) (...) => {...}` in an API file, this
|
|
7
|
-
* wraps it with an OpenTelemetry span.
|
|
8
|
-
*
|
|
9
|
-
* Keep this in sync with
|
|
10
|
-
* packages/vite/src/plugins/vite-plugin-cedar-otel-wrapping.ts.
|
|
11
|
-
*/
|
|
12
|
-
export declare function applyOtelWrapping(code: string, filename: string, apiSrc: string): string | null;
|
|
13
|
-
//# sourceMappingURL=esbuild-plugin-cedar-otel-wrapping.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"esbuild-plugin-cedar-otel-wrapping.d.ts","sourceRoot":"","sources":["../../../src/build/esbuild-plugin-cedar-otel-wrapping.ts"],"names":[],"mappings":"AASA;;;;;;;;;;GAUG;AAEH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,GACb,MAAM,GAAG,IAAI,CAmFf"}
|
|
@@ -1,214 +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 esbuild_plugin_cedar_otel_wrapping_exports = {};
|
|
30
|
-
__export(esbuild_plugin_cedar_otel_wrapping_exports, {
|
|
31
|
-
applyOtelWrapping: () => applyOtelWrapping
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(esbuild_plugin_cedar_otel_wrapping_exports);
|
|
34
|
-
var import_node_path = __toESM(require("node:path"), 1);
|
|
35
|
-
var import_oxc_parser = require("oxc-parser");
|
|
36
|
-
function applyOtelWrapping(code, filename, apiSrc) {
|
|
37
|
-
const relative = import_node_path.default.relative(apiSrc, filename);
|
|
38
|
-
const apiFolder = relative.split(import_node_path.default.sep)[0] ?? "?";
|
|
39
|
-
const parseResult = (0, import_oxc_parser.parseSync)(filename, code, { sourceType: "module" });
|
|
40
|
-
const replacements = [];
|
|
41
|
-
for (const node of parseResult.program.body) {
|
|
42
|
-
if (node.type !== "ExportNamedDeclaration") {
|
|
43
|
-
continue;
|
|
44
|
-
}
|
|
45
|
-
const decl = node.declaration;
|
|
46
|
-
if (decl?.type !== "VariableDeclaration") {
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
const declarator = decl.declarations[0];
|
|
50
|
-
if (!declarator) {
|
|
51
|
-
continue;
|
|
52
|
-
}
|
|
53
|
-
const fn = declarator.init;
|
|
54
|
-
if (fn?.type !== "ArrowFunctionExpression") {
|
|
55
|
-
continue;
|
|
56
|
-
}
|
|
57
|
-
if (declarator.id.type !== "Identifier") {
|
|
58
|
-
continue;
|
|
59
|
-
}
|
|
60
|
-
const fnName = declarator.id.name;
|
|
61
|
-
const innerArgs = buildInnerArgs(fn.params);
|
|
62
|
-
if (innerArgs === null) {
|
|
63
|
-
continue;
|
|
64
|
-
}
|
|
65
|
-
const fnHeader = code.slice(fn.start, fn.body.start);
|
|
66
|
-
const originalFnSrc = code.slice(fn.start, fn.end);
|
|
67
|
-
const isAsync = fn.async;
|
|
68
|
-
const awaitKw = isAsync ? "await " : "";
|
|
69
|
-
const asyncKw = isAsync ? "async " : "";
|
|
70
|
-
replacements.push({
|
|
71
|
-
start: node.start,
|
|
72
|
-
end: node.end,
|
|
73
|
-
src: buildWrappedExport(
|
|
74
|
-
fnName,
|
|
75
|
-
fnHeader,
|
|
76
|
-
originalFnSrc,
|
|
77
|
-
innerArgs,
|
|
78
|
-
awaitKw,
|
|
79
|
-
asyncKw,
|
|
80
|
-
apiFolder,
|
|
81
|
-
filename
|
|
82
|
-
)
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
if (replacements.length === 0) {
|
|
86
|
-
return null;
|
|
87
|
-
}
|
|
88
|
-
let output = code;
|
|
89
|
-
for (let i = replacements.length - 1; i >= 0; i--) {
|
|
90
|
-
const r = replacements[i];
|
|
91
|
-
output = output.slice(0, r.start) + r.src + output.slice(r.end);
|
|
92
|
-
}
|
|
93
|
-
return `import { trace as OTEL_TRACE } from '@opentelemetry/api'
|
|
94
|
-
` + output;
|
|
95
|
-
}
|
|
96
|
-
function buildInnerArgs(params) {
|
|
97
|
-
const args = [];
|
|
98
|
-
for (const param of params) {
|
|
99
|
-
if (param.type === "RestElement" || param.type === "ArrayPattern" || param.type === "TSParameterProperty") {
|
|
100
|
-
return null;
|
|
101
|
-
}
|
|
102
|
-
if (param.type === "Identifier") {
|
|
103
|
-
args.push(param.name);
|
|
104
|
-
continue;
|
|
105
|
-
}
|
|
106
|
-
if (param.type === "ObjectPattern") {
|
|
107
|
-
for (const prop of param.properties) {
|
|
108
|
-
if (prop.type === "RestElement") {
|
|
109
|
-
return null;
|
|
110
|
-
}
|
|
111
|
-
if (prop.key.type !== "Identifier") {
|
|
112
|
-
return null;
|
|
113
|
-
}
|
|
114
|
-
const value = prop.value;
|
|
115
|
-
if (value.type !== "Identifier" && value.type !== "AssignmentPattern" && value.type !== "ObjectPattern") {
|
|
116
|
-
return null;
|
|
117
|
-
}
|
|
118
|
-
if (value.type === "AssignmentPattern") {
|
|
119
|
-
if (value.left.type !== "Identifier" && value.left.type !== "ObjectPattern") {
|
|
120
|
-
return null;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
const obj = buildObjectCallArg(param);
|
|
125
|
-
if (obj === null) {
|
|
126
|
-
return null;
|
|
127
|
-
}
|
|
128
|
-
args.push(obj);
|
|
129
|
-
continue;
|
|
130
|
-
}
|
|
131
|
-
if (param.type === "AssignmentPattern") {
|
|
132
|
-
const ap = param;
|
|
133
|
-
if (ap.left.type === "Identifier") {
|
|
134
|
-
args.push(ap.left.name);
|
|
135
|
-
} else if (ap.left.type === "ObjectPattern") {
|
|
136
|
-
const obj = buildObjectCallArg(ap.left);
|
|
137
|
-
if (obj === null) {
|
|
138
|
-
return null;
|
|
139
|
-
}
|
|
140
|
-
args.push(obj);
|
|
141
|
-
} else {
|
|
142
|
-
return null;
|
|
143
|
-
}
|
|
144
|
-
continue;
|
|
145
|
-
}
|
|
146
|
-
return null;
|
|
147
|
-
}
|
|
148
|
-
return args.join(", ");
|
|
149
|
-
}
|
|
150
|
-
function buildObjectCallArg(pattern) {
|
|
151
|
-
const keys = [];
|
|
152
|
-
for (const prop of pattern.properties) {
|
|
153
|
-
if (prop.type === "RestElement") {
|
|
154
|
-
return null;
|
|
155
|
-
}
|
|
156
|
-
if (prop.key.type !== "Identifier") {
|
|
157
|
-
return null;
|
|
158
|
-
}
|
|
159
|
-
const keyName = prop.key.name;
|
|
160
|
-
let valueName = null;
|
|
161
|
-
if (prop.value.type === "Identifier") {
|
|
162
|
-
valueName = prop.value.name;
|
|
163
|
-
} else if (prop.value.type === "AssignmentPattern") {
|
|
164
|
-
if (prop.value.left.type === "Identifier") {
|
|
165
|
-
valueName = prop.value.left.name;
|
|
166
|
-
} else {
|
|
167
|
-
return null;
|
|
168
|
-
}
|
|
169
|
-
} else {
|
|
170
|
-
return null;
|
|
171
|
-
}
|
|
172
|
-
if (valueName !== keyName) {
|
|
173
|
-
keys.push(`${keyName}: ${valueName}`);
|
|
174
|
-
} else {
|
|
175
|
-
keys.push(keyName);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
return `{ ${keys.join(", ")} }`;
|
|
179
|
-
}
|
|
180
|
-
function buildWrappedExport(fnName, fnHeader, originalFnSrc, innerArgs, awaitKw, asyncKw, apiFolder, filename) {
|
|
181
|
-
const privateName = `__${fnName}`;
|
|
182
|
-
const spanName = `redwoodjs:api:${apiFolder}:${fnName}`;
|
|
183
|
-
return `export const ${fnName} = ${fnHeader}{
|
|
184
|
-
const ${privateName} = ${originalFnSrc}
|
|
185
|
-
const OTEL_TRACER = OTEL_TRACE.getTracer('redwoodjs')
|
|
186
|
-
const OTEL_RESULT = ${awaitKw}OTEL_TRACER.startActiveSpan(
|
|
187
|
-
'${spanName}',
|
|
188
|
-
${asyncKw}(span) => {
|
|
189
|
-
span.setAttribute('code.function', '${fnName}')
|
|
190
|
-
span.setAttribute('code.filepath', ${JSON.stringify(filename)})
|
|
191
|
-
try {
|
|
192
|
-
const OTEL_INNER_RESULT = ${awaitKw}${privateName}(${innerArgs})
|
|
193
|
-
span.end()
|
|
194
|
-
return OTEL_INNER_RESULT
|
|
195
|
-
} catch (error) {
|
|
196
|
-
span.recordException(error)
|
|
197
|
-
span.setStatus({
|
|
198
|
-
code: 2,
|
|
199
|
-
message:
|
|
200
|
-
error?.message?.split('\\n')[0] ??
|
|
201
|
-
error?.toString()?.split('\\n')[0],
|
|
202
|
-
})
|
|
203
|
-
span.end()
|
|
204
|
-
throw error
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
)
|
|
208
|
-
return OTEL_RESULT
|
|
209
|
-
}`;
|
|
210
|
-
}
|
|
211
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
212
|
-
0 && (module.exports = {
|
|
213
|
-
applyOtelWrapping
|
|
214
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"esbuild-plugin-handler-als-wrapping.d.ts","sourceRoot":"","sources":["../../../src/build/esbuild-plugin-handler-als-wrapping.ts"],"names":[],"mappings":"AAOA,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,MAAM,EACZ,EAAE,YAAoB,EAAE,GAAE;IAAE,YAAY,CAAC,EAAE,OAAO,CAAA;CAAO,GACxD,MAAM,GAAG,IAAI,CA0Cf"}
|
|
@@ -1,59 +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 esbuild_plugin_handler_als_wrapping_exports = {};
|
|
20
|
-
__export(esbuild_plugin_handler_als_wrapping_exports, {
|
|
21
|
-
applyHandlerAlsWrapping: () => applyHandlerAlsWrapping
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(esbuild_plugin_handler_als_wrapping_exports);
|
|
24
|
-
function applyHandlerAlsWrapping(code, { projectIsEsm = false } = {}) {
|
|
25
|
-
const handlerRe = /^export\s+(?:const|let|var)\s+handler(?:[^=]|=>)*?=(?![>=])/m;
|
|
26
|
-
const handlerMatch = handlerRe.exec(code);
|
|
27
|
-
if (!handlerMatch) {
|
|
28
|
-
return null;
|
|
29
|
-
}
|
|
30
|
-
const afterEquals = code.slice(handlerMatch.index + handlerMatch[0].length).trimStart();
|
|
31
|
-
const isAsync = /^async(?:\s*[\(\*]|\s+function)/.test(afterEquals);
|
|
32
|
-
const storePath = projectIsEsm ? "@cedarjs/context/dist/store.js" : "@cedarjs/context/dist/store";
|
|
33
|
-
const importStatement = `import { getAsyncStoreInstance as __cedar_getAsyncStoreInstance } from '${storePath}'
|
|
34
|
-
`;
|
|
35
|
-
const handlerStart = handlerMatch.index;
|
|
36
|
-
const before = code.slice(0, handlerStart);
|
|
37
|
-
const after = code.slice(handlerStart);
|
|
38
|
-
const renamed = after.replace(handlerRe, "const __cedar_handler =");
|
|
39
|
-
const wrappedHandler = `
|
|
40
|
-
export const handler = ${isAsync ? "async " : ""}(__cedar_event, __cedar_context) => {
|
|
41
|
-
// The store will be undefined if no context isolation has been performed yet
|
|
42
|
-
const __cedar_contextStore = __cedar_getAsyncStoreInstance().getStore()
|
|
43
|
-
if (__cedar_contextStore === undefined) {
|
|
44
|
-
return __cedar_getAsyncStoreInstance().run(
|
|
45
|
-
new Map(),
|
|
46
|
-
__cedar_handler,
|
|
47
|
-
__cedar_event,
|
|
48
|
-
__cedar_context
|
|
49
|
-
)
|
|
50
|
-
}
|
|
51
|
-
return __cedar_handler(__cedar_event, __cedar_context)
|
|
52
|
-
}
|
|
53
|
-
`;
|
|
54
|
-
return before + importStatement + renamed + wrappedHandler;
|
|
55
|
-
}
|
|
56
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
57
|
-
0 && (module.exports = {
|
|
58
|
-
applyHandlerAlsWrapping
|
|
59
|
-
});
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* For ESM projects using esbuild with `bundle: false`, rewrites extensionless
|
|
3
|
-
* relative imports to include `.js` extension so that Node's ESM resolver can
|
|
4
|
-
* locate the compiled output files at runtime.
|
|
5
|
-
*
|
|
6
|
-
* Handles both static imports (`from '../lib/db'`) and dynamic imports
|
|
7
|
-
* (`import('../lib/db')`).
|
|
8
|
-
*
|
|
9
|
-
* Always outputs `.js` because esbuild with `loader: 'js'` compiles all source
|
|
10
|
-
* files (`.ts`, `.tsx`, `.jsx`) to `.js` output. For a source file `api/src/lib/db.ts`
|
|
11
|
-
* or `api/src/lib/db.tsx`, the output is always `api/dist/lib/db.js`, so all
|
|
12
|
-
* import specifiers must use `.js` at runtime.
|
|
13
|
-
*
|
|
14
|
-
* This replaces the `resolvePath` hook in `babel-plugin-module-resolver` for
|
|
15
|
-
* the standalone esbuild build path (`runCedarBabelTransformsPlugin`), which
|
|
16
|
-
* was previously responsible for this extension-appending behaviour. Vite
|
|
17
|
-
* and Rollup resolve extensions themselves during bundling; only the esbuild
|
|
18
|
-
* `bundle: false` path needs explicit extension suffixes in the source.
|
|
19
|
-
*
|
|
20
|
-
* It is a plain function called inline — not an esbuild plugin — following
|
|
21
|
-
* the same pattern as `applySrcAlias`, `applyTsconfigPaths`, etc.
|
|
22
|
-
*
|
|
23
|
-
* Also handles Cedar SDL files whose names include a compound extension:
|
|
24
|
-
* `contacts.sdl.ts` compiles to `contacts.sdl.js`, so an import specifier
|
|
25
|
-
* `../graphql/contacts.sdl` (generated by applyImportDir's glob expansion)
|
|
26
|
-
* is rewritten to `../graphql/contacts.sdl.js`.
|
|
27
|
-
*
|
|
28
|
-
* Example: in `api/src/functions/graphql.ts` importing `../lib/db`, this
|
|
29
|
-
* rewrites it to `../lib/db.js` when `api/src/lib/db.ts` (or `db.tsx`)
|
|
30
|
-
* exists on disk.
|
|
31
|
-
*/
|
|
32
|
-
export declare function applyEsmExtensions(code: string, fromFile: string): string;
|
|
33
|
-
//# sourceMappingURL=esm-extensions.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"esm-extensions.d.ts","sourceRoot":"","sources":["../../../src/build/esm-extensions.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAiEzE"}
|
|
@@ -1,71 +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 esm_extensions_exports = {};
|
|
30
|
-
__export(esm_extensions_exports, {
|
|
31
|
-
applyEsmExtensions: () => applyEsmExtensions
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(esm_extensions_exports);
|
|
34
|
-
var import_node_fs = __toESM(require("node:fs"), 1);
|
|
35
|
-
var import_node_path = __toESM(require("node:path"), 1);
|
|
36
|
-
function applyEsmExtensions(code, fromFile) {
|
|
37
|
-
const fromDir = import_node_path.default.dirname(fromFile);
|
|
38
|
-
const rewriteImportPath = (importPath, preservePrefix, preserveSuffix) => {
|
|
39
|
-
const existingExt = import_node_path.default.extname(importPath);
|
|
40
|
-
const absImport = import_node_path.default.join(fromDir, importPath);
|
|
41
|
-
if (existingExt && existingExt !== ".js" && existingExt !== ".jsx") {
|
|
42
|
-
if (import_node_fs.default.existsSync(absImport + ".ts") || import_node_fs.default.existsSync(absImport + ".js") || import_node_fs.default.existsSync(absImport + ".tsx") || import_node_fs.default.existsSync(absImport + ".jsx")) {
|
|
43
|
-
return preservePrefix + importPath + ".js" + preserveSuffix;
|
|
44
|
-
}
|
|
45
|
-
return preservePrefix + importPath + preserveSuffix;
|
|
46
|
-
}
|
|
47
|
-
const base = existingExt ? importPath.slice(0, -existingExt.length) : importPath;
|
|
48
|
-
const absBase = import_node_path.default.join(fromDir, base);
|
|
49
|
-
if (import_node_fs.default.existsSync(absBase + ".ts") || import_node_fs.default.existsSync(absBase + ".js") || import_node_fs.default.existsSync(absBase + ".tsx") || import_node_fs.default.existsSync(absBase + ".jsx")) {
|
|
50
|
-
return preservePrefix + base + ".js" + preserveSuffix;
|
|
51
|
-
}
|
|
52
|
-
return preservePrefix + importPath + preserveSuffix;
|
|
53
|
-
};
|
|
54
|
-
let result = code.replace(
|
|
55
|
-
/\bfrom\s+(['"])(\.\.?\/[^'"]+)\1/g,
|
|
56
|
-
(match, quote, importPath) => {
|
|
57
|
-
return `from ${rewriteImportPath(importPath, quote, quote)}`;
|
|
58
|
-
}
|
|
59
|
-
);
|
|
60
|
-
result = result.replace(
|
|
61
|
-
/\bimport\s*\(\s*(['"])(\.\.?\/[^'"]+)\1\s*\)/g,
|
|
62
|
-
(match, quote, importPath) => {
|
|
63
|
-
return `import(${rewriteImportPath(importPath, quote, quote)})`;
|
|
64
|
-
}
|
|
65
|
-
);
|
|
66
|
-
return result;
|
|
67
|
-
}
|
|
68
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
69
|
-
0 && (module.exports = {
|
|
70
|
-
applyEsmExtensions
|
|
71
|
-
});
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { SourceMap } from 'magic-string';
|
|
2
|
-
/**
|
|
3
|
-
* Expands glob directory imports such as:
|
|
4
|
-
* import services from 'src/services/**\/*.{js,ts}'
|
|
5
|
-
* into individual namespace imports:
|
|
6
|
-
* let services = {}
|
|
7
|
-
* import * as services_a from 'src/services/a'
|
|
8
|
-
* services.a = services_a
|
|
9
|
-
*
|
|
10
|
-
* This is the esbuild-path equivalent of:
|
|
11
|
-
* - babel-plugin-redwood-import-dir (kept for Jest / console / data-migrate)
|
|
12
|
-
* - cedarImportDirPlugin (Vite plugin, for Vite build paths)
|
|
13
|
-
*
|
|
14
|
-
* Code duplication between the two non-Babel plugins is intentional.
|
|
15
|
-
*
|
|
16
|
-
* Returns the transformed source code, or null if no glob imports were found.
|
|
17
|
-
*/
|
|
18
|
-
export declare function applyImportDir(code: string, filePath: string): {
|
|
19
|
-
code: string;
|
|
20
|
-
map?: SourceMap;
|
|
21
|
-
} | null;
|
|
22
|
-
//# sourceMappingURL=import-dir.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"import-dir.d.ts","sourceRoot":"","sources":["../../../src/build/import-dir.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAI7C;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,GACf;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,SAAS,CAAA;CAAE,GAAG,IAAI,CAyE1C"}
|
|
@@ -1,88 +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 import_dir_exports = {};
|
|
30
|
-
__export(import_dir_exports, {
|
|
31
|
-
applyImportDir: () => applyImportDir
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(import_dir_exports);
|
|
34
|
-
var import_node_fs = __toESM(require("node:fs"), 1);
|
|
35
|
-
var import_node_path = __toESM(require("node:path"), 1);
|
|
36
|
-
var import_magic_string = __toESM(require("magic-string"), 1);
|
|
37
|
-
var import_project_config = require("@cedarjs/project-config");
|
|
38
|
-
function applyImportDir(code, filePath) {
|
|
39
|
-
if (!code.includes("**")) {
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
const GLOB_IMPORT_RE = /^import\s+(\w+)\s+from\s+['"]([^'"]+)['"]\s*;?/gm;
|
|
43
|
-
const s = new import_magic_string.default(code);
|
|
44
|
-
let hasTransformations = false;
|
|
45
|
-
for (const match of code.matchAll(GLOB_IMPORT_RE)) {
|
|
46
|
-
const importName = match[1];
|
|
47
|
-
const sourceValue = match[2];
|
|
48
|
-
if (!sourceValue.includes("**")) {
|
|
49
|
-
continue;
|
|
50
|
-
}
|
|
51
|
-
const importGlob = (0, import_project_config.importStatementPath)(sourceValue);
|
|
52
|
-
const cwd = importGlob.startsWith("src/") ? (0, import_project_config.getPaths)().api.base : import_node_path.default.dirname(filePath);
|
|
53
|
-
let dirFiles;
|
|
54
|
-
try {
|
|
55
|
-
dirFiles = import_node_fs.default.globSync(importGlob, {
|
|
56
|
-
cwd,
|
|
57
|
-
exclude: (n) => n.includes(".test.") || n.includes(".scenarios.") || n.includes(".d.ts")
|
|
58
|
-
});
|
|
59
|
-
} catch {
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
62
|
-
const staticGlob = importGlob.split("*")[0];
|
|
63
|
-
const filePathToVarName = (fp) => fp.replace(staticGlob, "").replace(/\.(js|ts)$/, "").replace(/[^a-zA-Z0-9]/g, "_");
|
|
64
|
-
hasTransformations = true;
|
|
65
|
-
let replacement = `let ${importName} = {};
|
|
66
|
-
`;
|
|
67
|
-
for (const fp of dirFiles) {
|
|
68
|
-
const { dir: fileDir, name: fileName } = import_node_path.default.parse(fp);
|
|
69
|
-
const normalizedDir = (0, import_project_config.importStatementPath)(fileDir);
|
|
70
|
-
const varName = filePathToVarName(fp);
|
|
71
|
-
const nsImport = `${importName}_${varName}`;
|
|
72
|
-
replacement += `import * as ${nsImport} from '${normalizedDir}/${fileName}';
|
|
73
|
-
`;
|
|
74
|
-
replacement += `${importName}.${varName} = ${nsImport};
|
|
75
|
-
`;
|
|
76
|
-
}
|
|
77
|
-
s.overwrite(
|
|
78
|
-
match.index,
|
|
79
|
-
match.index + match[0].length,
|
|
80
|
-
replacement.trimEnd()
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
|
-
return hasTransformations ? { code: s.toString(), map: s.generateMap({ hires: true }) } : null;
|
|
84
|
-
}
|
|
85
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
86
|
-
0 && (module.exports = {
|
|
87
|
-
applyImportDir
|
|
88
|
-
});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Injects `path` and `name` properties into `createJob()` definitions so the
|
|
3
|
-
* jobs runner can locate and identify the job's module at runtime.
|
|
4
|
-
*
|
|
5
|
-
* Standalone equivalent of the Vite cedarjsJobPathInjectorPlugin (used by
|
|
6
|
-
* buildApp and apiDevMiddleware) and the Babel pluginRedwoodJobPathInjector
|
|
7
|
-
* override they replaced. Applied inline in the esbuild API build and the
|
|
8
|
-
* standalone-Vite API build so neither path depends on Babel for job path
|
|
9
|
-
* injection.
|
|
10
|
-
*
|
|
11
|
-
* Keep this in sync with
|
|
12
|
-
* packages/vite/src/plugins/vite-plugin-cedarjs-job-path-injector.ts.
|
|
13
|
-
*/
|
|
14
|
-
export declare function applyJobPathInjector(code: string, filePath: string, jobsDir: string): string | null;
|
|
15
|
-
//# sourceMappingURL=job-path-injector.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"job-path-injector.d.ts","sourceRoot":"","sources":["../../../src/build/job-path-injector.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GACd,MAAM,GAAG,IAAI,CA8Ff"}
|