@cedarjs/babel-config 4.0.0 → 4.0.1-next.67
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/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAMhF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAMhF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAetD,eAAO,MAAM,YAAY,OAAO,CAAA;AAEhC,eAAO,MAAM,sBAAsB,GACjC;;CAAoC,KAqBf,gBAAgB,CAAC,SAAS,CAChD,CAAA;AAKD,MAAM,MAAM,UAAU,GAAG,WAAW,EAAE,CAAA;AACtC,KAAK,WAAW,GACZ,CAAC,YAAY,EAAE,aAAa,EAAE,SAAS,GAAG,MAAM,CAAC,GACjD,CAAC,YAAY,EAAE,aAAa,CAAC,CAAA;AAEjC,eAAO,MAAM,sBAAsB,GAAI;;;CAGjC,0FAiGL,CAAA;AAED,eAAO,MAAM,yBAAyB,0BAOrC,CAAA;AAED,eAAO,MAAM,wBAAwB,GAAI;;CAA6B,KA6BhD,gBAAgB,EACrC,CAAA;AAED,eAAO,MAAM,4BAA4B,GAAI;;CAA6B;;;;;;;CASzE,CAAA;AAGD,eAAO,MAAM,wBAAwB,GAAI,uBAGtC,mBAAwB,SAe1B,CAAA;AAED,eAAO,MAAM,kBAAkB,GAC7B,SAAS,MAAM,EACf,SAAS,gBAAgB,CAAC,SAAS,CAAC,0DAoBrC,CAAA"}
|
package/dist/api.js
CHANGED
|
@@ -44,6 +44,7 @@ var import_core = require("@babel/core");
|
|
|
44
44
|
var import_babel_plugin_module_resolver = require("babel-plugin-module-resolver");
|
|
45
45
|
var import_project_config = require("@cedarjs/project-config");
|
|
46
46
|
var import_common = require("./common.js");
|
|
47
|
+
var import_babel_plugin_cedar_gqlorm_inject = __toESM(require("./plugins/babel-plugin-cedar-gqlorm-inject.js"));
|
|
47
48
|
var import_babel_plugin_redwood_context_wrapping = __toESM(require("./plugins/babel-plugin-redwood-context-wrapping.js"));
|
|
48
49
|
var import_babel_plugin_redwood_directory_named_import = __toESM(require("./plugins/babel-plugin-redwood-directory-named-import.js"));
|
|
49
50
|
var import_babel_plugin_redwood_graphql_options_extract = __toESM(require("./plugins/babel-plugin-redwood-graphql-options-extract.js"));
|
|
@@ -166,7 +167,7 @@ const getApiSideBabelOverrides = ({ projectIsEsm = false } = {}) => {
|
|
|
166
167
|
{
|
|
167
168
|
// match */api/src/functions/graphql.js|ts
|
|
168
169
|
test: /.+api(?:[\\|/])src(?:[\\|/])functions(?:[\\|/])graphql\.(?:js|ts)$/,
|
|
169
|
-
plugins: [import_babel_plugin_redwood_graphql_options_extract.default]
|
|
170
|
+
plugins: [import_babel_plugin_redwood_graphql_options_extract.default, import_babel_plugin_cedar_gqlorm_inject.default]
|
|
170
171
|
},
|
|
171
172
|
// Apply context wrapping to all functions
|
|
172
173
|
{
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { PluginObj, types } from '@babel/core';
|
|
2
|
+
/**
|
|
3
|
+
* Babel plugin that injects the auto-generated gqlorm backend into
|
|
4
|
+
* `api/src/functions/graphql.ts` at build time.
|
|
5
|
+
*
|
|
6
|
+
* When `experimental.gqlorm.enabled = true` and `.cedar/gqlorm/backend.ts`
|
|
7
|
+
* exists, this plugin:
|
|
8
|
+
*
|
|
9
|
+
* 1. Adds imports at the top of graphql.ts:
|
|
10
|
+
* import * as __gqlorm_sdl__ from '../../../.cedar/gqlorm/backend'
|
|
11
|
+
* import { db as __gqlorm_db__ } from 'src/lib/db'
|
|
12
|
+
*
|
|
13
|
+
* 2. Inserts a statement immediately before the `createGraphQLHandler` call:
|
|
14
|
+
* sdls = {
|
|
15
|
+
* ...sdls,
|
|
16
|
+
* __gqlorm__: {
|
|
17
|
+
* schema: __gqlorm_sdl__.schema,
|
|
18
|
+
* resolvers: __gqlorm_sdl__.createGqlormResolvers(__gqlorm_db__),
|
|
19
|
+
* },
|
|
20
|
+
* }
|
|
21
|
+
*
|
|
22
|
+
* The `sdls` variable is already a `let` binding at this point because
|
|
23
|
+
* `babel-plugin-redwood-import-dir` transforms the glob import
|
|
24
|
+
* `import sdls from 'src/graphql/**\/*.sdl.{js,ts}'` into `let sdls = {}`.
|
|
25
|
+
*
|
|
26
|
+
* This plugin is a no-op when gqlorm is disabled or the backend file does
|
|
27
|
+
* not exist.
|
|
28
|
+
*/
|
|
29
|
+
export default function ({ types: t }: {
|
|
30
|
+
types: typeof types;
|
|
31
|
+
}): PluginObj;
|
|
32
|
+
//# sourceMappingURL=babel-plugin-cedar-gqlorm-inject.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"babel-plugin-cedar-gqlorm-inject.d.ts","sourceRoot":"","sources":["../../src/plugins/babel-plugin-cedar-gqlorm-inject.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAY,SAAS,EAAc,KAAK,EAAE,MAAM,aAAa,CAAA;AAIzE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,CAAC,OAAO,WAAW,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IAAE,KAAK,EAAE,OAAO,KAAK,CAAA;CAAE,GAAG,SAAS,CA8KzE"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var babel_plugin_cedar_gqlorm_inject_exports = {};
|
|
30
|
+
__export(babel_plugin_cedar_gqlorm_inject_exports, {
|
|
31
|
+
default: () => babel_plugin_cedar_gqlorm_inject_default
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(babel_plugin_cedar_gqlorm_inject_exports);
|
|
34
|
+
var import_node_fs = __toESM(require("node:fs"));
|
|
35
|
+
var import_node_path = __toESM(require("node:path"));
|
|
36
|
+
var import_project_config = require("@cedarjs/project-config");
|
|
37
|
+
function babel_plugin_cedar_gqlorm_inject_default({ types: t }) {
|
|
38
|
+
return {
|
|
39
|
+
name: "babel-plugin-cedar-gqlorm-inject",
|
|
40
|
+
visitor: {
|
|
41
|
+
Program(programPath, state) {
|
|
42
|
+
let config;
|
|
43
|
+
try {
|
|
44
|
+
config = (0, import_project_config.getConfig)();
|
|
45
|
+
} catch {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (!config.experimental?.gqlorm?.enabled) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
let paths;
|
|
52
|
+
try {
|
|
53
|
+
paths = (0, import_project_config.getPaths)();
|
|
54
|
+
} catch {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const backendPathWithoutExt = import_node_path.default.join(
|
|
58
|
+
paths.generated.base,
|
|
59
|
+
"gqlorm",
|
|
60
|
+
"backend"
|
|
61
|
+
);
|
|
62
|
+
const backendExists = import_node_fs.default.existsSync(backendPathWithoutExt + ".ts") || import_node_fs.default.existsSync(backendPathWithoutExt + ".js");
|
|
63
|
+
if (!backendExists) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const importNames = /* @__PURE__ */ new Set();
|
|
67
|
+
programPath.traverse({
|
|
68
|
+
ImportDeclaration(p) {
|
|
69
|
+
if (t.isStringLiteral(p.node.source, {
|
|
70
|
+
value: "@cedarjs/graphql-server"
|
|
71
|
+
})) {
|
|
72
|
+
for (const specifier of p.node.specifiers) {
|
|
73
|
+
if (t.isImportSpecifier(specifier) && t.isIdentifier(specifier.imported) && specifier.imported.name === "createGraphQLHandler") {
|
|
74
|
+
importNames.add(specifier.local.name);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
if (importNames.size === 0) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const callExpressionPaths = [];
|
|
84
|
+
programPath.traverse({
|
|
85
|
+
CallExpression(p) {
|
|
86
|
+
if (t.isIdentifier(p.node.callee) && importNames.has(p.node.callee.name)) {
|
|
87
|
+
callExpressionPaths.push(p);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
if (callExpressionPaths.length === 0) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const callExpressionPath = callExpressionPaths[0];
|
|
95
|
+
const statementParent = callExpressionPath.getStatementParent();
|
|
96
|
+
if (!statementParent) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
const filename = state.file.opts.filename;
|
|
100
|
+
if (!filename) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const relPath = import_node_path.default.relative(import_node_path.default.dirname(filename), backendPathWithoutExt).replace(/\\/g, "/") + ".ts";
|
|
104
|
+
const importSdl = t.importDeclaration(
|
|
105
|
+
[t.importNamespaceSpecifier(t.identifier("__gqlorm_sdl__"))],
|
|
106
|
+
t.stringLiteral(relPath)
|
|
107
|
+
);
|
|
108
|
+
const importDb = t.importDeclaration(
|
|
109
|
+
[
|
|
110
|
+
t.importSpecifier(
|
|
111
|
+
t.identifier("__gqlorm_db__"),
|
|
112
|
+
t.identifier("db")
|
|
113
|
+
)
|
|
114
|
+
],
|
|
115
|
+
t.stringLiteral("src/lib/db")
|
|
116
|
+
);
|
|
117
|
+
programPath.unshiftContainer("body", [importDb, importSdl]);
|
|
118
|
+
const sdlsMutation = t.expressionStatement(
|
|
119
|
+
t.callExpression(
|
|
120
|
+
t.memberExpression(t.identifier("Object"), t.identifier("assign")),
|
|
121
|
+
[
|
|
122
|
+
t.identifier("sdls"),
|
|
123
|
+
t.objectExpression([
|
|
124
|
+
t.objectProperty(
|
|
125
|
+
t.identifier("__gqlorm__"),
|
|
126
|
+
t.objectExpression([
|
|
127
|
+
t.objectProperty(
|
|
128
|
+
t.identifier("schema"),
|
|
129
|
+
t.memberExpression(
|
|
130
|
+
t.identifier("__gqlorm_sdl__"),
|
|
131
|
+
t.identifier("schema")
|
|
132
|
+
)
|
|
133
|
+
),
|
|
134
|
+
t.objectProperty(
|
|
135
|
+
t.identifier("resolvers"),
|
|
136
|
+
t.callExpression(
|
|
137
|
+
t.memberExpression(
|
|
138
|
+
t.identifier("__gqlorm_sdl__"),
|
|
139
|
+
t.identifier("createGqlormResolvers")
|
|
140
|
+
),
|
|
141
|
+
[t.identifier("__gqlorm_db__")]
|
|
142
|
+
)
|
|
143
|
+
)
|
|
144
|
+
])
|
|
145
|
+
)
|
|
146
|
+
])
|
|
147
|
+
]
|
|
148
|
+
)
|
|
149
|
+
);
|
|
150
|
+
statementParent.insertBefore(sdlsMutation);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/babel-config",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.1-next.67+ad97a60c79",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/cedarjs/cedar.git",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@babel/preset-typescript": "7.28.5",
|
|
33
33
|
"@babel/register": "7.28.6",
|
|
34
34
|
"@babel/traverse": "7.29.0",
|
|
35
|
-
"@cedarjs/project-config": "4.0.
|
|
35
|
+
"@cedarjs/project-config": "4.0.1-next.67+ad97a60c79",
|
|
36
36
|
"babel-plugin-auto-import": "1.1.0",
|
|
37
37
|
"babel-plugin-graphql-tag": "3.3.0",
|
|
38
38
|
"babel-plugin-module-resolver": "5.0.3",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"typescript": "5.9.3"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@cedarjs/framework-tools": "
|
|
44
|
+
"@cedarjs/framework-tools": "4.0.1-next.67",
|
|
45
45
|
"@types/babel-plugin-tester": "11.0.0",
|
|
46
46
|
"@types/babel__core": "7.20.5",
|
|
47
47
|
"@types/babel__register": "7.17.3",
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"publishConfig": {
|
|
57
57
|
"access": "public"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "ad97a60c793c21b3263b4178e339d89406f7a7a3"
|
|
60
60
|
}
|