@cedarjs/internal 6.0.0-canary.2623 → 6.0.0-canary.2626
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 +12 -1
- package/dist/build/esbuild-plugin-api-graphql.d.ts.map +1 -1
- package/dist/build/esbuild-plugin-api-graphql.js +8 -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/cjs/build/api.d.ts.map +1 -1
- package/dist/cjs/build/api.js +12 -1
- package/dist/cjs/build/esbuild-plugin-api-graphql.d.ts.map +1 -1
- package/dist/cjs/build/esbuild-plugin-api-graphql.js +8 -0
- package/dist/cjs/build/src-alias.d.ts +14 -0
- package/dist/cjs/build/src-alias.d.ts.map +1 -0
- package/dist/cjs/build/src-alias.js +51 -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;AAwBtE,eAAO,MAAM,QAAQ,4DAIpB,CAAA;AAED,eAAO,MAAM,UAAU,4DAStB,CAAA;AAED,eAAO,MAAM,aAAa,qBAGzB,CAAA;AAqJD,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
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
import { cedarApiGraphqlPlugin } from "./esbuild-plugin-api-graphql.js";
|
|
16
16
|
import { applyOtelWrapping } from "./esbuild-plugin-cedar-otel-wrapping.js";
|
|
17
17
|
import { applyHandlerAlsWrapping } from "./esbuild-plugin-handler-als-wrapping.js";
|
|
18
|
+
import { applySrcAlias } from "./src-alias.js";
|
|
18
19
|
let BUILD_CTX = null;
|
|
19
20
|
const buildApi = async () => {
|
|
20
21
|
BUILD_CTX?.dispose();
|
|
@@ -39,7 +40,13 @@ const runCedarBabelTransformsPlugin = {
|
|
|
39
40
|
name: "cedar-esbuild-babel-transform",
|
|
40
41
|
setup(build2) {
|
|
41
42
|
build2.onLoad({ filter: /\.(js|ts|tsx|jsx)$/ }, async (args) => {
|
|
42
|
-
|
|
43
|
+
let fileContents = await fs.promises.readFile(args.path, "utf-8");
|
|
44
|
+
fileContents = applySrcAlias(
|
|
45
|
+
fileContents,
|
|
46
|
+
path.dirname(
|
|
47
|
+
path.relative(build2.initialOptions.absWorkingDir + "/src", args.path)
|
|
48
|
+
)
|
|
49
|
+
);
|
|
43
50
|
const transformedCode = await transformWithBabel(
|
|
44
51
|
fileContents,
|
|
45
52
|
args.path,
|
|
@@ -89,6 +96,10 @@ function createCedarViteApiPlugin() {
|
|
|
89
96
|
}
|
|
90
97
|
let sourceCode = code;
|
|
91
98
|
const normalizedId = normalizePath(id);
|
|
99
|
+
sourceCode = applySrcAlias(
|
|
100
|
+
sourceCode,
|
|
101
|
+
path.dirname(path.relative(cedarPaths.api.src, id))
|
|
102
|
+
);
|
|
92
103
|
if (normalizedId.endsWith("/graphql.ts") || normalizedId.endsWith("/graphql.js")) {
|
|
93
104
|
sourceCode = applyGraphqlOptionsExtract(sourceCode) ?? sourceCode;
|
|
94
105
|
sourceCode = applyGqlormInject(sourceCode, id) ?? sourceCode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"esbuild-plugin-api-graphql.d.ts","sourceRoot":"","sources":["../../src/build/esbuild-plugin-api-graphql.ts"],"names":[],"mappings":"
|
|
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;AAgB1C,eAAO,MAAM,qBAAqB;;iBAEnB,WAAW;CAkEzB,CAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
2
3
|
import {
|
|
3
4
|
getApiSideBabelPlugins,
|
|
4
5
|
transformWithBabel
|
|
@@ -10,12 +11,19 @@ import {
|
|
|
10
11
|
} from "./api-graphql-transforms.js";
|
|
11
12
|
import { applyOtelWrapping } from "./esbuild-plugin-cedar-otel-wrapping.js";
|
|
12
13
|
import { applyHandlerAlsWrapping } from "./esbuild-plugin-handler-als-wrapping.js";
|
|
14
|
+
import { applySrcAlias } from "./src-alias.js";
|
|
13
15
|
const cedarApiGraphqlPlugin = {
|
|
14
16
|
name: "cedar-api-graphql",
|
|
15
17
|
setup(build) {
|
|
16
18
|
build.onLoad({ filter: /[/\\]graphql\.(ts|js)$/ }, async (args) => {
|
|
17
19
|
const cedarConfig = getConfig();
|
|
18
20
|
let fileContents = await fs.promises.readFile(args.path, "utf-8");
|
|
21
|
+
fileContents = applySrcAlias(
|
|
22
|
+
fileContents,
|
|
23
|
+
path.dirname(
|
|
24
|
+
path.relative(build.initialOptions.absWorkingDir + "/src", args.path)
|
|
25
|
+
)
|
|
26
|
+
);
|
|
19
27
|
fileContents = applyGraphqlOptionsExtract(fileContents) ?? fileContents;
|
|
20
28
|
fileContents = applyGqlormInject(fileContents, args.path, ".js") ?? fileContents;
|
|
21
29
|
const transformedCode = await transformWithBabel(
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rewrites `src/` bare specifiers in source code to relative paths, so that the
|
|
3
|
+
* esbuild API build (with `bundle: false`) produces output files with
|
|
4
|
+
* resolvable import paths at runtime.
|
|
5
|
+
*
|
|
6
|
+
* This replaces the `babel-plugin-module-resolver` `src: './src'` alias for the
|
|
7
|
+
* esbuild build paths. It is a plain function called inline from the existing
|
|
8
|
+
* esbuild `onLoad` handlers — not an esbuild plugin itself.
|
|
9
|
+
*
|
|
10
|
+
* For a file at `api/src/functions/graphql.ts` importing `src/lib/db`, this
|
|
11
|
+
* rewrites it to `../lib/db`.
|
|
12
|
+
*/
|
|
13
|
+
export declare function applySrcAlias(code: string, fromDirRelativeToApiSrc: string): string;
|
|
14
|
+
//# sourceMappingURL=src-alias.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"src-alias.d.ts","sourceRoot":"","sources":["../../src/build/src-alias.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;GAWG;AAEH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,uBAAuB,EAAE,MAAM,GAC9B,MAAM,CAWR"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { importStatementPath } from "@cedarjs/project-config";
|
|
3
|
+
function applySrcAlias(code, fromDirRelativeToApiSrc) {
|
|
4
|
+
return code.replace(
|
|
5
|
+
/from\s+['"]src\/(.+?)['"]/g,
|
|
6
|
+
(_match, rest) => {
|
|
7
|
+
const target = path.relative(fromDirRelativeToApiSrc, rest);
|
|
8
|
+
const formatted = importStatementPath(
|
|
9
|
+
target.startsWith(".") ? target : "./" + target
|
|
10
|
+
);
|
|
11
|
+
return `from '${formatted}'`;
|
|
12
|
+
}
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
applySrcAlias
|
|
17
|
+
};
|
|
@@ -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;AAwBtE,eAAO,MAAM,QAAQ,4DAIpB,CAAA;AAED,eAAO,MAAM,UAAU,4DAStB,CAAA;AAED,eAAO,MAAM,aAAa,qBAGzB,CAAA;AAqJD,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
|
@@ -46,6 +46,7 @@ var import_api_graphql_transforms = require("./api-graphql-transforms.js");
|
|
|
46
46
|
var import_esbuild_plugin_api_graphql = require("./esbuild-plugin-api-graphql.js");
|
|
47
47
|
var import_esbuild_plugin_cedar_otel_wrapping = require("./esbuild-plugin-cedar-otel-wrapping.js");
|
|
48
48
|
var import_esbuild_plugin_handler_als_wrapping = require("./esbuild-plugin-handler-als-wrapping.js");
|
|
49
|
+
var import_src_alias = require("./src-alias.js");
|
|
49
50
|
let BUILD_CTX = null;
|
|
50
51
|
const buildApi = async () => {
|
|
51
52
|
BUILD_CTX?.dispose();
|
|
@@ -70,7 +71,13 @@ const runCedarBabelTransformsPlugin = {
|
|
|
70
71
|
name: "cedar-esbuild-babel-transform",
|
|
71
72
|
setup(build2) {
|
|
72
73
|
build2.onLoad({ filter: /\.(js|ts|tsx|jsx)$/ }, async (args) => {
|
|
73
|
-
|
|
74
|
+
let fileContents = await import_node_fs.default.promises.readFile(args.path, "utf-8");
|
|
75
|
+
fileContents = (0, import_src_alias.applySrcAlias)(
|
|
76
|
+
fileContents,
|
|
77
|
+
import_node_path.default.dirname(
|
|
78
|
+
import_node_path.default.relative(build2.initialOptions.absWorkingDir + "/src", args.path)
|
|
79
|
+
)
|
|
80
|
+
);
|
|
74
81
|
const transformedCode = await (0, import_babel_config.transformWithBabel)(
|
|
75
82
|
fileContents,
|
|
76
83
|
args.path,
|
|
@@ -120,6 +127,10 @@ function createCedarViteApiPlugin() {
|
|
|
120
127
|
}
|
|
121
128
|
let sourceCode = code;
|
|
122
129
|
const normalizedId = (0, import_vite.normalizePath)(id);
|
|
130
|
+
sourceCode = (0, import_src_alias.applySrcAlias)(
|
|
131
|
+
sourceCode,
|
|
132
|
+
import_node_path.default.dirname(import_node_path.default.relative(cedarPaths.api.src, id))
|
|
133
|
+
);
|
|
123
134
|
if (normalizedId.endsWith("/graphql.ts") || normalizedId.endsWith("/graphql.js")) {
|
|
124
135
|
sourceCode = (0, import_api_graphql_transforms.applyGraphqlOptionsExtract)(sourceCode) ?? sourceCode;
|
|
125
136
|
sourceCode = (0, import_api_graphql_transforms.applyGqlormInject)(sourceCode, id) ?? sourceCode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"esbuild-plugin-api-graphql.d.ts","sourceRoot":"","sources":["../../../src/build/esbuild-plugin-api-graphql.ts"],"names":[],"mappings":"
|
|
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;AAgB1C,eAAO,MAAM,qBAAqB;;iBAEnB,WAAW;CAkEzB,CAAA"}
|
|
@@ -32,17 +32,25 @@ __export(esbuild_plugin_api_graphql_exports, {
|
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(esbuild_plugin_api_graphql_exports);
|
|
34
34
|
var import_node_fs = __toESM(require("node:fs"), 1);
|
|
35
|
+
var import_node_path = __toESM(require("node:path"), 1);
|
|
35
36
|
var import_babel_config = require("@cedarjs/babel-config");
|
|
36
37
|
var import_project_config = require("@cedarjs/project-config");
|
|
37
38
|
var import_api_graphql_transforms = require("./api-graphql-transforms.js");
|
|
38
39
|
var import_esbuild_plugin_cedar_otel_wrapping = require("./esbuild-plugin-cedar-otel-wrapping.js");
|
|
39
40
|
var import_esbuild_plugin_handler_als_wrapping = require("./esbuild-plugin-handler-als-wrapping.js");
|
|
41
|
+
var import_src_alias = require("./src-alias.js");
|
|
40
42
|
const cedarApiGraphqlPlugin = {
|
|
41
43
|
name: "cedar-api-graphql",
|
|
42
44
|
setup(build) {
|
|
43
45
|
build.onLoad({ filter: /[/\\]graphql\.(ts|js)$/ }, async (args) => {
|
|
44
46
|
const cedarConfig = (0, import_project_config.getConfig)();
|
|
45
47
|
let fileContents = await import_node_fs.default.promises.readFile(args.path, "utf-8");
|
|
48
|
+
fileContents = (0, import_src_alias.applySrcAlias)(
|
|
49
|
+
fileContents,
|
|
50
|
+
import_node_path.default.dirname(
|
|
51
|
+
import_node_path.default.relative(build.initialOptions.absWorkingDir + "/src", args.path)
|
|
52
|
+
)
|
|
53
|
+
);
|
|
46
54
|
fileContents = (0, import_api_graphql_transforms.applyGraphqlOptionsExtract)(fileContents) ?? fileContents;
|
|
47
55
|
fileContents = (0, import_api_graphql_transforms.applyGqlormInject)(fileContents, args.path, ".js") ?? fileContents;
|
|
48
56
|
const transformedCode = await (0, import_babel_config.transformWithBabel)(
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rewrites `src/` bare specifiers in source code to relative paths, so that the
|
|
3
|
+
* esbuild API build (with `bundle: false`) produces output files with
|
|
4
|
+
* resolvable import paths at runtime.
|
|
5
|
+
*
|
|
6
|
+
* This replaces the `babel-plugin-module-resolver` `src: './src'` alias for the
|
|
7
|
+
* esbuild build paths. It is a plain function called inline from the existing
|
|
8
|
+
* esbuild `onLoad` handlers — not an esbuild plugin itself.
|
|
9
|
+
*
|
|
10
|
+
* For a file at `api/src/functions/graphql.ts` importing `src/lib/db`, this
|
|
11
|
+
* rewrites it to `../lib/db`.
|
|
12
|
+
*/
|
|
13
|
+
export declare function applySrcAlias(code: string, fromDirRelativeToApiSrc: string): string;
|
|
14
|
+
//# sourceMappingURL=src-alias.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"src-alias.d.ts","sourceRoot":"","sources":["../../../src/build/src-alias.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;GAWG;AAEH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,uBAAuB,EAAE,MAAM,GAC9B,MAAM,CAWR"}
|
|
@@ -0,0 +1,51 @@
|
|
|
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 src_alias_exports = {};
|
|
30
|
+
__export(src_alias_exports, {
|
|
31
|
+
applySrcAlias: () => applySrcAlias
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(src_alias_exports);
|
|
34
|
+
var import_node_path = __toESM(require("node:path"), 1);
|
|
35
|
+
var import_project_config = require("@cedarjs/project-config");
|
|
36
|
+
function applySrcAlias(code, fromDirRelativeToApiSrc) {
|
|
37
|
+
return code.replace(
|
|
38
|
+
/from\s+['"]src\/(.+?)['"]/g,
|
|
39
|
+
(_match, rest) => {
|
|
40
|
+
const target = import_node_path.default.relative(fromDirRelativeToApiSrc, rest);
|
|
41
|
+
const formatted = (0, import_project_config.importStatementPath)(
|
|
42
|
+
target.startsWith(".") ? target : "./" + target
|
|
43
|
+
);
|
|
44
|
+
return `from '${formatted}'`;
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
49
|
+
0 && (module.exports = {
|
|
50
|
+
applySrcAlias
|
|
51
|
+
});
|
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.2626",
|
|
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.2626",
|
|
173
|
+
"@cedarjs/cli-helpers": "6.0.0-canary.2626",
|
|
174
|
+
"@cedarjs/graphql-server": "6.0.0-canary.2626",
|
|
175
|
+
"@cedarjs/project-config": "6.0.0-canary.2626",
|
|
176
|
+
"@cedarjs/router": "6.0.0-canary.2626",
|
|
177
|
+
"@cedarjs/structure": "6.0.0-canary.2626",
|
|
178
|
+
"@cedarjs/utils": "6.0.0-canary.2626",
|
|
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.2626",
|
|
221
221
|
"concurrently": "9.2.1",
|
|
222
222
|
"graphql-tag": "2.12.6",
|
|
223
223
|
"publint": "0.3.21",
|