@cedarjs/internal 6.0.0-canary.2626 → 6.0.0-canary.2628
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/build/api.d.ts.map +1 -1
- package/dist/build/api.js +5 -0
- 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/esbuild-plugin-api-graphql.d.ts.map +1 -1
- package/dist/build/esbuild-plugin-api-graphql.js +3 -0
- package/dist/cjs/build/api.d.ts.map +1 -1
- package/dist/cjs/build/api.js +5 -0
- package/dist/cjs/build/auto-import.d.ts +10 -0
- package/dist/cjs/build/auto-import.d.ts.map +1 -0
- package/dist/cjs/build/auto-import.js +144 -0
- package/dist/cjs/build/esbuild-plugin-api-graphql.d.ts.map +1 -1
- package/dist/cjs/build/esbuild-plugin-api-graphql.js +3 -0
- package/package.json +9 -9
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;AAyBtE,eAAO,MAAM,QAAQ,4DAIpB,CAAA;AAED,eAAO,MAAM,UAAU,4DAStB,CAAA;AAED,eAAO,MAAM,aAAa,qBAGzB,CAAA;AA0JD,eAAO,MAAM,gBAAgB,iHAqD5B,CAAA;AAcD,wBAAsB,aAAa,CACjC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CAoDf"}
|
package/dist/build/api.js
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
applyGqlormInject,
|
|
13
13
|
applyGraphqlOptionsExtract
|
|
14
14
|
} from "./api-graphql-transforms.js";
|
|
15
|
+
import { applyAutoImports } from "./auto-import.js";
|
|
15
16
|
import { cedarApiGraphqlPlugin } from "./esbuild-plugin-api-graphql.js";
|
|
16
17
|
import { applyOtelWrapping } from "./esbuild-plugin-cedar-otel-wrapping.js";
|
|
17
18
|
import { applyHandlerAlsWrapping } from "./esbuild-plugin-handler-als-wrapping.js";
|
|
@@ -47,10 +48,12 @@ const runCedarBabelTransformsPlugin = {
|
|
|
47
48
|
path.relative(build2.initialOptions.absWorkingDir + "/src", args.path)
|
|
48
49
|
)
|
|
49
50
|
);
|
|
51
|
+
fileContents = applyAutoImports(fileContents);
|
|
50
52
|
const transformedCode = await transformWithBabel(
|
|
51
53
|
fileContents,
|
|
52
54
|
args.path,
|
|
53
55
|
getApiSideBabelPlugins({
|
|
56
|
+
forVite: true,
|
|
54
57
|
projectIsEsm: projectSideIsEsm("api")
|
|
55
58
|
})
|
|
56
59
|
);
|
|
@@ -100,6 +103,7 @@ function createCedarViteApiPlugin() {
|
|
|
100
103
|
sourceCode,
|
|
101
104
|
path.dirname(path.relative(cedarPaths.api.src, id))
|
|
102
105
|
);
|
|
106
|
+
sourceCode = applyAutoImports(sourceCode);
|
|
103
107
|
if (normalizedId.endsWith("/graphql.ts") || normalizedId.endsWith("/graphql.js")) {
|
|
104
108
|
sourceCode = applyGraphqlOptionsExtract(sourceCode) ?? sourceCode;
|
|
105
109
|
sourceCode = applyGqlormInject(sourceCode, id) ?? sourceCode;
|
|
@@ -108,6 +112,7 @@ function createCedarViteApiPlugin() {
|
|
|
108
112
|
sourceCode,
|
|
109
113
|
id,
|
|
110
114
|
getApiSideBabelPlugins({
|
|
115
|
+
forVite: true,
|
|
111
116
|
projectIsEsm: isEsm
|
|
112
117
|
}),
|
|
113
118
|
true
|
|
@@ -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
|
+
};
|
|
@@ -1 +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;
|
|
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;AAiB1C,eAAO,MAAM,qBAAqB;;iBAEnB,WAAW;CAsEzB,CAAA"}
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
applyGqlormInject,
|
|
10
10
|
applyGraphqlOptionsExtract
|
|
11
11
|
} from "./api-graphql-transforms.js";
|
|
12
|
+
import { applyAutoImports } from "./auto-import.js";
|
|
12
13
|
import { applyOtelWrapping } from "./esbuild-plugin-cedar-otel-wrapping.js";
|
|
13
14
|
import { applyHandlerAlsWrapping } from "./esbuild-plugin-handler-als-wrapping.js";
|
|
14
15
|
import { applySrcAlias } from "./src-alias.js";
|
|
@@ -26,10 +27,12 @@ const cedarApiGraphqlPlugin = {
|
|
|
26
27
|
);
|
|
27
28
|
fileContents = applyGraphqlOptionsExtract(fileContents) ?? fileContents;
|
|
28
29
|
fileContents = applyGqlormInject(fileContents, args.path, ".js") ?? fileContents;
|
|
30
|
+
fileContents = applyAutoImports(fileContents);
|
|
29
31
|
const transformedCode = await transformWithBabel(
|
|
30
32
|
fileContents,
|
|
31
33
|
args.path,
|
|
32
34
|
getApiSideBabelPlugins({
|
|
35
|
+
forVite: true,
|
|
33
36
|
projectIsEsm: projectSideIsEsm("api")
|
|
34
37
|
})
|
|
35
38
|
);
|
|
@@ -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;AAyBtE,eAAO,MAAM,QAAQ,4DAIpB,CAAA;AAED,eAAO,MAAM,UAAU,4DAStB,CAAA;AAED,eAAO,MAAM,aAAa,qBAGzB,CAAA;AA0JD,eAAO,MAAM,gBAAgB,iHAqD5B,CAAA;AAcD,wBAAsB,aAAa,CACjC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CAoDf"}
|
package/dist/cjs/build/api.js
CHANGED
|
@@ -43,6 +43,7 @@ var import_babel_config = require("@cedarjs/babel-config");
|
|
|
43
43
|
var import_project_config = require("@cedarjs/project-config");
|
|
44
44
|
var import_files = require("../files.js");
|
|
45
45
|
var import_api_graphql_transforms = require("./api-graphql-transforms.js");
|
|
46
|
+
var import_auto_import = require("./auto-import.js");
|
|
46
47
|
var import_esbuild_plugin_api_graphql = require("./esbuild-plugin-api-graphql.js");
|
|
47
48
|
var import_esbuild_plugin_cedar_otel_wrapping = require("./esbuild-plugin-cedar-otel-wrapping.js");
|
|
48
49
|
var import_esbuild_plugin_handler_als_wrapping = require("./esbuild-plugin-handler-als-wrapping.js");
|
|
@@ -78,10 +79,12 @@ const runCedarBabelTransformsPlugin = {
|
|
|
78
79
|
import_node_path.default.relative(build2.initialOptions.absWorkingDir + "/src", args.path)
|
|
79
80
|
)
|
|
80
81
|
);
|
|
82
|
+
fileContents = (0, import_auto_import.applyAutoImports)(fileContents);
|
|
81
83
|
const transformedCode = await (0, import_babel_config.transformWithBabel)(
|
|
82
84
|
fileContents,
|
|
83
85
|
args.path,
|
|
84
86
|
(0, import_babel_config.getApiSideBabelPlugins)({
|
|
87
|
+
forVite: true,
|
|
85
88
|
projectIsEsm: (0, import_project_config.projectSideIsEsm)("api")
|
|
86
89
|
})
|
|
87
90
|
);
|
|
@@ -131,6 +134,7 @@ function createCedarViteApiPlugin() {
|
|
|
131
134
|
sourceCode,
|
|
132
135
|
import_node_path.default.dirname(import_node_path.default.relative(cedarPaths.api.src, id))
|
|
133
136
|
);
|
|
137
|
+
sourceCode = (0, import_auto_import.applyAutoImports)(sourceCode);
|
|
134
138
|
if (normalizedId.endsWith("/graphql.ts") || normalizedId.endsWith("/graphql.js")) {
|
|
135
139
|
sourceCode = (0, import_api_graphql_transforms.applyGraphqlOptionsExtract)(sourceCode) ?? sourceCode;
|
|
136
140
|
sourceCode = (0, import_api_graphql_transforms.applyGqlormInject)(sourceCode, id) ?? sourceCode;
|
|
@@ -139,6 +143,7 @@ function createCedarViteApiPlugin() {
|
|
|
139
143
|
sourceCode,
|
|
140
144
|
id,
|
|
141
145
|
(0, import_babel_config.getApiSideBabelPlugins)({
|
|
146
|
+
forVite: true,
|
|
142
147
|
projectIsEsm: isEsm
|
|
143
148
|
}),
|
|
144
149
|
true
|
|
@@ -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,144 @@
|
|
|
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 auto_import_exports = {};
|
|
20
|
+
__export(auto_import_exports, {
|
|
21
|
+
applyAutoImports: () => applyAutoImports
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(auto_import_exports);
|
|
24
|
+
var import_oxc_parser = require("oxc-parser");
|
|
25
|
+
function applyAutoImports(code) {
|
|
26
|
+
const result = (0, import_oxc_parser.parseSync)("temp.ts", code, {
|
|
27
|
+
lang: "ts",
|
|
28
|
+
sourceType: "module"
|
|
29
|
+
});
|
|
30
|
+
const needsGql = checkNeeds("gql", result.program, code);
|
|
31
|
+
const needsContext = checkNeeds("context", result.program, code);
|
|
32
|
+
let resultCode = code;
|
|
33
|
+
if (needsGql) {
|
|
34
|
+
resultCode = "import gql from 'graphql-tag'\n" + resultCode;
|
|
35
|
+
}
|
|
36
|
+
if (needsContext) {
|
|
37
|
+
resultCode = "import { context } from '@cedarjs/context'\n" + resultCode;
|
|
38
|
+
}
|
|
39
|
+
return resultCode;
|
|
40
|
+
}
|
|
41
|
+
function bindingInDeclarators(name, declarations) {
|
|
42
|
+
for (const decl of declarations) {
|
|
43
|
+
if (bindingPatternContains(decl.id, name)) {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
function bindingPatternContains(pattern, name) {
|
|
50
|
+
if (pattern.type === "Identifier") {
|
|
51
|
+
return pattern.name === name;
|
|
52
|
+
}
|
|
53
|
+
if (pattern.type === "ObjectPattern") {
|
|
54
|
+
for (const prop of pattern.properties) {
|
|
55
|
+
if (prop.type === "RestElement") {
|
|
56
|
+
if (bindingPatternContains(prop.argument, name)) {
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
} else {
|
|
60
|
+
if (bindingPatternContains(prop.value, name)) {
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
if (pattern.type === "ArrayPattern") {
|
|
68
|
+
for (const el of pattern.elements) {
|
|
69
|
+
if (el) {
|
|
70
|
+
if (el.type === "RestElement") {
|
|
71
|
+
if (bindingPatternContains(el.argument, name)) {
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
} else if (bindingPatternContains(el, name)) {
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
if (pattern.type === "AssignmentPattern") {
|
|
82
|
+
return bindingPatternContains(pattern.left, name);
|
|
83
|
+
}
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
function checkNeeds(name, program, code) {
|
|
87
|
+
if (!code.includes(name)) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
let isBound = false;
|
|
91
|
+
let hasUsage = false;
|
|
92
|
+
for (const node of program.body) {
|
|
93
|
+
if (node.type === "ImportDeclaration") {
|
|
94
|
+
for (const specifier of node.specifiers) {
|
|
95
|
+
if (specifier.type === "ImportSpecifier") {
|
|
96
|
+
if (specifier.imported.type === "Identifier" && specifier.imported.name === name || specifier.local.name === name) {
|
|
97
|
+
isBound = true;
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
} else if (specifier.type === "ImportDefaultSpecifier") {
|
|
101
|
+
if (specifier.local.name === name) {
|
|
102
|
+
isBound = true;
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
} else if (specifier.type === "ImportNamespaceSpecifier") {
|
|
106
|
+
if (specifier.local.name === name) {
|
|
107
|
+
isBound = true;
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
if (node.type === "VariableDeclaration") {
|
|
114
|
+
if (bindingInDeclarators(name, node.declarations)) {
|
|
115
|
+
isBound = true;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
if (node.type === "FunctionDeclaration" && node.id?.name === name) {
|
|
119
|
+
isBound = true;
|
|
120
|
+
}
|
|
121
|
+
if (node.type === "ExportNamedDeclaration" && node.declaration) {
|
|
122
|
+
if (node.declaration.type === "VariableDeclaration") {
|
|
123
|
+
if (bindingInDeclarators(name, node.declaration.declarations)) {
|
|
124
|
+
isBound = true;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (isBound) {
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
new import_oxc_parser.Visitor({
|
|
133
|
+
Identifier(node) {
|
|
134
|
+
if (node.name === name) {
|
|
135
|
+
hasUsage = true;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}).visit(program);
|
|
139
|
+
return hasUsage;
|
|
140
|
+
}
|
|
141
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
142
|
+
0 && (module.exports = {
|
|
143
|
+
applyAutoImports
|
|
144
|
+
});
|
|
@@ -1 +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;
|
|
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;AAiB1C,eAAO,MAAM,qBAAqB;;iBAEnB,WAAW;CAsEzB,CAAA"}
|
|
@@ -36,6 +36,7 @@ var import_node_path = __toESM(require("node:path"), 1);
|
|
|
36
36
|
var import_babel_config = require("@cedarjs/babel-config");
|
|
37
37
|
var import_project_config = require("@cedarjs/project-config");
|
|
38
38
|
var import_api_graphql_transforms = require("./api-graphql-transforms.js");
|
|
39
|
+
var import_auto_import = require("./auto-import.js");
|
|
39
40
|
var import_esbuild_plugin_cedar_otel_wrapping = require("./esbuild-plugin-cedar-otel-wrapping.js");
|
|
40
41
|
var import_esbuild_plugin_handler_als_wrapping = require("./esbuild-plugin-handler-als-wrapping.js");
|
|
41
42
|
var import_src_alias = require("./src-alias.js");
|
|
@@ -53,10 +54,12 @@ const cedarApiGraphqlPlugin = {
|
|
|
53
54
|
);
|
|
54
55
|
fileContents = (0, import_api_graphql_transforms.applyGraphqlOptionsExtract)(fileContents) ?? fileContents;
|
|
55
56
|
fileContents = (0, import_api_graphql_transforms.applyGqlormInject)(fileContents, args.path, ".js") ?? fileContents;
|
|
57
|
+
fileContents = (0, import_auto_import.applyAutoImports)(fileContents);
|
|
56
58
|
const transformedCode = await (0, import_babel_config.transformWithBabel)(
|
|
57
59
|
fileContents,
|
|
58
60
|
args.path,
|
|
59
61
|
(0, import_babel_config.getApiSideBabelPlugins)({
|
|
62
|
+
forVite: true,
|
|
60
63
|
projectIsEsm: (0, import_project_config.projectSideIsEsm)("api")
|
|
61
64
|
})
|
|
62
65
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/internal",
|
|
3
|
-
"version": "6.0.0-canary.
|
|
3
|
+
"version": "6.0.0-canary.2628",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/cedarjs/cedar.git",
|
|
@@ -169,13 +169,13 @@
|
|
|
169
169
|
"@babel/plugin-transform-react-jsx": "7.29.7",
|
|
170
170
|
"@babel/plugin-transform-typescript": "^7.26.8",
|
|
171
171
|
"@babel/traverse": "7.29.7",
|
|
172
|
-
"@cedarjs/babel-config": "6.0.0-canary.
|
|
173
|
-
"@cedarjs/cli-helpers": "6.0.0-canary.
|
|
174
|
-
"@cedarjs/graphql-server": "6.0.0-canary.
|
|
175
|
-
"@cedarjs/project-config": "6.0.0-canary.
|
|
176
|
-
"@cedarjs/router": "6.0.0-canary.
|
|
177
|
-
"@cedarjs/structure": "6.0.0-canary.
|
|
178
|
-
"@cedarjs/utils": "6.0.0-canary.
|
|
172
|
+
"@cedarjs/babel-config": "6.0.0-canary.2628",
|
|
173
|
+
"@cedarjs/cli-helpers": "6.0.0-canary.2628",
|
|
174
|
+
"@cedarjs/graphql-server": "6.0.0-canary.2628",
|
|
175
|
+
"@cedarjs/project-config": "6.0.0-canary.2628",
|
|
176
|
+
"@cedarjs/router": "6.0.0-canary.2628",
|
|
177
|
+
"@cedarjs/structure": "6.0.0-canary.2628",
|
|
178
|
+
"@cedarjs/utils": "6.0.0-canary.2628",
|
|
179
179
|
"@graphql-codegen/add": "6.0.1",
|
|
180
180
|
"@graphql-codegen/cli": "6.3.1",
|
|
181
181
|
"@graphql-codegen/client-preset": "5.3.0",
|
|
@@ -217,7 +217,7 @@
|
|
|
217
217
|
},
|
|
218
218
|
"devDependencies": {
|
|
219
219
|
"@arethetypeswrong/cli": "0.18.4",
|
|
220
|
-
"@cedarjs/framework-tools": "6.0.0-canary.
|
|
220
|
+
"@cedarjs/framework-tools": "6.0.0-canary.2628",
|
|
221
221
|
"concurrently": "9.2.1",
|
|
222
222
|
"graphql-tag": "2.12.6",
|
|
223
223
|
"publint": "0.3.21",
|