@cedarjs/internal 6.0.0-canary.2652 → 6.0.0-canary.2657

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.
@@ -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;AA0BtE,eAAO,MAAM,QAAQ,4DAIpB,CAAA;AAED,eAAO,MAAM,UAAU,4DAStB,CAAA;AAED,eAAO,MAAM,aAAa,qBAGzB,CAAA;AAkMD,eAAO,MAAM,gBAAgB,iHAyD5B,CAAA;AAcD,wBAAsB,aAAa,CACjC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CAoDf"}
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/build/api.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAgB,YAAY,EAAe,MAAM,SAAS,CAAA;AA2CtE,eAAO,MAAM,QAAQ,4DAIpB,CAAA;AAED,eAAO,MAAM,UAAU,4DAStB,CAAA;AAED,eAAO,MAAM,aAAa,qBAGzB,CAAA;AAiQD,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
@@ -2,22 +2,35 @@ import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import { build, context } from "esbuild";
4
4
  import { build as viteBuild, normalizePath } from "vite";
5
+ import tsPathsMod from "vite-tsconfig-paths";
6
+ const tsconfigPaths = (
7
+ // @ts-expect-error – .default only exists at runtime in CJS double-wrap
8
+ // interop
9
+ tsPathsMod.default?.default || tsPathsMod.default || tsPathsMod
10
+ );
5
11
  import {
6
12
  getApiSideBabelPlugins,
7
13
  transformWithBabel
8
14
  } from "@cedarjs/babel-config";
9
- import { getConfig, getPaths, projectSideIsEsm } from "@cedarjs/project-config";
15
+ import {
16
+ getConfig,
17
+ getPaths,
18
+ projectSideIsEsm,
19
+ resolveFile
20
+ } from "@cedarjs/project-config";
10
21
  import { findApiFiles } from "../files.js";
11
22
  import {
12
23
  applyGqlormInject,
13
24
  applyGraphqlOptionsExtract
14
25
  } from "./api-graphql-transforms.js";
15
26
  import { applyAutoImports } from "./auto-import.js";
27
+ import { applyDirectoryNamedImport } from "./directory-named-import.js";
16
28
  import { cedarApiGraphqlPlugin } from "./esbuild-plugin-api-graphql.js";
17
29
  import { applyOtelWrapping } from "./esbuild-plugin-cedar-otel-wrapping.js";
18
30
  import { applyHandlerAlsWrapping } from "./esbuild-plugin-handler-als-wrapping.js";
19
31
  import { applyImportDir } from "./import-dir.js";
20
32
  import { applySrcAlias } from "./src-alias.js";
33
+ import { applyTsconfigPaths } from "./tsconfig-paths.js";
21
34
  let BUILD_CTX = null;
22
35
  const buildApi = async () => {
23
36
  BUILD_CTX?.dispose();
@@ -49,6 +62,12 @@ const runCedarBabelTransformsPlugin = {
49
62
  path.relative(build2.initialOptions.absWorkingDir + "/src", args.path)
50
63
  )
51
64
  );
65
+ fileContents = applyTsconfigPaths(
66
+ fileContents,
67
+ args.path,
68
+ getPaths().api.base
69
+ );
70
+ fileContents = applyDirectoryNamedImport(fileContents, args.path);
52
71
  fileContents = applyAutoImports(fileContents);
53
72
  fileContents = applyImportDir(fileContents, args.path)?.code ?? fileContents;
54
73
  const transformedCode = await transformWithBabel(
@@ -101,6 +120,36 @@ function createImportDirVitePlugin() {
101
120
  }
102
121
  };
103
122
  }
