@cedarjs/internal 6.0.0-canary.2647 → 6.0.0-canary.2654

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;AAgCtE,eAAO,MAAM,QAAQ,4DAIpB,CAAA;AAED,eAAO,MAAM,UAAU,4DAStB,CAAA;AAED,eAAO,MAAM,aAAa,qBAGzB,CAAA;AAwPD,eAAO,MAAM,gBAAgB,iHA6D5B,CAAA;AAcD,wBAAsB,aAAa,CACjC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CAoDf"}
package/dist/build/api.js CHANGED
@@ -6,13 +6,19 @@ import {
6
6
  getApiSideBabelPlugins,
7
7
  transformWithBabel
8
8
  } from "@cedarjs/babel-config";
9
- import { getConfig, getPaths, projectSideIsEsm } from "@cedarjs/project-config";
9
+ import {
10
+ getConfig,
11
+ getPaths,
12
+ projectSideIsEsm,
13
+ resolveFile
14
+ } from "@cedarjs/project-config";
10
15
  import { findApiFiles } from "../files.js";
11
16
  import {
12
17
  applyGqlormInject,
13
18
  applyGraphqlOptionsExtract
14
19
  } from "./api-graphql-transforms.js";
15
20
  import { applyAutoImports } from "./auto-import.js";
21
+ import { applyDirectoryNamedImport } from "./directory-named-import.js";
16
22
  import { cedarApiGraphqlPlugin } from "./esbuild-plugin-api-graphql.js";
17
23
  import { applyOtelWrapping } from "./esbuild-plugin-cedar-otel-wrapping.js";
18
24
  import { applyHandlerAlsWrapping } from "./esbuild-plugin-handler-als-wrapping.js";
@@ -49,6 +55,7 @@ const runCedarBabelTransformsPlugin = {
49
55
  path.relative(build2.initialOptions.absWorkingDir + "/src", args.path)
50
56
  )
51
57
  );
58
+ fileContents = applyDirectoryNamedImport(fileContents, args.path);
52
59
  fileContents = applyAutoImports(fileContents);
53
60
  fileContents = applyImportDir(fileContents, args.path)?.code ?? fileContents;
54
61
  const transformedCode = await transformWithBabel(
@@ -101,6 +108,36 @@ function createImportDirVitePlugin() {
101
108
  }
102
109
  };
103
110
  }
111
+ function createDirectoryNamedImportVitePlugin() {
112
+ return {
113
+ name: "cedar-internal-directory-named-import",
114
+ enforce: "pre",
115
+ resolveId(id, importer) {
116
+ if (!id.startsWith(".") || !importer) {
117
+ return null;
118
+ }
119
+ if (importer.includes("node_modules")) {
120
+ return null;
121
+ }
122
+ const absolutePath = path.resolve(path.dirname(importer), id);
123
+ if (resolveFile(absolutePath)) {
124
+ return null;
125
+ }
126
+ const indexPath = path.join(absolutePath, "index");
127
+ const resolvedIndex = resolveFile(indexPath);
128
+ if (resolvedIndex) {
129
+ return normalizePath(resolvedIndex);
130
+ }
131
+ const basename = path.basename(absolutePath);
132
+ const dirNamedPath = path.join(absolutePath, basename);
133
+ const resolvedDirNamed = resolveFile(dirNamedPath);
134
+ if (resolvedDirNamed) {
135
+ return normalizePath(resolvedDirNamed);
136
+ }
137
+ return null;
138
+ }
139
+ };
140
+ }
104
141
  function createCedarViteApiPlugin() {
105
142
  const cedarConfig = getConfig();
106
143
  const isEsm = projectSideIsEsm("api");
@@ -202,7 +239,11 @@ const buildApiWithVite = async () => {
202
239
  // are expanded before Babel sees the code. The Babel import-dir plugin is
203
240
  // disabled for forVite:true builds; this inline Vite plugin is its
204
241
  // replacement for this code path (both CJS and ESM output via Rollup).
205
- plugins: [createImportDirVitePlugin(), createCedarViteApiPlugin()]
242
+ plugins: [
243
+ createImportDirVitePlugin(),
244
+ createDirectoryNamedImportVitePlugin(),
245
+ createCedarViteApiPlugin()
246
+ ]
206
247
  });
207
248
  };
208
249
  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;AAmB1C,eAAO,MAAM,qBAAqB;;iBAEnB,WAAW;CAgFzB,CAAA"}
@@ -10,6 +10,7 @@ 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";
@@ -26,6 +27,7 @@ const cedarApiGraphqlPlugin = {
26
27
  path.relative(build.initialOptions.absWorkingDir + "/src", args.path)
27
28
  )
28
29
  );
30
+ fileContents = applyDirectoryNamedImport(fileContents, args.path);
29
31
  fileContents = applyGraphqlOptionsExtract(fileContents) ?? fileContents;
30
32
  fileContents = applyGqlormInject(fileContents, args.path, ".js") ?? fileContents;
31
33
  fileContents = applyAutoImports(fileContents);
@@ -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;AAgCtE,eAAO,MAAM,QAAQ,4DAIpB,CAAA;AAED,eAAO,MAAM,UAAU,4DAStB,CAAA;AAED,eAAO,MAAM,aAAa,qBAGzB,CAAA;AAwPD,eAAO,MAAM,gBAAgB,iHA6D5B,CAAA;AAcD,wBAAsB,aAAa,CACjC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CAoDf"}
@@ -44,6 +44,7 @@ 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
46
  var import_auto_import = require("./auto-import.js");
47
+ var import_directory_named_import = require("./directory-named-import.js");
47
48
  var import_esbuild_plugin_api_graphql = require("./esbuild-plugin-api-graphql.js");
