@cedarjs/internal 5.0.6 → 5.0.7-next.186
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/ast.d.ts +1 -0
- package/dist/ast.d.ts.map +1 -1
- package/dist/ast.js +21 -0
- package/dist/build/api-graphql-transforms.d.ts +34 -0
- package/dist/build/api-graphql-transforms.d.ts.map +1 -0
- package/dist/build/api-graphql-transforms.js +119 -0
- package/dist/build/api.d.ts +2 -0
- package/dist/build/api.d.ts.map +1 -1
- package/dist/build/api.js +202 -39
- package/dist/build/auto-import.d.ts +10 -0
- package/dist/build/auto-import.d.ts.map +1 -0
- package/dist/build/auto-import.js +120 -0
- package/dist/build/directory-named-import.d.ts +2 -0
- package/dist/build/directory-named-import.d.ts.map +1 -0
- package/dist/build/directory-named-import.js +26 -0
- package/dist/build/esbuild-plugin-api-graphql.d.ts +6 -0
- package/dist/build/esbuild-plugin-api-graphql.d.ts.map +1 -0
- package/dist/build/esbuild-plugin-api-graphql.js +80 -0
- package/dist/build/esbuild-plugin-cedar-otel-wrapping.d.ts +13 -0
- package/dist/build/esbuild-plugin-cedar-otel-wrapping.d.ts.map +1 -0
- package/dist/build/esbuild-plugin-cedar-otel-wrapping.js +180 -0
- package/dist/build/esbuild-plugin-handler-als-wrapping.d.ts +4 -0
- package/dist/build/esbuild-plugin-handler-als-wrapping.d.ts.map +1 -0
- package/dist/build/{esbuild-plugin-cedar-context-wrapping.js → esbuild-plugin-handler-als-wrapping.js} +12 -12
- package/dist/build/esm-extensions.d.ts +33 -0
- package/dist/build/esm-extensions.d.ts.map +1 -0
- package/dist/build/esm-extensions.js +37 -0
- package/dist/build/import-dir.d.ts +22 -0
- package/dist/build/import-dir.d.ts.map +1 -0
- package/dist/build/import-dir.js +54 -0
- package/dist/build/job-path-injector.d.ts +15 -0
- package/dist/build/job-path-injector.d.ts.map +1 -0
- package/dist/build/job-path-injector.js +69 -0
- package/dist/build/src-alias.d.ts +14 -0
- package/dist/build/src-alias.d.ts.map +1 -0
- package/dist/build/src-alias.js +17 -0
- package/dist/build/tsconfig-paths.d.ts +2 -0
- package/dist/build/tsconfig-paths.d.ts.map +1 -0
- package/dist/build/tsconfig-paths.js +72 -0
- package/dist/generate/clientPreset.d.ts.map +1 -1
- package/dist/generate/clientPreset.js +10 -3
- package/dist/generate/graphqlSchema.d.ts.map +1 -1
- package/dist/generate/templates/mirror-cell-fragment.d.ts.template +18 -0
- package/dist/generate/templates.d.ts.map +1 -1
- package/dist/generate/templates.js +1 -6
- package/dist/generate/typeDefinitions.d.ts.map +1 -1
- package/dist/generate/typeDefinitions.js +15 -1
- package/dist/gql.d.ts +20 -0
- package/dist/gql.d.ts.map +1 -1
- package/dist/gql.js +24 -0
- package/dist/jsx.d.ts.map +1 -1
- package/dist/routes.d.ts.map +1 -1
- package/package.json +48 -80
- package/dist/build/esbuild-plugin-cedar-context-wrapping.d.ts +0 -4
- package/dist/build/esbuild-plugin-cedar-context-wrapping.d.ts.map +0 -1
- package/dist/cjs/ast.d.ts +0 -26
- package/dist/cjs/ast.d.ts.map +0 -1
- package/dist/cjs/ast.js +0 -201
- package/dist/cjs/build/api.d.ts +0 -7
- package/dist/cjs/build/api.d.ts.map +0 -1
- package/dist/cjs/build/api.js +0 -251
- package/dist/cjs/build/esbuild-plugin-cedar-context-wrapping.d.ts +0 -4
- package/dist/cjs/build/esbuild-plugin-cedar-context-wrapping.d.ts.map +0 -1
- package/dist/cjs/build/esbuild-plugin-cedar-context-wrapping.js +0 -59
- 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 -84
- 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.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 -372
- 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 -14
- package/dist/cjs/gql.d.ts.map +0 -1
- package/dist/cjs/gql.js +0 -108
- 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
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { importStatementPath, resolveFile } from "@cedarjs/project-config";
|
|
3
|
+
const RELATIVE_IMPORT_RE = /^(\s*(?:import|export)\s[^'"]*?)(['"])(\.\.?\/[^'"]+)\2/gm;
|
|
4
|
+
function applyDirectoryNamedImport(code, filePath) {
|
|
5
|
+
const fileDir = path.dirname(filePath);
|
|
6
|
+
return code.replace(
|
|
7
|
+
RELATIVE_IMPORT_RE,
|
|
8
|
+
(match, prefix, quote, importPath) => {
|
|
9
|
+
const absolutePath = path.join(fileDir, importPath);
|
|
10
|
+
if (resolveFile(absolutePath)) {
|
|
11
|
+
return match;
|
|
12
|
+
}
|
|
13
|
+
if (resolveFile(path.join(absolutePath, "index"))) {
|
|
14
|
+
return `${prefix}${quote}${importStatementPath(importPath + "/index")}${quote}`;
|
|
15
|
+
}
|
|
16
|
+
const basename = path.basename(absolutePath);
|
|
17
|
+
if (resolveFile(path.join(absolutePath, basename))) {
|
|
18
|
+
return `${prefix}${quote}${importStatementPath(importPath + "/" + basename)}${quote}`;
|
|
19
|
+
}
|
|
20
|
+
return match;
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
applyDirectoryNamedImport
|
|
26
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"esbuild-plugin-api-graphql.d.ts","sourceRoot":"","sources":["../../src/build/esbuild-plugin-api-graphql.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAsB1C,eAAO,MAAM,qBAAqB;;iBAEnB,WAAW;CAiHzB,CAAA"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import {
|
|
4
|
+
getApiSideBabelConfigPath,
|
|
5
|
+
getApiSideBabelPluginsForVite,
|
|
6
|
+
transformWithBabel
|
|
7
|
+
} from "@cedarjs/babel-config";
|
|
8
|
+
import { getConfig, getPaths, projectSideIsEsm } from "@cedarjs/project-config";
|
|
9
|
+
import {
|
|
10
|
+
applyGqlormInject,
|
|
11
|
+
applyGraphqlOptionsExtract
|
|
12
|
+
} from "./api-graphql-transforms.js";
|
|
13
|
+
import { applyAutoImports } from "./auto-import.js";
|
|
14
|
+
import { applyDirectoryNamedImport } from "./directory-named-import.js";
|
|
15
|
+
import { applyOtelWrapping } from "./esbuild-plugin-cedar-otel-wrapping.js";
|
|
16
|
+
import { applyHandlerAlsWrapping } from "./esbuild-plugin-handler-als-wrapping.js";
|
|
17
|
+
import { applyEsmExtensions } from "./esm-extensions.js";
|
|
18
|
+
import { applyImportDir } from "./import-dir.js";
|
|
19
|
+
import { applySrcAlias } from "./src-alias.js";
|
|
20
|
+
import { applyTsconfigPaths } from "./tsconfig-paths.js";
|
|
21
|
+
const cedarApiGraphqlPlugin = {
|
|
22
|
+
name: "cedar-api-graphql",
|
|
23
|
+
setup(build) {
|
|
24
|
+
build.onLoad({ filter: /[/\\]graphql\.(ts|js)$/ }, async (args) => {
|
|
25
|
+
const cedarConfig = getConfig();
|
|
26
|
+
let fileContents = await fs.promises.readFile(args.path, "utf-8");
|
|
27
|
+
fileContents = applySrcAlias(
|
|
28
|
+
fileContents,
|
|
29
|
+
path.dirname(
|
|
30
|
+
path.relative(build.initialOptions.absWorkingDir + "/src", args.path)
|
|
31
|
+
)
|
|
32
|
+
);
|
|
33
|
+
fileContents = applyTsconfigPaths(
|
|
34
|
+
fileContents,
|
|
35
|
+
args.path,
|
|
36
|
+
getPaths().api.base
|
|
37
|
+
);
|
|
38
|
+
fileContents = applyDirectoryNamedImport(fileContents, args.path);
|
|
39
|
+
fileContents = applyGraphqlOptionsExtract(fileContents) ?? fileContents;
|
|
40
|
+
fileContents = applyGqlormInject(fileContents, args.path, ".js") ?? fileContents;
|
|
41
|
+
fileContents = applyAutoImports(fileContents);
|
|
42
|
+
fileContents = applyImportDir(fileContents, args.path)?.code ?? fileContents;
|
|
43
|
+
const apiBabelConfigPath = getApiSideBabelConfigPath();
|
|
44
|
+
let code = fileContents;
|
|
45
|
+
if (apiBabelConfigPath) {
|
|
46
|
+
const transformedCode = await transformWithBabel(
|
|
47
|
+
fileContents,
|
|
48
|
+
args.path,
|
|
49
|
+
getApiSideBabelPluginsForVite(),
|
|
50
|
+
"inline",
|
|
51
|
+
true
|
|
52
|
+
);
|
|
53
|
+
if (!transformedCode?.code) {
|
|
54
|
+
throw new Error(`Could not transform file: ${args.path}`);
|
|
55
|
+
}
|
|
56
|
+
code = transformedCode.code;
|
|
57
|
+
}
|
|
58
|
+
if (projectSideIsEsm("api")) {
|
|
59
|
+
code = applyEsmExtensions(code, args.path);
|
|
60
|
+
}
|
|
61
|
+
if (cedarConfig.experimental?.opentelemetry?.enabled && cedarConfig.experimental?.opentelemetry?.wrapApi) {
|
|
62
|
+
code = applyOtelWrapping(code, args.path, getPaths().api.src) ?? code;
|
|
63
|
+
}
|
|
64
|
+
code = applyHandlerAlsWrapping(code, {
|
|
65
|
+
projectIsEsm: projectSideIsEsm("api")
|
|
66
|
+
}) ?? code;
|
|
67
|
+
return {
|
|
68
|
+
contents: code,
|
|
69
|
+
// Babel output is always plain JS. Without Babel the contents are
|
|
70
|
+
// still TypeScript when the source file is graphql.ts, so pick the
|
|
71
|
+
// matching loader and let esbuild do the stripping. (The onLoad
|
|
72
|
+
// filter only matches .ts and .js files.)
|
|
73
|
+
loader: !apiBabelConfigPath && args.path.endsWith(".ts") ? "ts" : "js"
|
|
74
|
+
};
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
export {
|
|
79
|
+
cedarApiGraphqlPlugin
|
|
80
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { parseSync } from "oxc-parser";
|
|
3
|
+
function applyOtelWrapping(code, filename, apiSrc) {
|
|
4
|
+
const relative = path.relative(apiSrc, filename);
|
|
5
|
+
const apiFolder = relative.split(path.sep)[0] ?? "?";
|
|
6
|
+
const parseResult = parseSync(filename, code, { sourceType: "module" });
|
|
7
|
+
const replacements = [];
|
|
8
|
+
for (const node of parseResult.program.body) {
|
|
9
|
+
if (node.type !== "ExportNamedDeclaration") {
|
|
10
|
+
continue;
|
|
11
|
+
}
|
|
12
|
+
const decl = node.declaration;
|
|
13
|
+
if (decl?.type !== "VariableDeclaration") {
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
const declarator = decl.declarations[0];
|
|
17
|
+
if (!declarator) {
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
const fn = declarator.init;
|
|
21
|
+
if (fn?.type !== "ArrowFunctionExpression") {
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
if (declarator.id.type !== "Identifier") {
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
const fnName = declarator.id.name;
|
|
28
|
+
const innerArgs = buildInnerArgs(fn.params);
|
|
29
|
+
if (innerArgs === null) {
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
const fnHeader = code.slice(fn.start, fn.body.start);
|
|
33
|
+
const originalFnSrc = code.slice(fn.start, fn.end);
|
|
34
|
+
const isAsync = fn.async;
|
|
35
|
+
const awaitKw = isAsync ? "await " : "";
|
|
36
|
+
const asyncKw = isAsync ? "async " : "";
|
|
37
|
+
replacements.push({
|
|
38
|
+
start: node.start,
|
|
39
|
+
end: node.end,
|
|
40
|
+
src: buildWrappedExport(
|
|
41
|
+
fnName,
|
|
42
|
+
fnHeader,
|
|
43
|
+
originalFnSrc,
|
|
44
|
+
innerArgs,
|
|
45
|
+
awaitKw,
|
|
46
|
+
asyncKw,
|
|
47
|
+
apiFolder,
|
|
48
|
+
filename
|
|
49
|
+
)
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
if (replacements.length === 0) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
let output = code;
|
|
56
|
+
for (let i = replacements.length - 1; i >= 0; i--) {
|
|
57
|
+
const r = replacements[i];
|
|
58
|
+
output = output.slice(0, r.start) + r.src + output.slice(r.end);
|
|
59
|
+
}
|
|
60
|
+
return `import { trace as OTEL_TRACE } from '@opentelemetry/api'
|
|
61
|
+
` + output;
|
|
62
|
+
}
|
|
63
|
+
function buildInnerArgs(params) {
|
|
64
|
+
const args = [];
|
|
65
|
+
for (const param of params) {
|
|
66
|
+
if (param.type === "RestElement" || param.type === "ArrayPattern" || param.type === "TSParameterProperty") {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
if (param.type === "Identifier") {
|
|
70
|
+
args.push(param.name);
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
if (param.type === "ObjectPattern") {
|
|
74
|
+
for (const prop of param.properties) {
|
|
75
|
+
if (prop.type === "RestElement") {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
if (prop.key.type !== "Identifier") {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
const value = prop.value;
|
|
82
|
+
if (value.type !== "Identifier" && value.type !== "AssignmentPattern" && value.type !== "ObjectPattern") {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
if (value.type === "AssignmentPattern") {
|
|
86
|
+
if (value.left.type !== "Identifier" && value.left.type !== "ObjectPattern") {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const obj = buildObjectCallArg(param);
|
|
92
|
+
if (obj === null) {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
args.push(obj);
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
if (param.type === "AssignmentPattern") {
|
|
99
|
+
const ap = param;
|
|
100
|
+
if (ap.left.type === "Identifier") {
|
|
101
|
+
args.push(ap.left.name);
|
|
102
|
+
} else if (ap.left.type === "ObjectPattern") {
|
|
103
|
+
const obj = buildObjectCallArg(ap.left);
|
|
104
|
+
if (obj === null) {
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
args.push(obj);
|
|
108
|
+
} else {
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
return args.join(", ");
|
|
116
|
+
}
|
|
117
|
+
function buildObjectCallArg(pattern) {
|
|
118
|
+
const keys = [];
|
|
119
|
+
for (const prop of pattern.properties) {
|
|
120
|
+
if (prop.type === "RestElement") {
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
if (prop.key.type !== "Identifier") {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
const keyName = prop.key.name;
|
|
127
|
+
let valueName = null;
|
|
128
|
+
if (prop.value.type === "Identifier") {
|
|
129
|
+
valueName = prop.value.name;
|
|
130
|
+
} else if (prop.value.type === "AssignmentPattern") {
|
|
131
|
+
if (prop.value.left.type === "Identifier") {
|
|
132
|
+
valueName = prop.value.left.name;
|
|
133
|
+
} else {
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
} else {
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
if (valueName !== keyName) {
|
|
140
|
+
keys.push(`${keyName}: ${valueName}`);
|
|
141
|
+
} else {
|
|
142
|
+
keys.push(keyName);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return `{ ${keys.join(", ")} }`;
|
|
146
|
+
}
|
|
147
|
+
function buildWrappedExport(fnName, fnHeader, originalFnSrc, innerArgs, awaitKw, asyncKw, apiFolder, filename) {
|
|
148
|
+
const privateName = `__${fnName}`;
|
|
149
|
+
const spanName = `redwoodjs:api:${apiFolder}:${fnName}`;
|
|
150
|
+
return `export const ${fnName} = ${fnHeader}{
|
|
151
|
+
const ${privateName} = ${originalFnSrc}
|
|
152
|
+
const OTEL_TRACER = OTEL_TRACE.getTracer('redwoodjs')
|
|
153
|
+
const OTEL_RESULT = ${awaitKw}OTEL_TRACER.startActiveSpan(
|
|
154
|
+
'${spanName}',
|
|
155
|
+
${asyncKw}(span) => {
|
|
156
|
+
span.setAttribute('code.function', '${fnName}')
|
|
157
|
+
span.setAttribute('code.filepath', ${JSON.stringify(filename)})
|
|
158
|
+
try {
|
|
159
|
+
const OTEL_INNER_RESULT = ${awaitKw}${privateName}(${innerArgs})
|
|
160
|
+
span.end()
|
|
161
|
+
return OTEL_INNER_RESULT
|
|
162
|
+
} catch (error) {
|
|
163
|
+
span.recordException(error)
|
|
164
|
+
span.setStatus({
|
|
165
|
+
code: 2,
|
|
166
|
+
message:
|
|
167
|
+
error?.message?.split('\\n')[0] ??
|
|
168
|
+
error?.toString()?.split('\\n')[0],
|
|
169
|
+
})
|
|
170
|
+
span.end()
|
|
171
|
+
throw error
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
)
|
|
175
|
+
return OTEL_RESULT
|
|
176
|
+
}`;
|
|
177
|
+
}
|
|
178
|
+
export {
|
|
179
|
+
applyOtelWrapping
|
|
180
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
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,4 +1,4 @@
|
|
|
1
|
-
function
|
|
1
|
+
function applyHandlerAlsWrapping(code, { projectIsEsm = false } = {}) {
|
|
2
2
|
const handlerRe = /^export\s+(?:const|let|var)\s+handler(?:[^=]|=>)*?=(?![>=])/m;
|
|
3
3
|
const handlerMatch = handlerRe.exec(code);
|
|
4
4
|
if (!handlerMatch) {
|
|
@@ -7,29 +7,29 @@ function applyContextWrapping(code, { projectIsEsm = false } = {}) {
|
|
|
7
7
|
const afterEquals = code.slice(handlerMatch.index + handlerMatch[0].length).trimStart();
|
|
8
8
|
const isAsync = /^async(?:\s*[\(\*]|\s+function)/.test(afterEquals);
|
|
9
9
|
const storePath = projectIsEsm ? "@cedarjs/context/dist/store.js" : "@cedarjs/context/dist/store";
|
|
10
|
-
const importStatement = `import { getAsyncStoreInstance as
|
|
10
|
+
const importStatement = `import { getAsyncStoreInstance as __cedar_getAsyncStoreInstance } from '${storePath}'
|
|
11
11
|
`;
|
|
12
12
|
const handlerStart = handlerMatch.index;
|
|
13
13
|
const before = code.slice(0, handlerStart);
|
|
14
14
|
const after = code.slice(handlerStart);
|
|
15
|
-
const renamed = after.replace(handlerRe, "const
|
|
15
|
+
const renamed = after.replace(handlerRe, "const __cedar_handler =");
|
|
16
16
|
const wrappedHandler = `
|
|
17
|
-
export const handler = ${isAsync ? "async " : ""}(
|
|
17
|
+
export const handler = ${isAsync ? "async " : ""}(__cedar_event, __cedar_context) => {
|
|
18
18
|
// The store will be undefined if no context isolation has been performed yet
|
|
19
|
-
const
|
|
20
|
-
if (
|
|
21
|
-
return
|
|
19
|
+
const __cedar_contextStore = __cedar_getAsyncStoreInstance().getStore()
|
|
20
|
+
if (__cedar_contextStore === undefined) {
|
|
21
|
+
return __cedar_getAsyncStoreInstance().run(
|
|
22
22
|
new Map(),
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
__cedar_handler,
|
|
24
|
+
__cedar_event,
|
|
25
|
+
__cedar_context
|
|
26
26
|
)
|
|
27
27
|
}
|
|
28
|
-
return
|
|
28
|
+
return __cedar_handler(__cedar_event, __cedar_context)
|
|
29
29
|
}
|
|
30
30
|
`;
|
|
31
31
|
return before + importStatement + renamed + wrappedHandler;
|
|
32
32
|
}
|
|
33
33
|
export {
|
|
34
|
-
|
|
34
|
+
applyHandlerAlsWrapping
|
|
35
35
|
};
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
function applyEsmExtensions(code, fromFile) {
|
|
4
|
+
const fromDir = path.dirname(fromFile);
|
|
5
|
+
const rewriteImportPath = (importPath, preservePrefix, preserveSuffix) => {
|
|
6
|
+
const existingExt = path.extname(importPath);
|
|
7
|
+
const absImport = path.join(fromDir, importPath);
|
|
8
|
+
if (existingExt && existingExt !== ".js" && existingExt !== ".jsx") {
|
|
9
|
+
if (fs.existsSync(absImport + ".ts") || fs.existsSync(absImport + ".js") || fs.existsSync(absImport + ".tsx") || fs.existsSync(absImport + ".jsx")) {
|
|
10
|
+
return preservePrefix + importPath + ".js" + preserveSuffix;
|
|
11
|
+
}
|
|
12
|
+
return preservePrefix + importPath + preserveSuffix;
|
|
13
|
+
}
|
|
14
|
+
const base = existingExt ? importPath.slice(0, -existingExt.length) : importPath;
|
|
15
|
+
const absBase = path.join(fromDir, base);
|
|
16
|
+
if (fs.existsSync(absBase + ".ts") || fs.existsSync(absBase + ".js") || fs.existsSync(absBase + ".tsx") || fs.existsSync(absBase + ".jsx")) {
|
|
17
|
+
return preservePrefix + base + ".js" + preserveSuffix;
|
|
18
|
+
}
|
|
19
|
+
return preservePrefix + importPath + preserveSuffix;
|
|
20
|
+
};
|
|
21
|
+
let result = code.replace(
|
|
22
|
+
/\bfrom\s+(['"])(\.\.?\/[^'"]+)\1/g,
|
|
23
|
+
(match, quote, importPath) => {
|
|
24
|
+
return `from ${rewriteImportPath(importPath, quote, quote)}`;
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
result = result.replace(
|
|
28
|
+
/\bimport\s*\(\s*(['"])(\.\.?\/[^'"]+)\1\s*\)/g,
|
|
29
|
+
(match, quote, importPath) => {
|
|
30
|
+
return `import(${rewriteImportPath(importPath, quote, quote)})`;
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
applyEsmExtensions
|
|
37
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import MagicString from "magic-string";
|
|
4
|
+
import { getPaths, importStatementPath } from "@cedarjs/project-config";
|
|
5
|
+
function applyImportDir(code, filePath) {
|
|
6
|
+
if (!code.includes("**")) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
const GLOB_IMPORT_RE = /^import\s+(\w+)\s+from\s+['"]([^'"]+)['"]\s*;?/gm;
|
|
10
|
+
const s = new MagicString(code);
|
|
11
|
+
let hasTransformations = false;
|
|
12
|
+
for (const match of code.matchAll(GLOB_IMPORT_RE)) {
|
|
13
|
+
const importName = match[1];
|
|
14
|
+
const sourceValue = match[2];
|
|
15
|
+
if (!sourceValue.includes("**")) {
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
const importGlob = importStatementPath(sourceValue);
|
|
19
|
+
const cwd = importGlob.startsWith("src/") ? getPaths().api.base : path.dirname(filePath);
|
|
20
|
+
let dirFiles;
|
|
21
|
+
try {
|
|
22
|
+
dirFiles = fs.globSync(importGlob, {
|
|
23
|
+
cwd,
|
|
24
|
+
exclude: (n) => n.includes(".test.") || n.includes(".scenarios.") || n.includes(".d.ts")
|
|
25
|
+
});
|
|
26
|
+
} catch {
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
const staticGlob = importGlob.split("*")[0];
|
|
30
|
+
const filePathToVarName = (fp) => fp.replace(staticGlob, "").replace(/\.(js|ts)$/, "").replace(/[^a-zA-Z0-9]/g, "_");
|
|
31
|
+
hasTransformations = true;
|
|
32
|
+
let replacement = `let ${importName} = {};
|
|
33
|
+
`;
|
|
34
|
+
for (const fp of dirFiles) {
|
|
35
|
+
const { dir: fileDir, name: fileName } = path.parse(fp);
|
|
36
|
+
const normalizedDir = importStatementPath(fileDir);
|
|
37
|
+
const varName = filePathToVarName(fp);
|
|
38
|
+
const nsImport = `${importName}_${varName}`;
|
|
39
|
+
replacement += `import * as ${nsImport} from '${normalizedDir}/${fileName}';
|
|
40
|
+
`;
|
|
41
|
+
replacement += `${importName}.${varName} = ${nsImport};
|
|
42
|
+
`;
|
|
43
|
+
}
|
|
44
|
+
s.overwrite(
|
|
45
|
+
match.index,
|
|
46
|
+
match.index + match[0].length,
|
|
47
|
+
replacement.trimEnd()
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
return hasTransformations ? { code: s.toString(), map: s.generateMap({ hires: true }) } : null;
|
|
51
|
+
}
|
|
52
|
+
export {
|
|
53
|
+
applyImportDir
|
|
54
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { parseSync } from "oxc-parser";
|
|
3
|
+
function applyJobPathInjector(code, filePath, jobsDir) {
|
|
4
|
+
if (!code.includes("createJob")) {
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
let program;
|
|
8
|
+
try {
|
|
9
|
+
program = parseSync(filePath, code, { sourceType: "module" }).program;
|
|
10
|
+
} catch (error) {
|
|
11
|
+
console.warn("Failed to parse file:", filePath);
|
|
12
|
+
console.warn(error);
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
const importPath = path.relative(jobsDir, filePath);
|
|
16
|
+
const importPathWithoutExtension = importPath.replace(/\.[^/.]+$/, "");
|
|
17
|
+
const insertions = [];
|
|
18
|
+
for (const node of program.body) {
|
|
19
|
+
if (node.type !== "ExportNamedDeclaration") {
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
const decl = node.declaration;
|
|
23
|
+
if (decl?.type !== "VariableDeclaration") {
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
for (const declarator of decl.declarations) {
|
|
27
|
+
if (declarator.id.type !== "Identifier") {
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
const init = declarator.init;
|
|
31
|
+
if (init?.type !== "CallExpression") {
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
const callee = init.callee;
|
|
35
|
+
if (callee.type !== "MemberExpression" || callee.computed || callee.property.type !== "Identifier" || callee.property.name !== "createJob") {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
const configArg = init.arguments[0];
|
|
39
|
+
if (configArg?.type !== "ObjectExpression") {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
const pathProperty = `path: ${JSON.stringify(importPathWithoutExtension)}`;
|
|
43
|
+
const nameProperty = `name: ${JSON.stringify(declarator.id.name)}`;
|
|
44
|
+
const lastProperty = configArg.properties.at(-1);
|
|
45
|
+
if (lastProperty) {
|
|
46
|
+
insertions.push({
|
|
47
|
+
pos: lastProperty.end,
|
|
48
|
+
text: `, ${pathProperty}, ${nameProperty}`
|
|
49
|
+
});
|
|
50
|
+
} else {
|
|
51
|
+
insertions.push({
|
|
52
|
+
pos: configArg.start + 1,
|
|
53
|
+
text: `${pathProperty}, ${nameProperty}`
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (insertions.length === 0) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
let result = code;
|
|
62
|
+
for (const { pos, text } of insertions.sort((a, b) => b.pos - a.pos)) {
|
|
63
|
+
result = result.slice(0, pos) + text + result.slice(pos);
|
|
64
|
+
}
|
|
65
|
+
return result;
|
|
66
|
+
}
|
|
67
|
+
export {
|
|
68
|
+
applyJobPathInjector
|
|
69
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rewrites `src/` bare specifiers in source code to relative paths, so that the
|
|
3
|
+
* esbuild API build (with `bundle: false`) produces output files with
|
|
4
|
+
* resolvable import paths at runtime.
|
|
5
|
+
*
|
|
6
|
+
* This replaces the `babel-plugin-module-resolver` `src: './src'` alias for the
|
|
7
|
+
* esbuild build paths. It is a plain function called inline from the existing
|
|
8
|
+
* esbuild `onLoad` handlers — not an esbuild plugin itself.
|
|
9
|
+
*
|
|
10
|
+
* For a file at `api/src/functions/graphql.ts` importing `src/lib/db`, this
|
|
11
|
+
* rewrites it to `../lib/db`.
|
|
12
|
+
*/
|
|
13
|
+
export declare function applySrcAlias(code: string, fromDirRelativeToApiSrc: string): string;
|
|
14
|
+
//# sourceMappingURL=src-alias.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"src-alias.d.ts","sourceRoot":"","sources":["../../src/build/src-alias.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;GAWG;AAEH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,uBAAuB,EAAE,MAAM,GAC9B,MAAM,CAWR"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { importStatementPath } from "@cedarjs/project-config";
|
|
3
|
+
function applySrcAlias(code, fromDirRelativeToApiSrc) {
|
|
4
|
+
return code.replace(
|
|
5
|
+
/from\s+['"]src\/(.+?)['"]/g,
|
|
6
|
+
(_match, rest) => {
|
|
7
|
+
const target = path.relative(fromDirRelativeToApiSrc, rest);
|
|
8
|
+
const formatted = importStatementPath(
|
|
9
|
+
target.startsWith(".") ? target : "./" + target
|
|
10
|
+
);
|
|
11
|
+
return `from '${formatted}'`;
|
|
12
|
+
}
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
applySrcAlias
|
|
17
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tsconfig-paths.d.ts","sourceRoot":"","sources":["../../src/build/tsconfig-paths.ts"],"names":[],"mappings":"AA8FA,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,MAAM,GACV,MAAM,CAyCR"}
|