123
+ function createDirectoryNamedImportVitePlugin() {
124
+ return {
125
+ name: "cedar-internal-directory-named-import",
126
+ enforce: "pre",
127
+ resolveId(id, importer) {
128
+ if (!id.startsWith(".") || !importer) {
129
+ return null;
130
+ }
131
+ if (importer.includes("node_modules")) {
132
+ return null;
133
+ }
134
+ const absolutePath = path.resolve(path.dirname(importer), id);
135
+ if (resolveFile(absolutePath)) {
136
+ return null;
137
+ }
138
+ const indexPath = path.join(absolutePath, "index");
139
+ const resolvedIndex = resolveFile(indexPath);
140
+ if (resolvedIndex) {
141
+ return normalizePath(resolvedIndex);
142
+ }
143
+ const basename = path.basename(absolutePath);
144
+ const dirNamedPath = path.join(absolutePath, basename);
145
+ const resolvedDirNamed = resolveFile(dirNamedPath);
146
+ if (resolvedDirNamed) {
147
+ return normalizePath(resolvedDirNamed);
148
+ }
149
+ return null;
150
+ }
151
+ };
152
+ }
104
153
  function createCedarViteApiPlugin() {
105
154
  const cedarConfig = getConfig();
106
155
  const isEsm = projectSideIsEsm("api");
@@ -202,7 +251,15 @@ const buildApiWithVite = async () => {
202
251
  // are expanded before Babel sees the code. The Babel import-dir plugin is
203
252
  // disabled for forVite:true builds; this inline Vite plugin is its
204
253
  // replacement for this code path (both CJS and ESM output via Rollup).
205
- plugins: [createImportDirVitePlugin(), createCedarViteApiPlugin()]
254
+ // tsconfigPaths resolves user-defined tsconfig.json `paths` aliases; it
255
+ // replaces the Babel module-resolver's tsconfig-paths handling for this
256
+ // code path.
257
+ plugins: [
258
+ tsconfigPaths(),
259
+ createImportDirVitePlugin(),
260
+ createDirectoryNamedImportVitePlugin(),
261
+ createCedarViteApiPlugin()
262
+ ]
206
263
  });
207
264
  };
