@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
package/dist/ast.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export declare const getNamedExports: (ast: types.Node) => NamedExports[];
|
|
|
17
17
|
*/
|
|
18
18
|
export declare const getGqlQueries: (ast: types.Node) => string[];
|
|
19
19
|
export declare const getCellGqlQuery: (ast: types.Node) => undefined;
|
|
20
|
+
export declare const getCellGqlFragment: (ast: types.Node) => undefined;
|
|
20
21
|
export declare const hasDefaultExport: (ast: types.Node) => boolean;
|
|
21
22
|
export declare const getDefaultExportLocation: (ast: types.Node) => {
|
|
22
23
|
line: number;
|
package/dist/ast.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../src/ast.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../src/ast.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAYnC,eAAO,MAAM,SAAS,GAAI,UAAU,MAAM,KAAG,KAAK,CAAC,IAyBlD,CAAA;AAED,UAAU,YAAY;IACpB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,WAAW,GAAG,UAAU,GAAG,UAAU,GAAG,OAAO,CAAA;IACrD,QAAQ,EAAE;QACR,IAAI,EAAE,MAAM,CAAA;QACZ,MAAM,EAAE,MAAM,CAAA;KACf,CAAA;CACF;AACD;;GAEG;AACH,eAAO,MAAM,eAAe,GAAI,KAAK,KAAK,CAAC,IAAI,KAAG,YAAY,EA4D7D,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,aAAa,GAAI,KAAK,KAAK,CAAC,IAAI,aAY5C,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,KAAK,KAAK,CAAC,IAAI,cA8B9C,CAAA;AAED,eAAO,MAAM,kBAAkB,GAAI,KAAK,KAAK,CAAC,IAAI,cA8BjD,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,KAAK,KAAK,CAAC,IAAI,KAAG,OASlD,CAAA;AAED,eAAO,MAAM,wBAAwB,GACnC,KAAK,KAAK,CAAC,IAAI,KACd;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,IA0CrC,CAAA"}
|
package/dist/ast.js
CHANGED
|
@@ -115,6 +115,26 @@ const getCellGqlQuery = (ast) => {
|
|
|
115
115
|
});
|
|
116
116
|
return cellQuery;
|
|
117
117
|
};
|
|
118
|
+
const getCellGqlFragment = (ast) => {
|
|
119
|
+
let cellFragment = void 0;
|
|
120
|
+
traverse(ast, {
|
|
121
|
+
ExportNamedDeclaration({ node }) {
|
|
122
|
+
if (node.exportKind === "value" && types.isVariableDeclaration(node.declaration)) {
|
|
123
|
+
const exportedFragmentNode = node.declaration.declarations.find(
|
|
124
|
+
(d) => {
|
|
125
|
+
return types.isIdentifier(d.id) && d.id.name === "FRAGMENT" && types.isTaggedTemplateExpression(d.init);
|
|
126
|
+
}
|
|
127
|
+
);
|
|
128
|
+
if (exportedFragmentNode) {
|
|
129
|
+
const templateExpression = exportedFragmentNode.init;
|
|
130
|
+
cellFragment = templateExpression.quasi.quasis[0].value.raw;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
return cellFragment;
|
|
137
|
+
};
|
|
118
138
|
const hasDefaultExport = (ast) => {
|
|
119
139
|
let exported = false;
|
|
120
140
|
traverse(ast, {
|
|
@@ -154,6 +174,7 @@ const getDefaultExportLocation = (ast) => {
|
|
|
154
174
|
};
|
|
155
175
|
export {
|
|
156
176
|
fileToAst,
|
|
177
|
+
getCellGqlFragment,
|
|
157
178
|
getCellGqlQuery,
|
|
158
179
|
getDefaultExportLocation,
|
|
159
180
|
getGqlQueries,
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extracts the options argument from createGraphQLHandler calls and stores
|
|
3
|
+
* them in an exported variable. Returns the transformed code, or null if no
|
|
4
|
+
* transformation was needed.
|
|
5
|
+
*
|
|
6
|
+
* Transforms:
|
|
7
|
+
* export const handler = createGraphQLHandler({ options })
|
|
8
|
+
* into:
|
|
9
|
+
* export const __cedar_graphqlOptions = { options }
|
|
10
|
+
* export const handler = createGraphQLHandler(__cedar_graphqlOptions)
|
|
11
|
+
*/
|
|
12
|
+
export declare function applyGraphqlOptionsExtract(code: string): string | null;
|
|
13
|
+
/**
|
|
14
|
+
* Injects the auto-generated gqlorm backend into graphql.ts at build time.
|
|
15
|
+
*
|
|
16
|
+
* When `experimental.gqlorm.enabled = true` and `.cedar/gqlorm/backend.ts`
|
|
17
|
+
* exists, this function:
|
|
18
|
+
*
|
|
19
|
+
* 1. Adds imports at the top of graphql.ts:
|
|
20
|
+
* import * as __gqlorm_sdl__ from '../../../.cedar/gqlorm/backend'
|
|
21
|
+
* import { db as __gqlorm_db__ } from 'src/lib/db'
|
|
22
|
+
*
|
|
23
|
+
* 2. Inserts a statement immediately before the `createGraphQLHandler` call:
|
|
24
|
+
* Object.assign(sdls, {
|
|
25
|
+
* __gqlorm__: {
|
|
26
|
+
* schema: __gqlorm_sdl__.schema,
|
|
27
|
+
* resolvers: __gqlorm_sdl__.createGqlormResolvers(__gqlorm_db__),
|
|
28
|
+
* },
|
|
29
|
+
* })
|
|
30
|
+
*
|
|
31
|
+
* Returns the transformed code, or null if no transformation was needed.
|
|
32
|
+
*/
|
|
33
|
+
export declare function applyGqlormInject(code: string, id: string, dbExt?: '.ts' | '.js'): string | null;
|
|
34
|
+
//# sourceMappingURL=api-graphql-transforms.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-graphql-transforms.d.ts","sourceRoot":"","sources":["../../src/build/api-graphql-transforms.ts"],"names":[],"mappings":"AAYA;;;;;;;;;;GAUG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CA6FtE;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,EACV,KAAK,GAAE,KAAK,GAAG,KAAa,GAC3B,MAAM,GAAG,IAAI,CAmFf"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { parseSync, Visitor } from "oxc-parser";
|
|
4
|
+
import {
|
|
5
|
+
getConfig,
|
|
6
|
+
getPaths,
|
|
7
|
+
importStatementPath
|
|
8
|
+
} from "@cedarjs/project-config";
|
|
9
|
+
function applyGraphqlOptionsExtract(code) {
|
|
10
|
+
if (code.includes("__cedar_graphqlOptions")) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
const { program } = parseSync("graphql.ts", code, {
|
|
14
|
+
// lang is only a parse hint; 'ts' also parses JS (the graphql handler can
|
|
15
|
+
// be graphql.js in JS projects), so this is safe for both file types.
|
|
16
|
+
lang: "ts",
|
|
17
|
+
sourceType: "module"
|
|
18
|
+
});
|
|
19
|
+
const importNames = /* @__PURE__ */ new Set();
|
|
20
|
+
for (const node of program.body) {
|
|
21
|
+
if (node.type === "ImportDeclaration") {
|
|
22
|
+
if (node.source.value !== "@cedarjs/graphql-server") {
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
for (const specifier of node.specifiers) {
|
|
26
|
+
if (specifier.type === "ImportSpecifier" && specifier.imported.type === "Identifier" && specifier.imported.name === "createGraphQLHandler") {
|
|
27
|
+
importNames.add(specifier.local.name);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (importNames.size === 0) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
const callExpressionPaths = [];
|
|
36
|
+
new Visitor({
|
|
37
|
+
CallExpression(node) {
|
|
38
|
+
if (node.callee.type === "Identifier" && importNames.has(node.callee.name)) {
|
|
39
|
+
callExpressionPaths.push(node);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}).visit(program);
|
|
43
|
+
if (callExpressionPaths.length > 1) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
const callExpression = callExpressionPaths[0];
|
|
47
|
+
if (!callExpression) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
const options = callExpression.arguments[0];
|
|
51
|
+
if (!options) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
if (options.type !== "Identifier" && options.type !== "ObjectExpression" && options.type !== "CallExpression" && options.type !== "ConditionalExpression") {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
const optionsStart = options.start;
|
|
58
|
+
const optionsEnd = options.end;
|
|
59
|
+
const lineStart = code.lastIndexOf("\n", callExpression.start) + 1;
|
|
60
|
+
const indentMatch = /^[ \t]*/.exec(code.slice(lineStart));
|
|
61
|
+
const indent = indentMatch ? indentMatch[0] : "";
|
|
62
|
+
const optionsConst = `${indent}export const __cedar_graphqlOptions = ${code.slice(
|
|
63
|
+
optionsStart,
|
|
64
|
+
optionsEnd
|
|
65
|
+
)}
|
|
66
|
+
`;
|
|
67
|
+
const before = code.slice(0, lineStart);
|
|
68
|
+
const between = code.slice(lineStart, optionsStart);
|
|
69
|
+
const after = code.slice(optionsEnd);
|
|
70
|
+
return before + optionsConst + between + "__cedar_graphqlOptions" + after;
|
|
71
|
+
}
|
|
72
|
+
function applyGqlormInject(code, id, dbExt = ".ts") {
|
|
73
|
+
if (code.includes("__gqlorm_sdl__")) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
if (!code.includes("createGraphQLHandler")) {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
if (!getConfig().experimental?.gqlorm?.enabled) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
const backendPathWithoutExt = path.join(
|
|
83
|
+
getPaths().generated.base,
|
|
84
|
+
"gqlorm",
|
|
85
|
+
"backend"
|
|
86
|
+
);
|
|
87
|
+
if (!fs.existsSync(backendPathWithoutExt + ".ts")) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
const handlerPattern = /^export\s+const\s+(\w+)\s*=\s*createGraphQLHandler\s*\(/m;
|
|
91
|
+
const handlerMatch = handlerPattern.exec(code);
|
|
92
|
+
if (!handlerMatch) {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
const handlerLineStart = code.lastIndexOf("\n", handlerMatch.index) + 1;
|
|
96
|
+
const relPath = importStatementPath(
|
|
97
|
+
path.relative(path.dirname(id), backendPathWithoutExt)
|
|
98
|
+
) + ".ts";
|
|
99
|
+
const dbSrcPath = path.join(getPaths().api.src, "lib", "db");
|
|
100
|
+
const relDbPath = importStatementPath(path.relative(path.dirname(id), dbSrcPath)) + dbExt;
|
|
101
|
+
const importDb = `import { db as __gqlorm_db__ } from '${relDbPath}'`;
|
|
102
|
+
const importSdl = `import * as __gqlorm_sdl__ from '${relPath}'`;
|
|
103
|
+
const importsToAdd = `${importDb}
|
|
104
|
+
${importSdl}
|
|
105
|
+
`;
|
|
106
|
+
const sdlsMutation = `Object.assign(sdls, {
|
|
107
|
+
__gqlorm__: {
|
|
108
|
+
schema: __gqlorm_sdl__.schema,
|
|
109
|
+
resolvers: __gqlorm_sdl__.createGqlormResolvers(__gqlorm_db__),
|
|
110
|
+
},
|
|
111
|
+
})
|
|
112
|
+
`;
|
|
113
|
+
const transformed = importsToAdd + code.slice(0, handlerLineStart) + sdlsMutation + code.slice(handlerLineStart);
|
|
114
|
+
return transformed;
|
|
115
|
+
}
|
|
116
|
+
export {
|
|
117
|
+
applyGqlormInject,
|
|
118
|
+
applyGraphqlOptionsExtract
|
|
119
|
+
};
|
package/dist/build/api.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { BuildOptions } from 'esbuild';
|
|
2
|
+
export { applySrcAlias } from './src-alias.js';
|
|
3
|
+
export { applyEsmExtensions } from './esm-extensions.js';
|
|
2
4
|
export declare const buildApi: () => Promise<import("esbuild").BuildResult<BuildOptions>>;
|
|
3
5
|
export declare const rebuildApi: () => Promise<import("esbuild").BuildResult<BuildOptions>>;
|
|
4
6
|
export declare const cleanApiBuild: () => Promise<void>;
|
package/dist/build/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/build/api.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAgB,YAAY,EAAe,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/build/api.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAgB,YAAY,EAAe,MAAM,SAAS,CAAA;AA6CtE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAIxD,eAAO,MAAM,QAAQ,4DAIpB,CAAA;AAED,eAAO,MAAM,UAAU,4DAStB,CAAA;AAED,eAAO,MAAM,aAAa,qBAGzB,CAAA;AA0VD,eAAO,MAAM,gBAAgB,iHAiE5B,CAAA;AAcD,wBAAsB,aAAa,CACjC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CAoDf"}
|
package/dist/build/api.js
CHANGED
|
@@ -1,14 +1,42 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { build, context } from "esbuild";
|
|
4
|
+
import MagicString from "magic-string";
|
|
4
5
|
import { build as viteBuild, normalizePath } from "vite";
|
|
6
|
+
import tsPathsMod from "vite-tsconfig-paths";
|
|
7
|
+
const tsconfigPaths = (
|
|
8
|
+
// @ts-expect-error – .default only exists at runtime in CJS double-wrap
|
|
9
|
+
// interop
|
|
10
|
+
tsPathsMod.default?.default || tsPathsMod.default || tsPathsMod
|
|
11
|
+
);
|
|
5
12
|
import {
|
|
6
|
-
|
|
13
|
+
getApiSideBabelConfigPath,
|
|
14
|
+
getApiSideBabelPluginsForVite,
|
|
7
15
|
transformWithBabel
|
|
8
16
|
} from "@cedarjs/babel-config";
|
|
9
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
getConfig,
|
|
19
|
+
getPaths,
|
|
20
|
+
projectSideIsEsm,
|
|
21
|
+
resolveFile
|
|
22
|
+
} from "@cedarjs/project-config";
|
|
10
23
|
import { findApiFiles } from "../files.js";
|
|
11
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
applyGqlormInject,
|
|
26
|
+
applyGraphqlOptionsExtract
|
|
27
|
+
} from "./api-graphql-transforms.js";
|
|
28
|
+
import { applyAutoImports } from "./auto-import.js";
|
|
29
|
+
import { applyDirectoryNamedImport } from "./directory-named-import.js";
|
|
30
|
+
import { cedarApiGraphqlPlugin } from "./esbuild-plugin-api-graphql.js";
|
|
31
|
+
import { applyOtelWrapping } from "./esbuild-plugin-cedar-otel-wrapping.js";
|
|
32
|
+
import { applyHandlerAlsWrapping } from "./esbuild-plugin-handler-als-wrapping.js";
|
|
33
|
+
import { applyEsmExtensions } from "./esm-extensions.js";
|
|
34
|
+
import { applyImportDir } from "./import-dir.js";
|
|
35
|
+
import { applyJobPathInjector } from "./job-path-injector.js";
|
|
36
|
+
import { applySrcAlias } from "./src-alias.js";
|
|
37
|
+
import { applyTsconfigPaths } from "./tsconfig-paths.js";
|
|
38
|
+
import { applySrcAlias as applySrcAlias2 } from "./src-alias.js";
|
|
39
|
+
import { applyEsmExtensions as applyEsmExtensions2 } from "./esm-extensions.js";
|
|
12
40
|
let BUILD_CTX = null;
|
|
13
41
|
const buildApi = async () => {
|
|
14
42
|
BUILD_CTX?.dispose();
|
|
@@ -32,33 +60,124 @@ const cleanApiBuild = async () => {
|
|
|
32
60
|
const runCedarBabelTransformsPlugin = {
|
|
33
61
|
name: "cedar-esbuild-babel-transform",
|
|
34
62
|
setup(build2) {
|
|
35
|
-
const cedarConfig = getConfig();
|
|
36
63
|
build2.onLoad({ filter: /\.(js|ts|tsx|jsx)$/ }, async (args) => {
|
|
37
|
-
|
|
38
|
-
|
|
64
|
+
let fileContents = await fs.promises.readFile(args.path, "utf-8");
|
|
65
|
+
fileContents = applySrcAlias(
|
|
66
|
+
fileContents,
|
|
67
|
+
path.dirname(
|
|
68
|
+
path.relative(build2.initialOptions.absWorkingDir + "/src", args.path)
|
|
69
|
+
)
|
|
70
|
+
);
|
|
71
|
+
fileContents = applyTsconfigPaths(
|
|
39
72
|
fileContents,
|
|
40
73
|
args.path,
|
|
41
|
-
|
|
42
|
-
openTelemetry: cedarConfig.experimental.opentelemetry.enabled && cedarConfig.experimental.opentelemetry.wrapApi,
|
|
43
|
-
projectIsEsm: projectSideIsEsm("api")
|
|
44
|
-
})
|
|
74
|
+
getPaths().api.base
|
|
45
75
|
);
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
76
|
+
fileContents = applyDirectoryNamedImport(fileContents, args.path);
|
|
77
|
+
fileContents = applyAutoImports(fileContents);
|
|
78
|
+
fileContents = applyImportDir(fileContents, args.path)?.code ?? fileContents;
|
|
79
|
+
fileContents = applyJobPathInjector(fileContents, args.path, getPaths().api.jobs) ?? fileContents;
|
|
80
|
+
const normalizedPath = normalizePath(args.path);
|
|
81
|
+
const cedarPaths = getPaths();
|
|
82
|
+
const isEsm = projectSideIsEsm("api");
|
|
83
|
+
const apiBabelConfigPath = getApiSideBabelConfigPath();
|
|
84
|
+
let code = fileContents;
|
|
85
|
+
if (apiBabelConfigPath) {
|
|
86
|
+
const transformedCode = await transformWithBabel(
|
|
87
|
+
fileContents,
|
|
88
|
+
args.path,
|
|
89
|
+
getApiSideBabelPluginsForVite(),
|
|
90
|
+
"inline",
|
|
91
|
+
true
|
|
49
92
|
);
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
93
|
+
if (!transformedCode?.code) {
|
|
94
|
+
throw new Error(`Could not transform file: ${args.path}`);
|
|
95
|
+
}
|
|
96
|
+
code = transformedCode.code;
|
|
97
|
+
}
|
|
98
|
+
if (isEsm) {
|
|
99
|
+
code = applyEsmExtensions(code, args.path);
|
|
100
|
+
}
|
|
101
|
+
const functionsDir = normalizePath(cedarPaths.api.functions);
|
|
102
|
+
if (normalizedPath.startsWith(functionsDir + "/")) {
|
|
103
|
+
code = applyHandlerAlsWrapping(code, {
|
|
104
|
+
projectIsEsm: isEsm
|
|
105
|
+
}) ?? code;
|
|
106
|
+
}
|
|
107
|
+
if (normalizedPath.startsWith(normalizePath(cedarPaths.api.src) + "/")) {
|
|
108
|
+
code = applyOtelWrapping(code, args.path, cedarPaths.api.src) ?? code;
|
|
57
109
|
}
|
|
58
|
-
|
|
110
|
+
return {
|
|
111
|
+
contents: code,
|
|
112
|
+
// Babel output is always plain JS. Without Babel the contents are
|
|
113
|
+
// still TypeScript/JSX, so pick the loader matching the file's
|
|
114
|
+
// extension and let esbuild do the stripping.
|
|
115
|
+
loader: apiBabelConfigPath ? "js" : getEsbuildLoader(args.path)
|
|
116
|
+
};
|
|
59
117
|
});
|
|
60
118
|
}
|
|
61
119
|
};
|
|
120
|
+
function getEsbuildLoader(filePath) {
|
|
121
|
+
switch (path.extname(filePath)) {
|
|
122
|
+
case ".ts":
|
|
123
|
+
return "ts";
|
|
124
|
+
case ".tsx":
|
|
125
|
+
return "tsx";
|
|
126
|
+
case ".jsx":
|
|
127
|
+
return "jsx";
|
|
128
|
+
default:
|
|
129
|
+
return "js";
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
function createImportDirVitePlugin() {
|
|
133
|
+
return {
|
|
134
|
+
name: "cedar-internal-import-dir",
|
|
135
|
+
enforce: "pre",
|
|
136
|
+
transform(code, id) {
|
|
137
|
+
if (!/\.(js|ts|tsx|jsx)$/.test(id)) {
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
if (id.includes("node_modules")) {
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
const result = applyImportDir(code, id);
|
|
144
|
+
if (!result) {
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
return { code: result.code, map: result.map };
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
function createDirectoryNamedImportVitePlugin() {
|
|
152
|
+
return {
|
|
153
|
+
name: "cedar-internal-directory-named-import",
|
|
154
|
+
enforce: "pre",
|
|
155
|
+
resolveId(id, importer) {
|
|
156
|
+
if (!id.startsWith(".") || !importer) {
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
if (importer.includes("node_modules")) {
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
const absolutePath = path.resolve(path.dirname(importer), id);
|
|
163
|
+
if (resolveFile(absolutePath)) {
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
const indexPath = path.join(absolutePath, "index");
|
|
167
|
+
const resolvedIndex = resolveFile(indexPath);
|
|
168
|
+
if (resolvedIndex) {
|
|
169
|
+
return normalizePath(resolvedIndex);
|
|
170
|
+
}
|
|
171
|
+
const basename = path.basename(absolutePath);
|
|
172
|
+
const dirNamedPath = path.join(absolutePath, basename);
|
|
173
|
+
const resolvedDirNamed = resolveFile(dirNamedPath);
|
|
174
|
+
if (resolvedDirNamed) {
|
|
175
|
+
return normalizePath(resolvedDirNamed);
|
|
176
|
+
}
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
}
|
|
62
181
|
function createCedarViteApiPlugin() {
|
|
63
182
|
const cedarConfig = getConfig();
|
|
64
183
|
const isEsm = projectSideIsEsm("api");
|
|
@@ -76,28 +195,55 @@ function createCedarViteApiPlugin() {
|
|
|
76
195
|
if (!normalizePath(id).startsWith(normalizePath(cedarPaths.api.base))) {
|
|
77
196
|
return null;
|
|
78
197
|
}
|
|
79
|
-
|
|
80
|
-
|
|
198
|
+
let sourceCode = code;
|
|
199
|
+
const normalizedId = normalizePath(id);
|
|
200
|
+
sourceCode = applySrcAlias(
|
|
201
|
+
sourceCode,
|
|
202
|
+
path.dirname(path.relative(cedarPaths.api.src, id))
|
|
203
|
+
);
|
|
204
|
+
sourceCode = applyAutoImports(sourceCode);
|
|
205
|
+
sourceCode = applyJobPathInjector(sourceCode, id, cedarPaths.api.jobs) ?? sourceCode;
|
|
206
|
+
if (normalizedId.endsWith("/graphql.ts") || normalizedId.endsWith("/graphql.js")) {
|
|
207
|
+
sourceCode = applyGraphqlOptionsExtract(sourceCode) ?? sourceCode;
|
|
208
|
+
sourceCode = applyGqlormInject(sourceCode, id) ?? sourceCode;
|
|
209
|
+
}
|
|
210
|
+
const apiBabelConfigPath = getApiSideBabelConfigPath();
|
|
211
|
+
const transformedCode = apiBabelConfigPath ? await transformWithBabel(
|
|
212
|
+
sourceCode,
|
|
81
213
|
id,
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
projectIsEsm: isEsm
|
|
85
|
-
}),
|
|
214
|
+
getApiSideBabelPluginsForVite(),
|
|
215
|
+
true,
|
|
86
216
|
true
|
|
87
|
-
);
|
|
88
|
-
if (transformedCode?.code) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
217
|
+
) : null;
|
|
218
|
+
if (apiBabelConfigPath && !transformedCode?.code) {
|
|
219
|
+
throw new Error(`Could not transform file: ${id}`);
|
|
220
|
+
}
|
|
221
|
+
let outputCode = transformedCode?.code ?? sourceCode;
|
|
222
|
+
if (cedarConfig.experimental?.opentelemetry?.enabled && cedarConfig.experimental?.opentelemetry?.wrapApi) {
|
|
223
|
+
outputCode = applyOtelWrapping(outputCode, id, cedarPaths.api.src) ?? outputCode;
|
|
224
|
+
}
|
|
225
|
+
if (isEsm) {
|
|
226
|
+
outputCode = applyEsmExtensions(outputCode, id);
|
|
227
|
+
}
|
|
228
|
+
const functionsDir = normalizePath(cedarPaths.api.functions);
|
|
229
|
+
if (normalizedId.startsWith(functionsDir + "/")) {
|
|
230
|
+
outputCode = applyHandlerAlsWrapping(outputCode, {
|
|
93
231
|
projectIsEsm: isEsm
|
|
94
|
-
}) ??
|
|
232
|
+
}) ?? outputCode;
|
|
233
|
+
}
|
|
234
|
+
if (!transformedCode) {
|
|
235
|
+
if (outputCode === code) {
|
|
236
|
+
return null;
|
|
237
|
+
}
|
|
95
238
|
return {
|
|
96
|
-
code:
|
|
97
|
-
map:
|
|
239
|
+
code: outputCode,
|
|
240
|
+
map: new MagicString(code).generateMap({ hires: true })
|
|
98
241
|
};
|
|
99
242
|
}
|
|
100
|
-
|
|
243
|
+
return {
|
|
244
|
+
code: outputCode,
|
|
245
|
+
map: transformedCode.map ?? null
|
|
246
|
+
};
|
|
101
247
|
}
|
|
102
248
|
};
|
|
103
249
|
}
|
|
@@ -141,7 +287,19 @@ const buildApiWithVite = async () => {
|
|
|
141
287
|
}
|
|
142
288
|
}
|
|
143
289
|
},
|
|
144
|
-
|
|
290
|
+
// cedarImportDirPlugin must run before the Babel transform so glob imports
|
|
291
|
+
// are expanded before Babel sees the code. The Babel import-dir plugin is
|
|
292
|
+
// not part of getApiSideBabelPluginsForVite(); this inline Vite plugin is
|
|
293
|
+
// its replacement for this code path (both CJS and ESM output via Rollup).
|
|
294
|
+
// tsconfigPaths resolves user-defined tsconfig.json `paths` aliases; it
|
|
295
|
+
// replaces the Babel module-resolver's tsconfig-paths handling for this
|
|
296
|
+
// code path.
|
|
297
|
+
plugins: [
|
|
298
|
+
tsconfigPaths(),
|
|
299
|
+
createImportDirVitePlugin(),
|
|
300
|
+
createDirectoryNamedImportVitePlugin(),
|
|
301
|
+
createCedarViteApiPlugin()
|
|
302
|
+
]
|
|
145
303
|
});
|
|
146
304
|
};
|
|
147
305
|
const transpileApi = async (files) => {
|
|
@@ -199,7 +357,10 @@ function getEsbuildOptions(files) {
|
|
|
199
357
|
format,
|
|
200
358
|
allowOverwrite: true,
|
|
201
359
|
bundle: false,
|
|
202
|
-
|
|
360
|
+
// Registration order matters: cedarApiGraphqlPlugin (narrow filter) must
|
|
361
|
+
// come first so it claims graphql.ts before runCedarBabelTransformsPlugin
|
|
362
|
+
// (broad filter) can. See the NOTE on cedarApiGraphqlPlugin.
|
|
363
|
+
plugins: [cedarApiGraphqlPlugin, runCedarBabelTransformsPlugin],
|
|
203
364
|
outdir: cedarPaths.api.dist,
|
|
204
365
|
// setting this to 'true' will generate an external sourcemap x.js.map
|
|
205
366
|
// AND set the sourceMappingURL comment
|
|
@@ -208,6 +369,8 @@ function getEsbuildOptions(files) {
|
|
|
208
369
|
};
|
|
209
370
|
}
|
|
210
371
|
export {
|
|
372
|
+
applyEsmExtensions2 as applyEsmExtensions,
|
|
373
|
+
applySrcAlias2 as applySrcAlias,
|
|
211
374
|
buildApi,
|
|
212
375
|
buildApiWithVite,
|
|
213
376
|
cleanApiBuild,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Injects imports for `gql` and `context` into API source files that reference
|
|
3
|
+
* them without importing them. Uses an oxc-parser AST walk to check bindings,
|
|
4
|
+
* so local declarations never receive a conflicting import.
|
|
5
|
+
*
|
|
6
|
+
* This replaces `babel-plugin-auto-import` for the esbuild API build path,
|
|
7
|
+
* matching the behavior of `cedarAutoImportsPlugin` in Vite builds.
|
|
8
|
+
*/
|
|
9
|
+
export declare function applyAutoImports(code: string): string;
|
|
10
|
+
//# sourceMappingURL=auto-import.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-import.d.ts","sourceRoot":"","sources":["../../src/build/auto-import.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AAEH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAoBrD"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { parseSync, Visitor } from "oxc-parser";
|
|
2
|
+
function applyAutoImports(code) {
|
|
3
|
+
const result = parseSync("temp.ts", code, {
|
|
4
|
+
lang: "ts",
|
|
5
|
+
sourceType: "module"
|
|
6
|
+
});
|
|
7
|
+
const needsGql = checkNeeds("gql", result.program, code);
|
|
8
|
+
const needsContext = checkNeeds("context", result.program, code);
|
|
9
|
+
let resultCode = code;
|
|
10
|
+
if (needsGql) {
|
|
11
|
+
resultCode = "import gql from 'graphql-tag'\n" + resultCode;
|
|
12
|
+
}
|
|
13
|
+
if (needsContext) {
|
|
14
|
+
resultCode = "import { context } from '@cedarjs/context'\n" + resultCode;
|
|
15
|
+
}
|
|
16
|
+
return resultCode;
|
|
17
|
+
}
|
|
18
|
+
function bindingInDeclarators(name, declarations) {
|
|
19
|
+
for (const decl of declarations) {
|
|
20
|
+
if (bindingPatternContains(decl.id, name)) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
function bindingPatternContains(pattern, name) {
|
|
27
|
+
if (pattern.type === "Identifier") {
|
|
28
|
+
return pattern.name === name;
|
|
29
|
+
}
|
|
30
|
+
if (pattern.type === "ObjectPattern") {
|
|
31
|
+
for (const prop of pattern.properties) {
|
|
32
|
+
if (prop.type === "RestElement") {
|
|
33
|
+
if (bindingPatternContains(prop.argument, name)) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
} else {
|
|
37
|
+
if (bindingPatternContains(prop.value, name)) {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
if (pattern.type === "ArrayPattern") {
|
|
45
|
+
for (const el of pattern.elements) {
|
|
46
|
+
if (el) {
|
|
47
|
+
if (el.type === "RestElement") {
|
|
48
|
+
if (bindingPatternContains(el.argument, name)) {
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
} else if (bindingPatternContains(el, name)) {
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
if (pattern.type === "AssignmentPattern") {
|
|
59
|
+
return bindingPatternContains(pattern.left, name);
|
|
60
|
+
}
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
function checkNeeds(name, program, code) {
|
|
64
|
+
if (!code.includes(name)) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
let isBound = false;
|
|
68
|
+
let hasUsage = false;
|
|
69
|
+
for (const node of program.body) {
|
|
70
|
+
if (node.type === "ImportDeclaration") {
|
|
71
|
+
for (const specifier of node.specifiers) {
|
|
72
|
+
if (specifier.type === "ImportSpecifier") {
|
|
73
|
+
if (specifier.imported.type === "Identifier" && specifier.imported.name === name || specifier.local.name === name) {
|
|
74
|
+
isBound = true;
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
} else if (specifier.type === "ImportDefaultSpecifier") {
|
|
78
|
+
if (specifier.local.name === name) {
|
|
79
|
+
isBound = true;
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
} else if (specifier.type === "ImportNamespaceSpecifier") {
|
|
83
|
+
if (specifier.local.name === name) {
|
|
84
|
+
isBound = true;
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (node.type === "VariableDeclaration") {
|
|
91
|
+
if (bindingInDeclarators(name, node.declarations)) {
|
|
92
|
+
isBound = true;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (node.type === "FunctionDeclaration" && node.id?.name === name) {
|
|
96
|
+
isBound = true;
|
|
97
|
+
}
|
|
98
|
+
if (node.type === "ExportNamedDeclaration" && node.declaration) {
|
|
99
|
+
if (node.declaration.type === "VariableDeclaration") {
|
|
100
|
+
if (bindingInDeclarators(name, node.declaration.declarations)) {
|
|
101
|
+
isBound = true;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (isBound) {
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
new Visitor({
|
|
110
|
+
Identifier(node) {
|
|
111
|
+
if (node.name === name) {
|
|
112
|
+
hasUsage = true;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}).visit(program);
|
|
116
|
+
return hasUsage;
|
|
117
|
+
}
|
|
118
|
+
export {
|
|
119
|
+
applyAutoImports
|
|
120
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directory-named-import.d.ts","sourceRoot":"","sources":["../../src/build/directory-named-import.ts"],"names":[],"mappings":"AAiCA,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,GACf,MAAM,CAyBR"}
|