48
49
  var import_esbuild_plugin_cedar_otel_wrapping = require("./esbuild-plugin-cedar-otel-wrapping.js");
49
50
  var import_esbuild_plugin_handler_als_wrapping = require("./esbuild-plugin-handler-als-wrapping.js");
@@ -80,6 +81,7 @@ const runCedarBabelTransformsPlugin = {
80
81
  import_node_path.default.relative(build2.initialOptions.absWorkingDir + "/src", args.path)
81
82
  )
82
83
  );
84
+ fileContents = (0, import_directory_named_import.applyDirectoryNamedImport)(fileContents, args.path);
83
85
  fileContents = (0, import_auto_import.applyAutoImports)(fileContents);
84
86
  fileContents = (0, import_import_dir.applyImportDir)(fileContents, args.path)?.code ?? fileContents;
85
87
  const transformedCode = await (0, import_babel_config.transformWithBabel)(
@@ -132,6 +134,36 @@ function createImportDirVitePlugin() {
132
134
  }
133
135
  };
134
136
  }
137
+ function createDirectoryNamedImportVitePlugin() {
138
+ return {
139
+ name: "cedar-internal-directory-named-import",
140
+ enforce: "pre",
141
+ resolveId(id, importer) {
142
+ if (!id.startsWith(".") || !importer) {
143
+ return null;
144
+ }
145
+ if (importer.includes("node_modules")) {
146
+ return null;
147
+ }
148
+ const absolutePath = import_node_path.default.resolve(import_node_path.default.dirname(importer), id);
149
+ if ((0, import_project_config.resolveFile)(absolutePath)) {
150
+ return null;
151
+ }
152
+ const indexPath = import_node_path.default.join(absolutePath, "index");
153
+ const resolvedIndex = (0, import_project_config.resolveFile)(indexPath);
154
+ if (resolvedIndex) {
155
+ return (0, import_vite.normalizePath)(resolvedIndex);
156
+ }
157
+ const basename = import_node_path.default.basename(absolutePath);
158
+ const dirNamedPath = import_node_path.default.join(absolutePath, basename);
159
+ const resolvedDirNamed = (0, import_project_config.resolveFile)(dirNamedPath);
160
+ if (resolvedDirNamed) {
161
+ return (0, import_vite.normalizePath)(resolvedDirNamed);
162
+ }
163
+ return null;
164
+ }
165
+ };
166
+ }
135
167
  function createCedarViteApiPlugin() {
136
168
  const cedarConfig = (0, import_project_config.getConfig)();
137
169
  const isEsm = (0, import_project_config.projectSideIsEsm)("api");
@@ -233,7 +265,11 @@ const buildApiWithVite = async () => {
233
265
  // are expanded before Babel sees the code. The Babel import-dir plugin is
234
266
  // disabled for forVite:true builds; this inline Vite plugin is its
235
267
  // replacement for this code path (both CJS and ESM output via Rollup).
236
- plugins: [createImportDirVitePlugin(), createCedarViteApiPlugin()]
268
+ plugins: [
269
+ createImportDirVitePlugin(),
270
+ createDirectoryNamedImportVitePlugin(),
271
+ createCedarViteApiPlugin()
272
+ ]
237
273
  });
238
274
  };
239
275
  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;AAmB1C,eAAO,MAAM,qBAAqB;;iBAEnB,WAAW;CAgFzB,CAAA"}
@@ -37,6 +37,7 @@ 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");
@@ -53,6 +54,7 @@ const cedarApiGraphqlPlugin = {
53
54
  import_node_path.default.relative(build.initialOptions.absWorkingDir + "/src", args.path)
54
55
  )
55
56
  );
57
+ fileContents = (0, import_directory_named_import.applyDirectoryNamedImport)(fileContents, args.path);
56
58
  fileContents = (0, import_api_graphql_transforms.applyGraphqlOptionsExtract)(fileContents) ?? fileContents;
57
59
  fileContents = (0, import_api_graphql_transforms.applyGqlormInject)(fileContents, args.path, ".js") ?? fileContents;
58
60
  fileContents = (0, import_auto_import.applyAutoImports)(fileContents);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/internal",
3
- "version": "6.0.0-canary.2647",
3
+ "version": "6.0.0-canary.2654",
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.2647",
173
- "@cedarjs/cli-helpers": "6.0.0-canary.2647",
174
- "@cedarjs/graphql-server": "6.0.0-canary.2647",
175
- "@cedarjs/project-config": "6.0.0-canary.2647",
176
- "@cedarjs/router": "6.0.0-canary.2647",
177
- "@cedarjs/structure": "6.0.0-canary.2647",
178
- "@cedarjs/utils": "6.0.0-canary.2647",
172
+ "@cedarjs/babel-config": "6.0.0-canary.2654",
173
+ "@cedarjs/cli-helpers": "6.0.0-canary.2654",
174
+ "@cedarjs/graphql-server": "6.0.0-canary.2654",
175
+ "@cedarjs/project-config": "6.0.0-canary.2654",
176
+ "@cedarjs/router": "6.0.0-canary.2654",
177
+ "@cedarjs/structure": "6.0.0-canary.2654",
178
+ "@cedarjs/utils": "6.0.0-canary.2654",
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",
@@ -218,7 +218,7 @@
218
218
  },
219
219
  "devDependencies": {
220
220
  "@arethetypeswrong/cli": "0.18.5",
221
- "@cedarjs/framework-tools": "6.0.0-canary.2647",
221
+ "@cedarjs/framework-tools": "6.0.0-canary.2654",
222
222
  "concurrently": "9.2.1",
223
223
  "graphql-tag": "2.12.6",
224
224
  "publint": "0.3.21",