208
265
  const transpileApi = async (files) => {
@@ -0,0 +1,2 @@
1
+ export declare function applyDirectoryNamedImport(code: string, filePath: string): string;
2
+ //# sourceMappingURL=directory-named-import.d.ts.map
@@ -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"}
@@ -0,0 +1,26 @@
1
+ import path from "node:path";
2
+ import { importStatementPath, resolveFile } from "@cedarjs/project-config";
3
+ const RELATIVE_IMPORT_RE = /^(\s*(?:import|export)\s[^'"]*?)(['"])(\.\.?\/[^'"]+)\2/gm;
4
+ function applyDirectoryNamedImport(code, filePath) {
5
+ const fileDir = path.dirname(filePath);
6
+ return code.replace(
7
+ RELATIVE_IMPORT_RE,
8
+ (match, prefix, quote, importPath) => {
9
+ const absolutePath = path.join(fileDir, importPath);
10
+ if (resolveFile(absolutePath)) {
11
+ return match;
12
+ }
13
+ if (resolveFile(path.join(absolutePath, "index"))) {
14
+ return `${prefix}${quote}${importStatementPath(importPath + "/index")}${quote}`;
15
+ }
16
+ const basename = path.basename(absolutePath);
17
+ if (resolveFile(path.join(absolutePath, basename))) {
18
+ return `${prefix}${quote}${importStatementPath(importPath + "/" + basename)}${quote}`;
19
+ }
20
+ return match;
21
+ }
22
+ );
23
+ }
24
+ export {
25
+ applyDirectoryNamedImport
26
+ };
@@ -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;AAkB1C,eAAO,MAAM,qBAAqB;;iBAEnB,WAAW;CA4EzB,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;AAoB1C,eAAO,MAAM,qBAAqB;;iBAEnB,WAAW;CA0FzB,CAAA"}
@@ -10,10 +10,12 @@ import {
10
10
  applyGraphqlOptionsExtract
11
11
  } from "./api-graphql-transforms.js";
12
12
  import { applyAutoImports } from "./auto-import.js";
13
+ import { applyDirectoryNamedImport } from "./directory-named-import.js";
13
14
  import { applyOtelWrapping } from "./esbuild-plugin-cedar-otel-wrapping.js";
14
15
  import { applyHandlerAlsWrapping } from "./esbuild-plugin-handler-als-wrapping.js";
15
16
  import { applyImportDir } from "./import-dir.js";
16
17
  import { applySrcAlias } from "./src-alias.js";
18
+ import { applyTsconfigPaths } from "./tsconfig-paths.js";
17
19
  const cedarApiGraphqlPlugin = {
18
20
  name: "cedar-api-graphql",
19
21
  setup(build) {
@@ -26,6 +28,12 @@ const cedarApiGraphqlPlugin = {
26
28
  path.relative(build.initialOptions.absWorkingDir + "/src", args.path)
27
29
  )
28
30
  );
31
+ fileContents = applyTsconfigPaths(
32
+ fileContents,
33
+ args.path,
34
+ getPaths().api.base
35
+ );
36
+ fileContents = applyDirectoryNamedImport(fileContents, args.path);
29
37
  fileContents = applyGraphqlOptionsExtract(fileContents) ?? fileContents;
30
38
  fileContents = applyGqlormInject(fileContents, args.path, ".js") ?? fileContents;
31
39
  fileContents = applyAutoImports(fileContents);
@@ -0,0 +1,2 @@
1
+ export declare function applyTsconfigPaths(code: string, filePath: string, cwd: string): string;
2
+ //# sourceMappingURL=tsconfig-paths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tsconfig-paths.d.ts","sourceRoot":"","sources":["../../src/build/tsconfig-paths.ts"],"names":[],"mappings":"AA8FA,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,MAAM,GACV,MAAM,CAyCR"}
@@ -0,0 +1,72 @@
1
+ import path from "node:path";
2
+ import { createMatchPath, loadConfig } from "tsconfig-paths";
3
+ import { importStatementPath, resolveFile } from "@cedarjs/project-config";
4
+ const EXCLUDED_PATH_KEY_RE = /src\/|\$api\/\*|types\/\*|@cedarjs\/.*/;
5
+ const RESOLVE_EXTENSIONS = [
6
+ ".js",
7
+ ".tsx",
8
+ ".ts",
9
+ ".jsx",
10
+ ".mjs",
11
+ ".mts",
12
+ ".cjs"
13
+ ];
14
+ const BARE_IMPORT_RE = /\bfrom\s+(['"])([^'"./][^'"]*)\1/g;
15
+ function getMatchPath(cwd) {
16
+ const config = loadConfig(cwd);
17
+ if (config.resultType === "failed") {
18
+ return null;
19
+ }
20
+ const paths = Object.fromEntries(
21
+ Object.entries(config.paths).filter(
22
+ ([key]) => !EXCLUDED_PATH_KEY_RE.test(key)
23
+ )
24
+ );
25
+ if (Object.keys(paths).length === 0) {
26
+ return null;
27
+ }
28
+ return createMatchPath(config.absoluteBaseUrl, paths);
29
+ }
30
+ function resolveToFile(candidate) {
31
+ if (resolveFile(candidate)) {
32
+ return candidate;
33
+ }
34
+ if (resolveFile(path.join(candidate, "index"))) {
35
+ return path.join(candidate, "index");
36
+ }
37
+ const basename = path.basename(candidate);
38
+ if (resolveFile(path.join(candidate, basename))) {
39
+ return path.join(candidate, basename);
40
+ }
41
+ return null;
42
+ }
43
+ function applyTsconfigPaths(code, filePath, cwd) {
44
+ const matchPath = getMatchPath(cwd);
45
+ if (!matchPath) {
46
+ return code;
47
+ }
48
+ return code.replace(
49
+ BARE_IMPORT_RE,
50
+ (full, quote, importPath) => {
51
+ const basename = importPath.split("/").pop();
52
+ const rawMatch = matchPath(importPath, void 0, void 0, RESOLVE_EXTENSIONS) ?? (basename && matchPath(
53
+ `${importPath}/${basename}`,
54
+ void 0,
55
+ void 0,
56
+ RESOLVE_EXTENSIONS
57
+ ));
58
+ const resolved = rawMatch && resolveToFile(rawMatch);
59
+ if (!resolved) {
60
+ return full;
61
+ }
62
+ const relativePath = path.relative(path.dirname(filePath), resolved);
63
+ const formatted = importStatementPath(
64
+ relativePath.startsWith(".") ? relativePath : "./" + relativePath
65
+ );
66
+ return `from ${quote}${formatted}${quote}`;
67
+ }
68
+ );
69
+ }
70
+ export {
71
+ applyTsconfigPaths
72
+ };
@@ -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;AA0BtE,eAAO,MAAM,QAAQ,4DAIpB,CAAA;AAED,eAAO,MAAM,UAAU,4DAStB,CAAA;AAED,eAAO,MAAM,aAAa,qBAGzB,CAAA;AAkMD,eAAO,MAAM,gBAAgB,iHAyD5B,CAAA;AAcD,wBAAsB,aAAa,CACjC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CAoDf"}
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/build/api.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAgB,YAAY,EAAe,MAAM,SAAS,CAAA;AA2CtE,eAAO,MAAM,QAAQ,4DAIpB,CAAA;AAED,eAAO,MAAM,UAAU,4DAStB,CAAA;AAED,eAAO,MAAM,aAAa,qBAGzB,CAAA;AAiQD,eAAO,MAAM,gBAAgB,iHAiE5B,CAAA;AAcD,wBAAsB,aAAa,CACjC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CAoDf"}
@@ -39,16 +39,24 @@ var import_node_fs = __toESM(require("node:fs"), 1);
39
39
  var import_node_path = __toESM(require("node:path"), 1);
40
40
  var import_esbuild = require("esbuild");
41
41
  var import_vite = require("vite");
42
+ var import_vite_tsconfig_paths = __toESM(require("vite-tsconfig-paths"), 1);
42
43
  var import_babel_config = require("@cedarjs/babel-config");
43
44
  var import_project_config = require("@cedarjs/project-config");
44
45
  var import_files = require("../files.js");
45
46
  var import_api_graphql_transforms = require("./api-graphql-transforms.js");
46
47
  var import_auto_import = require("./auto-import.js");
48
+ var import_directory_named_import = require("./directory-named-import.js");
47
49
  var import_esbuild_plugin_api_graphql = require("./esbuild-plugin-api-graphql.js");
48
50
  var import_esbuild_plugin_cedar_otel_wrapping = require("./esbuild-plugin-cedar-otel-wrapping.js");
49
51
  var import_esbuild_plugin_handler_als_wrapping = require("./esbuild-plugin-handler-als-wrapping.js");
50
52
  var import_import_dir = require("./import-dir.js");
51
53
  var import_src_alias = require("./src-alias.js");
54
+ var import_tsconfig_paths = require("./tsconfig-paths.js");
55
+ const tsconfigPaths = (
56
+ // @ts-expect-error – .default only exists at runtime in CJS double-wrap
57
+ // interop
58
+ import_vite_tsconfig_paths.default.default?.default || import_vite_tsconfig_paths.default.default || import_vite_tsconfig_paths.default
59
+ );
52
60
  let BUILD_CTX = null;
53
61
  const buildApi = async () => {
54
62
  BUILD_CTX?.dispose();
@@ -80,6 +88,12 @@ const runCedarBabelTransformsPlugin = {
80
88
  import_node_path.default.relative(build2.initialOptions.absWorkingDir + "/src", args.path)
81
89
  )
82
90
  );
91
+ fileContents = (0, import_tsconfig_paths.applyTsconfigPaths)(
92
+ fileContents,
93
+ args.path,
94
+ (0, import_project_config.getPaths)().api.base
95
+ );
96
+ fileContents = (0, import_directory_named_import.applyDirectoryNamedImport)(fileContents, args.path);
83
97
  fileContents = (0, import_auto_import.applyAutoImports)(fileContents);
84
98
  fileContents = (0, import_import_dir.applyImportDir)(fileContents, args.path)?.code ?? fileContents;
85
99
  const transformedCode = await (0, import_babel_config.transformWithBabel)(
@@ -132,6 +146,36 @@ function createImportDirVitePlugin() {
132
146
  }
133
147
  };
134
148
  }
149
+ function createDirectoryNamedImportVitePlugin() {
150
+ return {
151
+ name: "cedar-internal-directory-named-import",
152
+ enforce: "pre",
153
+ resolveId(id, importer) {
154
+ if (!id.startsWith(".") || !importer) {
155
+ return null;
156
+ }
157
+ if (importer.includes("node_modules")) {
158
+ return null;
159
+ }
160
+ const absolutePath = import_node_path.default.resolve(import_node_path.default.dirname(importer), id);
161
+ if ((0, import_project_config.resolveFile)(absolutePath)) {
162
+ return null;
163
+ }
164
+ const indexPath = import_node_path.default.join(absolutePath, "index");
165
+ const resolvedIndex = (0, import_project_config.resolveFile)(indexPath);
166
+ if (resolvedIndex) {
167
+ return (0, import_vite.normalizePath)(resolvedIndex);
168
+ }
169
+ const basename = import_node_path.default.basename(absolutePath);
170
+ const dirNamedPath = import_node_path.default.join(absolutePath, basename);
171
+ const resolvedDirNamed = (0, import_project_config.resolveFile)(dirNamedPath);
172
+ if (resolvedDirNamed) {
173
+ return (0, import_vite.normalizePath)(resolvedDirNamed);
174
+ }
175
+ return null;
176
+ }
177
+ };
178
+ }
135
179
  function createCedarViteApiPlugin() {
136
180
  const cedarConfig = (0, import_project_config.getConfig)();
137
181
  const isEsm = (0, import_project_config.projectSideIsEsm)("api");
@@ -233,7 +277,15 @@ const buildApiWithVite = async () => {
233
277
  // are expanded before Babel sees the code. The Babel import-dir plugin is
234
278
  // disabled for forVite:true builds; this inline Vite plugin is its
235
279
  // replacement for this code path (both CJS and ESM output via Rollup).
236
- plugins: [createImportDirVitePlugin(), createCedarViteApiPlugin()]
280
+ // tsconfigPaths resolves user-defined tsconfig.json `paths` aliases; it
281
+ // replaces the Babel module-resolver's tsconfig-paths handling for this
282
+ // code path.
283
+ plugins: [
284
+ tsconfigPaths(),
285
+ createImportDirVitePlugin(),
286
+ createDirectoryNamedImportVitePlugin(),
287
+ createCedarViteApiPlugin()
288
+ ]
237
289
  });
238
290
  };
