@cedarjs/internal 6.0.0-canary.2695 → 6.0.0-canary.2697
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 +86 -53
- package/dist/build/esbuild-plugin-api-graphql.d.ts.map +1 -1
- package/dist/build/esbuild-plugin-api-graphql.js +19 -13
- package/dist/cjs/build/api.d.ts.map +1 -1
- package/dist/cjs/build/api.js +84 -52
- package/dist/cjs/build/esbuild-plugin-api-graphql.d.ts.map +1 -1
- package/dist/cjs/build/esbuild-plugin-api-graphql.js +17 -12
- 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;AA4CtE,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;AAwVD,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,6 +1,7 @@
|
|
|
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";
|
|
5
6
|
import tsPathsMod from "vite-tsconfig-paths";
|
|
6
7
|
const tsconfigPaths = (
|
|
@@ -9,7 +10,8 @@ const tsconfigPaths = (
|
|
|
9
10
|
tsPathsMod.default?.default || tsPathsMod.default || tsPathsMod
|
|
10
11
|
);
|
|
11
12
|
import {
|
|
12
|
-
|
|
13
|
+
getApiSideBabelConfigPath,
|
|
14
|
+
getApiSideBabelPluginsForVite,
|
|
13
15
|
transformWithBabel
|
|
14
16
|
} from "@cedarjs/babel-config";
|
|
15
17
|
import {
|
|
@@ -73,40 +75,60 @@ const runCedarBabelTransformsPlugin = {
|
|
|
73
75
|
fileContents = applyDirectoryNamedImport(fileContents, args.path);
|
|
74
76
|
fileContents = applyAutoImports(fileContents);
|
|
75
77
|
fileContents = applyImportDir(fileContents, args.path)?.code ?? fileContents;
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
})
|
|
78
|
+
const normalizedPath = normalizePath(args.path);
|
|
79
|
+
const cedarPaths = getPaths();
|
|
80
|
+
const isEsm = projectSideIsEsm("api");
|
|
81
|
+
const apiBabelConfigPath = getApiSideBabelConfigPath();
|
|
82
|
+
const isJobsFile = normalizedPath.startsWith(
|
|
83
|
+
normalizePath(cedarPaths.api.jobs) + "/"
|
|
83
84
|
);
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
code = applyHandlerAlsWrapping(code, {
|
|
95
|
-
projectIsEsm: isEsm
|
|
96
|
-
}) ?? code;
|
|
97
|
-
}
|
|
98
|
-
if (normalizedPath.startsWith(normalizePath(cedarPaths.api.src) + "/")) {
|
|
99
|
-
code = applyOtelWrapping(code, args.path, cedarPaths.api.src) ?? code;
|
|
85
|
+
const useBabel = Boolean(apiBabelConfigPath) || isJobsFile;
|
|
86
|
+
let code = fileContents;
|
|
87
|
+
if (useBabel) {
|
|
88
|
+
const transformedCode = await transformWithBabel(
|
|
89
|
+
fileContents,
|
|
90
|
+
args.path,
|
|
91
|
+
getApiSideBabelPluginsForVite()
|
|
92
|
+
);
|
|
93
|
+
if (!transformedCode?.code) {
|
|
94
|
+
throw new Error(`Could not transform file: ${args.path}`);
|
|
100
95
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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;
|
|
105
109
|
}
|
|
106
|
-
|
|
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: useBabel ? "js" : getEsbuildLoader(args.path)
|
|
116
|
+
};
|
|
107
117
|
});
|
|
108
118
|
}
|
|
109
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
|
+
}
|
|
110
132
|
function createImportDirVitePlugin() {
|
|
111
133
|
return {
|
|
112
134
|
name: "cedar-internal-import-dir",
|
|
@@ -184,35 +206,46 @@ function createCedarViteApiPlugin() {
|
|
|
184
206
|
sourceCode = applyGraphqlOptionsExtract(sourceCode) ?? sourceCode;
|
|
185
207
|
sourceCode = applyGqlormInject(sourceCode, id) ?? sourceCode;
|
|
186
208
|
}
|
|
187
|
-
const
|
|
209
|
+
const apiBabelConfigPath = getApiSideBabelConfigPath();
|
|
210
|
+
const isJobsFile = normalizedId.startsWith(
|
|
211
|
+
normalizePath(cedarPaths.api.jobs) + "/"
|
|
212
|
+
);
|
|
213
|
+
const useBabel = Boolean(apiBabelConfigPath) || isJobsFile;
|
|
214
|
+
const transformedCode = useBabel ? await transformWithBabel(
|
|
188
215
|
sourceCode,
|
|
189
216
|
id,
|
|
190
|
-
|
|
191
|
-
forVite: true,
|
|
192
|
-
projectIsEsm: isEsm
|
|
193
|
-
}),
|
|
217
|
+
getApiSideBabelPluginsForVite(),
|
|
194
218
|
true
|
|
195
|
-
);
|
|
196
|
-
if (transformedCode?.code) {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
219
|
+
) : null;
|
|
220
|
+
if (useBabel && !transformedCode?.code) {
|
|
221
|
+
throw new Error(`Could not transform file: ${id}`);
|
|
222
|
+
}
|
|
223
|
+
let outputCode = transformedCode?.code ?? sourceCode;
|
|
224
|
+
if (cedarConfig.experimental?.opentelemetry?.enabled && cedarConfig.experimental?.opentelemetry?.wrapApi) {
|
|
225
|
+
outputCode = applyOtelWrapping(outputCode, id, cedarPaths.api.src) ?? outputCode;
|
|
226
|
+
}
|
|
227
|
+
if (isEsm) {
|
|
228
|
+
outputCode = applyEsmExtensions(outputCode, id);
|
|
229
|
+
}
|
|
230
|
+
const functionsDir = normalizePath(cedarPaths.api.functions);
|
|
231
|
+
if (normalizedId.startsWith(functionsDir + "/")) {
|
|
232
|
+
outputCode = applyHandlerAlsWrapping(outputCode, {
|
|
233
|
+
projectIsEsm: isEsm
|
|
234
|
+
}) ?? outputCode;
|
|
235
|
+
}
|
|
236
|
+
if (!transformedCode) {
|
|
237
|
+
if (outputCode === code) {
|
|
238
|
+
return null;
|
|
209
239
|
}
|
|
210
240
|
return {
|
|
211
|
-
code:
|
|
212
|
-
map:
|
|
241
|
+
code: outputCode,
|
|
242
|
+
map: new MagicString(code).generateMap({ hires: true })
|
|
213
243
|
};
|
|
214
244
|
}
|
|
215
|
-
|
|
245
|
+
return {
|
|
246
|
+
code: outputCode,
|
|
247
|
+
map: transformedCode.map ?? null
|
|
248
|
+
};
|
|
216
249
|
}
|
|
217
250
|
};
|
|
218
251
|
}
|
|
@@ -258,8 +291,8 @@ const buildApiWithVite = async () => {
|
|
|
258
291
|
},
|
|
259
292
|
// cedarImportDirPlugin must run before the Babel transform so glob imports
|
|
260
293
|
// are expanded before Babel sees the code. The Babel import-dir plugin is
|
|
261
|
-
//
|
|
262
|
-
// replacement for this code path (both CJS and ESM output via Rollup).
|
|
294
|
+
// not part of getApiSideBabelPluginsForVite(); this inline Vite plugin is
|
|
295
|
+
// its replacement for this code path (both CJS and ESM output via Rollup).
|
|
263
296
|
// tsconfigPaths resolves user-defined tsconfig.json `paths` aliases; it
|
|
264
297
|
// replaces the Babel module-resolver's tsconfig-paths handling for this
|
|
265
298
|
// code path.
|
|
@@ -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;AAsB1C,eAAO,MAAM,qBAAqB;;iBAEnB,WAAW;CA+GzB,CAAA"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import {
|
|
4
|
-
|
|
4
|
+
getApiSideBabelConfigPath,
|
|
5
|
+
getApiSideBabelPluginsForVite,
|
|
5
6
|
transformWithBabel
|
|
6
7
|
} from "@cedarjs/babel-config";
|
|
7
8
|
import { getConfig, getPaths, projectSideIsEsm } from "@cedarjs/project-config";
|
|
@@ -39,18 +40,19 @@ const cedarApiGraphqlPlugin = {
|
|
|
39
40
|
fileContents = applyGqlormInject(fileContents, args.path, ".js") ?? fileContents;
|
|
40
41
|
fileContents = applyAutoImports(fileContents);
|
|
41
42
|
fileContents = applyImportDir(fileContents, args.path)?.code ?? fileContents;
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
43
|
+
const apiBabelConfigPath = getApiSideBabelConfigPath();
|
|
44
|
+
let code = fileContents;
|
|
45
|
+
if (apiBabelConfigPath) {
|
|
46
|
+
const transformedCode = await transformWithBabel(
|
|
47
|
+
fileContents,
|
|
48
|
+
args.path,
|
|
49
|
+
getApiSideBabelPluginsForVite()
|
|
50
|
+
);
|
|
51
|
+
if (!transformedCode?.code) {
|
|
52
|
+
throw new Error(`Could not transform file: ${args.path}`);
|
|
53
|
+
}
|
|
54
|
+
code = transformedCode.code;
|
|
52
55
|
}
|
|
53
|
-
let code = transformedCode.code;
|
|
54
56
|
if (projectSideIsEsm("api")) {
|
|
55
57
|
code = applyEsmExtensions(code, args.path);
|
|
56
58
|
}
|
|
@@ -62,7 +64,11 @@ const cedarApiGraphqlPlugin = {
|
|
|
62
64
|
}) ?? code;
|
|
63
65
|
return {
|
|
64
66
|
contents: code,
|
|
65
|
-
|
|
67
|
+
// Babel output is always plain JS. Without Babel the contents are
|
|
68
|
+
// still TypeScript when the source file is graphql.ts, so pick the
|
|
69
|
+
// matching loader and let esbuild do the stripping. (The onLoad
|
|
70
|
+
// filter only matches .ts and .js files.)
|
|
71
|
+
loader: !apiBabelConfigPath && args.path.endsWith(".ts") ? "ts" : "js"
|
|
66
72
|
};
|
|
67
73
|
});
|
|
68
74
|
}
|
|
@@ -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;AA4CtE,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;AAwVD,eAAO,MAAM,gBAAgB,iHAiE5B,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
|
@@ -40,6 +40,7 @@ module.exports = __toCommonJS(api_exports);
|
|
|
40
40
|
var import_node_fs = __toESM(require("node:fs"), 1);
|
|
41
41
|
var import_node_path = __toESM(require("node:path"), 1);
|
|
42
42
|
var import_esbuild = require("esbuild");
|
|
43
|
+
var import_magic_string = __toESM(require("magic-string"), 1);
|
|
43
44
|
var import_vite = require("vite");
|
|
44
45
|
var import_vite_tsconfig_paths = __toESM(require("vite-tsconfig-paths"), 1);
|
|
45
46
|
var import_babel_config = require("@cedarjs/babel-config");
|
|
@@ -101,40 +102,60 @@ const runCedarBabelTransformsPlugin = {
|
|
|
101
102
|
fileContents = (0, import_directory_named_import.applyDirectoryNamedImport)(fileContents, args.path);
|
|
102
103
|
fileContents = (0, import_auto_import.applyAutoImports)(fileContents);
|
|
103
104
|
fileContents = (0, import_import_dir.applyImportDir)(fileContents, args.path)?.code ?? fileContents;
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
})
|
|
105
|
+
const normalizedPath = (0, import_vite.normalizePath)(args.path);
|
|
106
|
+
const cedarPaths = (0, import_project_config.getPaths)();
|
|
107
|
+
const isEsm = (0, import_project_config.projectSideIsEsm)("api");
|
|
108
|
+
const apiBabelConfigPath = (0, import_babel_config.getApiSideBabelConfigPath)();
|
|
109
|
+
const isJobsFile = normalizedPath.startsWith(
|
|
110
|
+
(0, import_vite.normalizePath)(cedarPaths.api.jobs) + "/"
|
|
111
111
|
);
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
code = (0, import_esbuild_plugin_handler_als_wrapping.applyHandlerAlsWrapping)(code, {
|
|
123
|
-
projectIsEsm: isEsm
|
|
124
|
-
}) ?? code;
|
|
125
|
-
}
|
|
126
|
-
if (normalizedPath.startsWith((0, import_vite.normalizePath)(cedarPaths.api.src) + "/")) {
|
|
127
|
-
code = (0, import_esbuild_plugin_cedar_otel_wrapping.applyOtelWrapping)(code, args.path, cedarPaths.api.src) ?? code;
|
|
112
|
+
const useBabel = Boolean(apiBabelConfigPath) || isJobsFile;
|
|
113
|
+
let code = fileContents;
|
|
114
|
+
if (useBabel) {
|
|
115
|
+
const transformedCode = await (0, import_babel_config.transformWithBabel)(
|
|
116
|
+
fileContents,
|
|
117
|
+
args.path,
|
|
118
|
+
(0, import_babel_config.getApiSideBabelPluginsForVite)()
|
|
119
|
+
);
|
|
120
|
+
if (!transformedCode?.code) {
|
|
121
|
+
throw new Error(`Could not transform file: ${args.path}`);
|
|
128
122
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
123
|
+
code = transformedCode.code;
|
|
124
|
+
}
|
|
125
|
+
if (isEsm) {
|
|
126
|
+
code = (0, import_esm_extensions.applyEsmExtensions)(code, args.path);
|
|
127
|
+
}
|
|
128
|
+
const functionsDir = (0, import_vite.normalizePath)(cedarPaths.api.functions);
|
|
129
|
+
if (normalizedPath.startsWith(functionsDir + "/")) {
|
|
130
|
+
code = (0, import_esbuild_plugin_handler_als_wrapping.applyHandlerAlsWrapping)(code, {
|
|
131
|
+
projectIsEsm: isEsm
|
|
132
|
+
}) ?? code;
|
|
133
|
+
}
|
|
134
|
+
if (normalizedPath.startsWith((0, import_vite.normalizePath)(cedarPaths.api.src) + "/")) {
|
|
135
|
+
code = (0, import_esbuild_plugin_cedar_otel_wrapping.applyOtelWrapping)(code, args.path, cedarPaths.api.src) ?? code;
|
|
133
136
|
}
|
|
134
|
-
|
|
137
|
+
return {
|
|
138
|
+
contents: code,
|
|
139
|
+
// Babel output is always plain JS. Without Babel the contents are
|
|
140
|
+
// still TypeScript/JSX, so pick the loader matching the file's
|
|
141
|
+
// extension and let esbuild do the stripping.
|
|
142
|
+
loader: useBabel ? "js" : getEsbuildLoader(args.path)
|
|
143
|
+
};
|
|
135
144
|
});
|
|
136
145
|
}
|
|
137
146
|
};
|
|
147
|
+
function getEsbuildLoader(filePath) {
|
|
148
|
+
switch (import_node_path.default.extname(filePath)) {
|
|
149
|
+
case ".ts":
|
|
150
|
+
return "ts";
|
|
151
|
+
case ".tsx":
|
|
152
|
+
return "tsx";
|
|
153
|
+
case ".jsx":
|
|
154
|
+
return "jsx";
|
|
155
|
+
default:
|
|
156
|
+
return "js";
|
|
157
|
+
}
|
|
158
|
+
}
|
|
138
159
|
function createImportDirVitePlugin() {
|
|
139
160
|
return {
|
|
140
161
|
name: "cedar-internal-import-dir",
|
|
@@ -212,35 +233,46 @@ function createCedarViteApiPlugin() {
|
|
|
212
233
|
sourceCode = (0, import_api_graphql_transforms.applyGraphqlOptionsExtract)(sourceCode) ?? sourceCode;
|
|
213
234
|
sourceCode = (0, import_api_graphql_transforms.applyGqlormInject)(sourceCode, id) ?? sourceCode;
|
|
214
235
|
}
|
|
215
|
-
const
|
|
236
|
+
const apiBabelConfigPath = (0, import_babel_config.getApiSideBabelConfigPath)();
|
|
237
|
+
const isJobsFile = normalizedId.startsWith(
|
|
238
|
+
(0, import_vite.normalizePath)(cedarPaths.api.jobs) + "/"
|
|
239
|
+
);
|
|
240
|
+
const useBabel = Boolean(apiBabelConfigPath) || isJobsFile;
|
|
241
|
+
const transformedCode = useBabel ? await (0, import_babel_config.transformWithBabel)(
|
|
216
242
|
sourceCode,
|
|
217
243
|
id,
|
|
218
|
-
(0, import_babel_config.
|
|
219
|
-
forVite: true,
|
|
220
|
-
projectIsEsm: isEsm
|
|
221
|
-
}),
|
|
244
|
+
(0, import_babel_config.getApiSideBabelPluginsForVite)(),
|
|
222
245
|
true
|
|
223
|
-
);
|
|
224
|
-
if (transformedCode?.code) {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
246
|
+
) : null;
|
|
247
|
+
if (useBabel && !transformedCode?.code) {
|
|
248
|
+
throw new Error(`Could not transform file: ${id}`);
|
|
249
|
+
}
|
|
250
|
+
let outputCode = transformedCode?.code ?? sourceCode;
|
|
251
|
+
if (cedarConfig.experimental?.opentelemetry?.enabled && cedarConfig.experimental?.opentelemetry?.wrapApi) {
|
|
252
|
+
outputCode = (0, import_esbuild_plugin_cedar_otel_wrapping.applyOtelWrapping)(outputCode, id, cedarPaths.api.src) ?? outputCode;
|
|
253
|
+
}
|
|
254
|
+
if (isEsm) {
|
|
255
|
+
outputCode = (0, import_esm_extensions.applyEsmExtensions)(outputCode, id);
|
|
256
|
+
}
|
|
257
|
+
const functionsDir = (0, import_vite.normalizePath)(cedarPaths.api.functions);
|
|
258
|
+
if (normalizedId.startsWith(functionsDir + "/")) {
|
|
259
|
+
outputCode = (0, import_esbuild_plugin_handler_als_wrapping.applyHandlerAlsWrapping)(outputCode, {
|
|
260
|
+
projectIsEsm: isEsm
|
|
261
|
+
}) ?? outputCode;
|
|
262
|
+
}
|
|
263
|
+
if (!transformedCode) {
|
|
264
|
+
if (outputCode === code) {
|
|
265
|
+
return null;
|
|
237
266
|
}
|
|
238
267
|
return {
|
|
239
|
-
code:
|
|
240
|
-
map:
|
|
268
|
+
code: outputCode,
|
|
269
|
+
map: new import_magic_string.default(code).generateMap({ hires: true })
|
|
241
270
|
};
|
|
242
271
|
}
|
|
243
|
-
|
|
272
|
+
return {
|
|
273
|
+
code: outputCode,
|
|
274
|
+
map: transformedCode.map ?? null
|
|
275
|
+
};
|
|
244
276
|
}
|
|
245
277
|
};
|
|
246
278
|
}
|
|
@@ -286,8 +318,8 @@ const buildApiWithVite = async () => {
|
|
|
286
318
|
},
|
|
287
319
|
// cedarImportDirPlugin must run before the Babel transform so glob imports
|
|
288
320
|
// are expanded before Babel sees the code. The Babel import-dir plugin is
|
|
289
|
-
//
|
|
290
|
-
// replacement for this code path (both CJS and ESM output via Rollup).
|
|
321
|
+
// not part of getApiSideBabelPluginsForVite(); this inline Vite plugin is
|
|
322
|
+
// its replacement for this code path (both CJS and ESM output via Rollup).
|
|
291
323
|
// tsconfigPaths resolves user-defined tsconfig.json `paths` aliases; it
|
|
292
324
|
// replaces the Babel module-resolver's tsconfig-paths handling for this
|
|
293
325
|
// code path.
|
|
@@ -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;AAsB1C,eAAO,MAAM,qBAAqB;;iBAEnB,WAAW;CA+GzB,CAAA"}
|
|
@@ -66,18 +66,19 @@ const cedarApiGraphqlPlugin = {
|
|
|
66
66
|
fileContents = (0, import_api_graphql_transforms.applyGqlormInject)(fileContents, args.path, ".js") ?? fileContents;
|
|
67
67
|
fileContents = (0, import_auto_import.applyAutoImports)(fileContents);
|
|
68
68
|
fileContents = (0, import_import_dir.applyImportDir)(fileContents, args.path)?.code ?? fileContents;
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
(0, import_babel_config.
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
69
|
+
const apiBabelConfigPath = (0, import_babel_config.getApiSideBabelConfigPath)();
|
|
70
|
+
let code = fileContents;
|
|
71
|
+
if (apiBabelConfigPath) {
|
|
72
|
+
const transformedCode = await (0, import_babel_config.transformWithBabel)(
|
|
73
|
+
fileContents,
|
|
74
|
+
args.path,
|
|
75
|
+
(0, import_babel_config.getApiSideBabelPluginsForVite)()
|
|
76
|
+
);
|
|
77
|
+
if (!transformedCode?.code) {
|
|
78
|
+
throw new Error(`Could not transform file: ${args.path}`);
|
|
79
|
+
}
|
|
80
|
+
code = transformedCode.code;
|
|
79
81
|
}
|
|
80
|
-
let code = transformedCode.code;
|
|
81
82
|
if ((0, import_project_config.projectSideIsEsm)("api")) {
|
|
82
83
|
code = (0, import_esm_extensions.applyEsmExtensions)(code, args.path);
|
|
83
84
|
}
|
|
@@ -89,7 +90,11 @@ const cedarApiGraphqlPlugin = {
|
|
|
89
90
|
}) ?? code;
|
|
90
91
|
return {
|
|
91
92
|
contents: code,
|
|
92
|
-
|
|
93
|
+
// Babel output is always plain JS. Without Babel the contents are
|
|
94
|
+
// still TypeScript when the source file is graphql.ts, so pick the
|
|
95
|
+
// matching loader and let esbuild do the stripping. (The onLoad
|
|
96
|
+
// filter only matches .ts and .js files.)
|
|
97
|
+
loader: !apiBabelConfigPath && args.path.endsWith(".ts") ? "ts" : "js"
|
|
93
98
|
};
|
|
94
99
|
});
|
|
95
100
|
}
|
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.2697",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/cedarjs/cedar.git",
|
|
@@ -179,13 +179,13 @@
|
|
|
179
179
|
"@babel/plugin-transform-react-jsx": "7.29.7",
|
|
180
180
|
"@babel/plugin-transform-typescript": "^7.26.8",
|
|
181
181
|
"@babel/traverse": "7.29.7",
|
|
182
|
-
"@cedarjs/babel-config": "6.0.0-canary.
|
|
183
|
-
"@cedarjs/cli-helpers": "6.0.0-canary.
|
|
184
|
-
"@cedarjs/graphql-server": "6.0.0-canary.
|
|
185
|
-
"@cedarjs/project-config": "6.0.0-canary.
|
|
186
|
-
"@cedarjs/router": "6.0.0-canary.
|
|
187
|
-
"@cedarjs/structure": "6.0.0-canary.
|
|
188
|
-
"@cedarjs/utils": "6.0.0-canary.
|
|
182
|
+
"@cedarjs/babel-config": "6.0.0-canary.2697",
|
|
183
|
+
"@cedarjs/cli-helpers": "6.0.0-canary.2697",
|
|
184
|
+
"@cedarjs/graphql-server": "6.0.0-canary.2697",
|
|
185
|
+
"@cedarjs/project-config": "6.0.0-canary.2697",
|
|
186
|
+
"@cedarjs/router": "6.0.0-canary.2697",
|
|
187
|
+
"@cedarjs/structure": "6.0.0-canary.2697",
|
|
188
|
+
"@cedarjs/utils": "6.0.0-canary.2697",
|
|
189
189
|
"@graphql-codegen/add": "6.0.1",
|
|
190
190
|
"@graphql-codegen/cli": "6.3.1",
|
|
191
191
|
"@graphql-codegen/client-preset": "5.3.0",
|
|
@@ -230,7 +230,7 @@
|
|
|
230
230
|
},
|
|
231
231
|
"devDependencies": {
|
|
232
232
|
"@arethetypeswrong/cli": "0.18.5",
|
|
233
|
-
"@cedarjs/framework-tools": "6.0.0-canary.
|
|
233
|
+
"@cedarjs/framework-tools": "6.0.0-canary.2697",
|
|
234
234
|
"concurrently": "9.2.1",
|
|
235
235
|
"graphql-tag": "2.12.6",
|
|
236
236
|
"publint": "0.3.21",
|