239
291
  const transpileApi = async (files) => {
@@ -0,0 +1,2 @@
1
+ export declare function applyDirectoryNamedImport(code: string, filePath: string): string;
2
+ //# sourceMappingURL=directory-named-import.d.ts.map
@@ -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"}
@@ -0,0 +1,60 @@
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 directory_named_import_exports = {};
30
+ __export(directory_named_import_exports, {
31
+ applyDirectoryNamedImport: () => applyDirectoryNamedImport
32
+ });
33
+ module.exports = __toCommonJS(directory_named_import_exports);
34
+ var import_node_path = __toESM(require("node:path"), 1);
35
+ var import_project_config = require("@cedarjs/project-config");
36
+ const RELATIVE_IMPORT_RE = /^(\s*(?:import|export)\s[^'"]*?)(['"])(\.\.?\/[^'"]+)\2/gm;
37
+ function applyDirectoryNamedImport(code, filePath) {
38
+ const fileDir = import_node_path.default.dirname(filePath);
39
+ return code.replace(
40
+ RELATIVE_IMPORT_RE,
41
+ (match, prefix, quote, importPath) => {
42
+ const absolutePath = import_node_path.default.join(fileDir, importPath);
43
+ if ((0, import_project_config.resolveFile)(absolutePath)) {
44
+ return match;
45
+ }
46
+ if ((0, import_project_config.resolveFile)(import_node_path.default.join(absolutePath, "index"))) {
47
+ return `${prefix}${quote}${(0, import_project_config.importStatementPath)(importPath + "/index")}${quote}`;
48
+ }
49
+ const basename = import_node_path.default.basename(absolutePath);
50
+ if ((0, import_project_config.resolveFile)(import_node_path.default.join(absolutePath, basename))) {
51
+ return `${prefix}${quote}${(0, import_project_config.importStatementPath)(importPath + "/" + basename)}${quote}`;
52
+ }
53
+ return match;
54
+ }
55
+ );
56
+ }
57
+ // Annotate the CommonJS export names for ESM import in node:
58
+ 0 && (module.exports = {
59
+ applyDirectoryNamedImport
60
+ });
@@ -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;AAkB1C,eAAO,MAAM,qBAAqB;;iBAEnB,WAAW;CA4EzB,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;AAoB1C,eAAO,MAAM,qBAAqB;;iBAEnB,WAAW;CA0FzB,CAAA"}
@@ -37,10 +37,12 @@ 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
39
  var import_auto_import = require("./auto-import.js");
40
+ var import_directory_named_import = require("./directory-named-import.js");
40
41
  var import_esbuild_plugin_cedar_otel_wrapping = require("./esbuild-plugin-cedar-otel-wrapping.js");
41
42
  var import_esbuild_plugin_handler_als_wrapping = require("./esbuild-plugin-handler-als-wrapping.js");
42
43
  var import_import_dir = require("./import-dir.js");
43
44
  var import_src_alias = require("./src-alias.js");
45
+ var import_tsconfig_paths = require("./tsconfig-paths.js");
44
46
  const cedarApiGraphqlPlugin = {
45
47
  name: "cedar-api-graphql",
46
48
  setup(build) {
@@ -53,6 +55,12 @@ const cedarApiGraphqlPlugin = {
53
55
  import_node_path.default.relative(build.initialOptions.absWorkingDir + "/src", args.path)
54
56
  )
55
57
  );
58
+ fileContents = (0, import_tsconfig_paths.applyTsconfigPaths)(
59
+ fileContents,
60
+ args.path,
61
+ (0, import_project_config.getPaths)().api.base
62
+ );
63
+ fileContents = (0, import_directory_named_import.applyDirectoryNamedImport)(fileContents, args.path);
56
64
  fileContents = (0, import_api_graphql_transforms.applyGraphqlOptionsExtract)(fileContents) ?? fileContents;
57
65
  fileContents = (0, import_api_graphql_transforms.applyGqlormInject)(fileContents, args.path, ".js") ?? fileContents;
58
66
  fileContents = (0, import_auto_import.applyAutoImports)(fileContents);
@@ -0,0 +1,2 @@
1
+ export declare function applyTsconfigPaths(code: string, filePath: string, cwd: string): string;
2
+ //# sourceMappingURL=tsconfig-paths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tsconfig-paths.d.ts","sourceRoot":"","sources":["../../../src/build/tsconfig-paths.ts"],"names":[],"mappings":"AA8FA,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,MAAM,GACV,MAAM,CAyCR"}
@@ -0,0 +1,106 @@
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 tsconfig_paths_exports = {};
30
+ __export(tsconfig_paths_exports, {
31
+ applyTsconfigPaths: () => applyTsconfigPaths
32
+ });
33
+ module.exports = __toCommonJS(tsconfig_paths_exports);
34
+ var import_node_path = __toESM(require("node:path"), 1);
35
+ var import_tsconfig_paths = require("tsconfig-paths");
36
+ var import_project_config = require("@cedarjs/project-config");
37
+ const EXCLUDED_PATH_KEY_RE = /src\/|\$api\/\*|types\/\*|@cedarjs\/.*/;
38
+ const RESOLVE_EXTENSIONS = [
39
+ ".js",
40
+ ".tsx",
41
+ ".ts",
42
+ ".jsx",
43
+ ".mjs",
44
+ ".mts",
45
+ ".cjs"
46
+ ];
47
+ const BARE_IMPORT_RE = /\bfrom\s+(['"])([^'"./][^'"]*)\1/g;
48
+ function getMatchPath(cwd) {
49
+ const config = (0, import_tsconfig_paths.loadConfig)(cwd);
50
+ if (config.resultType === "failed") {
51
+ return null;
52
+ }
53
+ const paths = Object.fromEntries(
54
+ Object.entries(config.paths).filter(
55
+ ([key]) => !EXCLUDED_PATH_KEY_RE.test(key)
56
+ )
57
+ );
58
+ if (Object.keys(paths).length === 0) {
59
+ return null;
60
+ }
61
+ return (0, import_tsconfig_paths.createMatchPath)(config.absoluteBaseUrl, paths);
62
+ }
63
+ function resolveToFile(candidate) {
64
+ if ((0, import_project_config.resolveFile)(candidate)) {
65
+ return candidate;
66
+ }
67
+ if ((0, import_project_config.resolveFile)(import_node_path.default.join(candidate, "index"))) {
68
+ return import_node_path.default.join(candidate, "index");
69
+ }
70
+ const basename = import_node_path.default.basename(candidate);
71
+ if ((0, import_project_config.resolveFile)(import_node_path.default.join(candidate, basename))) {
72
+ return import_node_path.default.join(candidate, basename);
73
+ }
74
+ return null;
75
+ }
76
+ function applyTsconfigPaths(code, filePath, cwd) {
77
+ const matchPath = getMatchPath(cwd);
78
+ if (!matchPath) {
79
+ return code;
80
+ }
81
+ return code.replace(
82
+ BARE_IMPORT_RE,
83
+ (full, quote, importPath) => {
84
+ const basename = importPath.split("/").pop();
85
+ const rawMatch = matchPath(importPath, void 0, void 0, RESOLVE_EXTENSIONS) ?? (basename && matchPath(
86
+ `${importPath}/${basename}`,
87
+ void 0,
88
+ void 0,
89
+ RESOLVE_EXTENSIONS
90
+ ));
91
+ const resolved = rawMatch && resolveToFile(rawMatch);
92
+ if (!resolved) {
93
+ return full;
94
+ }
95
+ const relativePath = import_node_path.default.relative(import_node_path.default.dirname(filePath), resolved);
96
+ const formatted = (0, import_project_config.importStatementPath)(
97
+ relativePath.startsWith(".") ? relativePath : "./" + relativePath
98
+ );
99
+ return `from ${quote}${formatted}${quote}`;
100
+ }
101
+ );
102
+ }
103
+ // Annotate the CommonJS export names for ESM import in node:
104
+ 0 && (module.exports = {
105
+ applyTsconfigPaths
106
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/internal",
3
- "version": "6.0.0-canary.2652",
3
+ "version": "6.0.0-canary.2657",
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.2652",
173
- "@cedarjs/cli-helpers": "6.0.0-canary.2652",
174
- "@cedarjs/graphql-server": "6.0.0-canary.2652",
175
- "@cedarjs/project-config": "6.0.0-canary.2652",
176
- "@cedarjs/router": "6.0.0-canary.2652",
177
- "@cedarjs/structure": "6.0.0-canary.2652",
178
- "@cedarjs/utils": "6.0.0-canary.2652",
172
+ "@cedarjs/babel-config": "6.0.0-canary.2657",
173
+ "@cedarjs/cli-helpers": "6.0.0-canary.2657",
174
+ "@cedarjs/graphql-server": "6.0.0-canary.2657",
175
+ "@cedarjs/project-config": "6.0.0-canary.2657",
176
+ "@cedarjs/router": "6.0.0-canary.2657",
177
+ "@cedarjs/structure": "6.0.0-canary.2657",
178
+ "@cedarjs/utils": "6.0.0-canary.2657",
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",
@@ -213,12 +213,14 @@
213
213
  "systeminformation": "5.31.7",
214
214
  "termi-link": "1.1.0",
215
215
  "ts-node": "10.9.2",
216
+ "tsconfig-paths": "4.2.0",
216
217
  "typescript": "5.9.3",
217
- "vite": "7.3.5"
218
+ "vite": "7.3.5",
219
+ "vite-tsconfig-paths": "^6.1.1"
218
220
  },
219
221
  "devDependencies": {
220
222
  "@arethetypeswrong/cli": "0.18.5",
221
- "@cedarjs/framework-tools": "6.0.0-canary.2652",
223
+ "@cedarjs/framework-tools": "6.0.0-canary.2657",
222
224
  "concurrently": "9.2.1",
223
225
  "graphql-tag": "2.12.6",
224
226
  "publint": "0.3.21",