@cedarjs/babel-config 5.0.3 → 5.0.4-next.167

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.
Files changed (33) hide show
  1. package/dist/api.d.ts +42 -10
  2. package/dist/api.d.ts.map +1 -1
  3. package/dist/api.js +84 -111
  4. package/dist/common.d.ts +2 -10
  5. package/dist/common.d.ts.map +1 -1
  6. package/dist/common.js +20 -75
  7. package/dist/index.d.ts +3 -3
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +28 -48
  10. package/dist/plugins/{babel-plugin-redwood-context-wrapping.d.ts → babel-plugin-handler-als-wrapping.d.ts} +1 -1
  11. package/dist/plugins/babel-plugin-handler-als-wrapping.d.ts.map +1 -0
  12. package/dist/plugins/{babel-plugin-redwood-context-wrapping.js → babel-plugin-handler-als-wrapping.js} +19 -39
  13. package/dist/plugins/babel-plugin-redwood-directory-named-import.js +9 -39
  14. package/dist/plugins/babel-plugin-redwood-import-dir.js +10 -40
  15. package/dist/plugins/babel-plugin-redwood-job-path-injector.js +7 -37
  16. package/dist/plugins/babel-plugin-redwood-mock-cell-data.d.ts.map +1 -1
  17. package/dist/plugins/babel-plugin-redwood-mock-cell-data.js +19 -52
  18. package/dist/plugins/babel-plugin-redwood-remove-dev-fatal-error-page.js +3 -23
  19. package/dist/plugins/babel-plugin-redwood-routes-auto-loader.js +27 -51
  20. package/dist/web.d.ts.map +1 -1
  21. package/dist/web.js +48 -71
  22. package/package.json +7 -7
  23. package/dist/plugins/babel-plugin-cedar-gqlorm-inject.d.ts +0 -32
  24. package/dist/plugins/babel-plugin-cedar-gqlorm-inject.d.ts.map +0 -1
  25. package/dist/plugins/babel-plugin-cedar-gqlorm-inject.js +0 -154
  26. package/dist/plugins/babel-plugin-cedar-graphql-options-extract.d.ts +0 -5
  27. package/dist/plugins/babel-plugin-cedar-graphql-options-extract.d.ts.map +0 -1
  28. package/dist/plugins/babel-plugin-cedar-graphql-options-extract.js +0 -88
  29. package/dist/plugins/babel-plugin-redwood-context-wrapping.d.ts.map +0 -1
  30. package/dist/plugins/babel-plugin-redwood-otel-wrapping.d.ts +0 -5
  31. package/dist/plugins/babel-plugin-redwood-otel-wrapping.d.ts.map +0 -1
  32. package/dist/plugins/babel-plugin-redwood-otel-wrapping.js +0 -329
  33. package/dist/plugins/prettier.config.js +0 -28
@@ -1,62 +1,35 @@
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_redwood_routes_auto_loader_exports = {};
30
- __export(babel_plugin_redwood_routes_auto_loader_exports, {
31
- default: () => babel_plugin_redwood_routes_auto_loader_default
32
- });
33
- module.exports = __toCommonJS(babel_plugin_redwood_routes_auto_loader_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");
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import {
4
+ ensurePosixPath,
5
+ getPaths,
6
+ importStatementPath,
7
+ processPagesDir,
8
+ resolveFile
9
+ } from "@cedarjs/project-config";
37
10
  const getPathRelativeToSrc = (maybeAbsolutePath) => {
38
11
  if (maybeAbsolutePath.startsWith("src/")) {
39
- const basePath = import_node_path.default.join((0, import_project_config.getPaths)().web.base, maybeAbsolutePath);
40
- const resolved = (0, import_project_config.resolveFile)(basePath) || (0, import_project_config.resolveFile)(import_node_path.default.join(basePath, "index")) || (0, import_project_config.resolveFile)(import_node_path.default.join(basePath, import_node_path.default.basename(basePath)));
12
+ const basePath = path.join(getPaths().web.base, maybeAbsolutePath);
13
+ const resolved = resolveFile(basePath) || resolveFile(path.join(basePath, "index")) || resolveFile(path.join(basePath, path.basename(basePath)));
41
14
  if (resolved) {
42
15
  const withoutExt = resolved.replace(/\.[^/.]+$/, "");
43
- return "./" + import_node_path.default.relative((0, import_project_config.getPaths)().web.src, withoutExt);
16
+ return "./" + path.relative(getPaths().web.src, withoutExt);
44
17
  }
45
18
  return "./" + maybeAbsolutePath.slice("src/".length);
46
19
  }
47
- if (!import_node_path.default.isAbsolute(maybeAbsolutePath)) {
20
+ if (!path.isAbsolute(maybeAbsolutePath)) {
48
21
  return maybeAbsolutePath;
49
22
  }
50
- return `./${import_node_path.default.relative((0, import_project_config.getPaths)().web.src, maybeAbsolutePath)}`;
23
+ return `./${path.relative(getPaths().web.src, maybeAbsolutePath)}`;
51
24
  };
52
25
  const withRelativeImports = (page) => {
53
26
  return {
54
27
  ...page,
55
- relativeImport: (0, import_project_config.ensurePosixPath)(getPathRelativeToSrc(page.importPath))
28
+ relativeImport: ensurePosixPath(getPathRelativeToSrc(page.importPath))
56
29
  };
57
30
  };
58
31
  function babel_plugin_redwood_routes_auto_loader_default({ types: t }, { forPrerender = false }) {
59
- let pages = (0, import_project_config.processPagesDir)().map(withRelativeImports);
32
+ let pages = processPagesDir().map(withRelativeImports);
60
33
  const duplicatePageImportNames = /* @__PURE__ */ new Set();
61
34
  const sortedPageImportNames = pages.map((page) => page.importName).sort();
62
35
  for (let i = 0; i < sortedPageImportNames.length - 1; i++) {
@@ -82,7 +55,7 @@ function babel_plugin_redwood_routes_auto_loader_default({ types: t }, { forPrer
82
55
  return;
83
56
  }
84
57
  const userImportRelativePath = getPathRelativeToSrc(
85
- (0, import_project_config.importStatementPath)(p.node.source?.value)
58
+ importStatementPath(p.node.source?.value)
86
59
  );
87
60
  const defaultSpecifier = p.node.specifiers.find(
88
61
  (specifiers) => t.isImportDefaultSpecifier(specifiers)
@@ -92,7 +65,7 @@ function babel_plugin_redwood_routes_auto_loader_default({ types: t }, { forPrer
92
65
  }
93
66
  if (forPrerender) {
94
67
  const pageThatUserImported = pages.find((page) => {
95
- return page.relativeImport === (0, import_project_config.ensurePosixPath)(userImportRelativePath);
68
+ return page.relativeImport === ensurePosixPath(userImportRelativePath);
96
69
  });
97
70
  if (pageThatUserImported) {
98
71
  pageThatUserImported.importName = defaultSpecifier.local.name;
@@ -104,21 +77,21 @@ function babel_plugin_redwood_routes_auto_loader_default({ types: t }, { forPrer
104
77
  }
105
78
  if (userImportRelativePath && defaultSpecifier) {
106
79
  pages = pages.filter(
107
- (page) => !(page.relativeImport === (0, import_project_config.ensurePosixPath)(userImportRelativePath))
80
+ (page) => !(page.relativeImport === ensurePosixPath(userImportRelativePath))
108
81
  );
109
82
  }
110
83
  },
111
84
  Program: {
112
85
  enter() {
113
- pages = (0, import_project_config.processPagesDir)().map(withRelativeImports);
114
- const appPath = (0, import_project_config.resolveFile)(import_node_path.default.join((0, import_project_config.getPaths)().web.src, "App"));
86
+ pages = processPagesDir().map(withRelativeImports);
87
+ const appPath = resolveFile(path.join(getPaths().web.src, "App"));
115
88
  if (appPath) {
116
- const appSource = import_node_fs.default.readFileSync(appPath, "utf8");
89
+ const appSource = fs.readFileSync(appPath, "utf8");
117
90
  const importRe = /^import\s+\w+\s+from\s+['"]([^'"]+)['"]/gm;
118
91
  let m;
119
92
  while ((m = importRe.exec(appSource)) !== null) {
120
- const rel = (0, import_project_config.ensurePosixPath)(
121
- getPathRelativeToSrc((0, import_project_config.importStatementPath)(m[1]))
93
+ const rel = ensurePosixPath(
94
+ getPathRelativeToSrc(importStatementPath(m[1]))
122
95
  );
123
96
  pages = pages.filter((page) => page.relativeImport !== rel);
124
97
  }
@@ -195,3 +168,6 @@ function prerenderLoaderImpl(forPrerender, relativeImport, t) {
195
168
  )
196
169
  ]);
197
170
  }
171
+ export {
172
+ babel_plugin_redwood_routes_auto_loader_default as default
173
+ };
package/dist/web.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../src/web.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAKnD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAUtD,MAAM,WAAW,KAAK;IACpB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,gEAAgE;IAChE,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB;;;OAGG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,eAAO,MAAM,sBAAsB,GACjC,uBAAsB,KAA0B,uBAqGjD,CAAA;AAED,eAAO,MAAM,mBAAmB,GAC9B,4BAA2B,KAA+B,KACzD,gBAAgB,EAqClB,CAAA;AAED,eAAO,MAAM,sBAAsB,GAAI,SAAS,KAAK,qDAwCpD,CAAA;AAED,eAAO,MAAM,yBAAyB,0BAOrC,CAAA;AAED,eAAO,MAAM,4BAA4B,GAAI,UAAS,KAAU;;;;;;;CAa/D,CAAA;AAGD,eAAO,MAAM,wBAAwB,GAAI,mCAItC,mBAAwB,SAY1B,CAAA"}
1
+ {"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../src/web.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAKnD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAetD,MAAM,WAAW,KAAK;IACpB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,gEAAgE;IAChE,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB;;;OAGG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,eAAO,MAAM,sBAAsB,GACjC,uBAAsB,KAA0B,uBA2GjD,CAAA;AAED,eAAO,MAAM,mBAAmB,GAC9B,4BAA2B,KAA+B,KACzD,gBAAgB,EA0ClB,CAAA;AAED,eAAO,MAAM,sBAAsB,GAAI,SAAS,KAAK,qDAwCpD,CAAA;AAED,eAAO,MAAM,yBAAyB,0BAOrC,CAAA;AAED,eAAO,MAAM,4BAA4B,GAAI,UAAS,KAAU;;;;;;;CAa/D,CAAA;AAGD,eAAO,MAAM,wBAAwB,GAAI,mCAItC,mBAAwB,SAY1B,CAAA"}
package/dist/web.js CHANGED
@@ -1,69 +1,37 @@
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 web_exports = {};
30
- __export(web_exports, {
31
- getWebSideBabelConfigPath: () => getWebSideBabelConfigPath,
32
- getWebSideBabelPlugins: () => getWebSideBabelPlugins,
33
- getWebSideBabelPresets: () => getWebSideBabelPresets,
34
- getWebSideDefaultBabelConfig: () => getWebSideDefaultBabelConfig,
35
- getWebSideOverrides: () => getWebSideOverrides,
36
- registerWebSideBabelHook: () => registerWebSideBabelHook
37
- });
38
- module.exports = __toCommonJS(web_exports);
39
- var import_node_fs = __toESM(require("node:fs"));
40
- var import_node_path = __toESM(require("node:path"));
41
- var import_babel_plugin_module_resolver = require("babel-plugin-module-resolver");
42
- var import_project_config = require("@cedarjs/project-config");
43
- var import_common = require("./common.js");
1
+ import fs from "node:fs";
2
+ import { createRequire } from "node:module";
3
+ import path from "node:path";
4
+ import { resolvePath } from "babel-plugin-module-resolver";
5
+ import { getConfig, getPaths } from "@cedarjs/project-config";
6
+ import {
7
+ registerBabel,
8
+ parseTypeScriptConfigFiles,
9
+ getPathsFromTypeScriptConfig
10
+ } from "./common.js";
11
+ const require2 = createRequire(import.meta.url);
44
12
  const getWebSideBabelPlugins = ({ forJest, forVite } = { forJest: false }) => {
45
- const config = (0, import_project_config.getConfig)();
13
+ const config = getConfig();
46
14
  const useReactCompiler = config.experimental?.reactCompiler?.enabled && config.experimental?.reactCompiler?.lintOnly === false;
47
15
  const useTrustedDocumentsGqlTag = config.graphql.trustedDocuments;
48
- const rwjsPaths = (0, import_project_config.getPaths)();
49
- const tsConfigs = (0, import_common.parseTypeScriptConfigFiles)();
16
+ const rwjsPaths = getPaths();
17
+ const tsConfigs = parseTypeScriptConfigFiles();
50
18
  const plugins = [
51
19
  // It is important that this plugin run first, as noted here: https://react.dev/learn/react-compiler
52
20
  useReactCompiler && ["babel-plugin-react-compiler", { target: "19" }],
53
- ...forJest ? (0, import_common.getCommonPlugins)() : [],
54
21
  // === Import path handling
55
- [
22
+ // Vite resolves the src/ and $api/ aliases via
23
+ // cedarjsResolveCedarStyleImportsPlugin, and tsconfig `paths` aliases via
24
+ // vite-tsconfig-paths, instead of this babel plugin
25
+ !forVite && [
56
26
  "babel-plugin-module-resolver",
57
27
  {
58
28
  alias: {
59
- ...!forVite && {
60
- // Jest monorepo and multi project runner is not correctly
61
- // determining the `cwd`:
62
- // https://github.com/facebook/jest/issues/7359
63
- src: forJest ? rwjsPaths.web.src : "./src"
64
- },
29
+ // Jest monorepo and multi project runner is not correctly
30
+ // determining the `cwd`:
31
+ // https://github.com/facebook/jest/issues/7359
32
+ src: forJest ? rwjsPaths.web.src : "./src",
65
33
  // adds the paths from [ts|js]config.json to the module resolver
66
- ...(0, import_common.getPathsFromTypeScriptConfig)(tsConfigs.web, rwjsPaths.web.base),
34
+ ...getPathsFromTypeScriptConfig(tsConfigs.web, rwjsPaths.web.base),
67
35
  $api: rwjsPaths.api.base
68
36
  },
69
37
  root: [rwjsPaths.web.base],
@@ -71,7 +39,7 @@ const getWebSideBabelPlugins = ({ forJest, forVite } = { forJest: false }) => {
71
39
  loglevel: "silent",
72
40
  // to silence the unnecessary warnings
73
41
  resolvePath(sourcePath, currentFile, opts) {
74
- const resolvedPath = (0, import_babel_plugin_module_resolver.resolvePath)(sourcePath, currentFile, opts);
42
+ const resolvedPath = resolvePath(sourcePath, currentFile, opts);
75
43
  return resolvedPath?.replace(/\.js$/, "");
76
44
  }
77
45
  },
@@ -81,12 +49,14 @@ const getWebSideBabelPlugins = ({ forJest, forVite } = { forJest: false }) => {
81
49
  // packages/vite/src/plugins/vite-plugin-cedarjs-resolve-cedar-style-imports.ts
82
50
  // instead of this babel plugin
83
51
  !forVite && [
84
- require("./plugins/babel-plugin-redwood-directory-named-import").default,
52
+ require2("./plugins/babel-plugin-redwood-directory-named-import").default,
85
53
  void 0,
86
54
  "rwjs-directory-named-modules"
87
55
  ],
88
56
  // === Auto imports, and transforms
89
- [
57
+ // Vite handles auto-imports via cedarAutoImportsPlugin; only keep for
58
+ // non-Vite consumers (Jest web tests).
59
+ !forVite && [
90
60
  "babel-plugin-auto-import",
91
61
  {
92
62
  declarations: [
@@ -114,11 +84,15 @@ const getWebSideBabelPlugins = ({ forJest, forVite } = { forJest: false }) => {
114
84
  },
115
85
  "rwjs-web-auto-import"
116
86
  ],
117
- ["babel-plugin-graphql-tag", void 0, "rwjs-babel-graphql-tag"],
118
87
  // Prerender uses rollup-plugin-cedar-remove-dev-fatal-error-page
119
88
  // Vite uses vite-plugin-cedar-remove-dev-fatal-error-page
89
+ !forVite && [
90
+ "babel-plugin-graphql-tag",
91
+ void 0,
92
+ "rwjs-babel-graphql-tag"
93
+ ],
120
94
  forJest && process.env.NODE_ENV !== "development" && [
121
- require("./plugins/babel-plugin-redwood-remove-dev-fatal-error-page").default,
95
+ require2("./plugins/babel-plugin-redwood-remove-dev-fatal-error-page").default,
122
96
  void 0,
123
97
  "rwjs-remove-dev-fatal-error-page"
124
98
  ]
@@ -134,7 +108,7 @@ const getWebSideOverrides = ({ forPrerender, forVite } = { forPrerender: false }
134
108
  test: /src[\/\\]Routes.(js|tsx|jsx)$/,
135
109
  plugins: [
136
110
  [
137
- require("./plugins/babel-plugin-redwood-routes-auto-loader").default,
111
+ require2("./plugins/babel-plugin-redwood-routes-auto-loader").default,
138
112
  // The plugin will modify the Routes file differently based on what
139
113
  // context we're building for
140
114
  {
@@ -147,10 +121,14 @@ const getWebSideOverrides = ({ forPrerender, forVite } = { forPrerender: false }
147
121
  // ** Files ending in `Cell.mock.[js,ts]` **
148
122
  // Automatically determine keys for saving and retrieving mock data.
149
123
  // Only required for storybook and jest
150
- process.env.NODE_ENV !== "production" && {
124
+ // Vite/Vitest runs the mock-cell-data transform via its own plugin
125
+ // (vite-plugin-cedar-mock-cell-data). Jest (CJS projects) still needs the
126
+ // Babel plugin because it doesn't go through Vite's pipeline, so we keep
127
+ // the override active for non-Vite contexts.
128
+ !forVite && process.env.NODE_ENV !== "production" && {
151
129
  test: /.+Cell.mock.(js|ts)$/,
152
130
  plugins: [
153
- require("./plugins/babel-plugin-redwood-mock-cell-data").default
131
+ require2("./plugins/babel-plugin-redwood-mock-cell-data").default
154
132
  ]
155
133
  }
156
134
  ];
@@ -164,7 +142,7 @@ const getWebSideBabelPresets = (options) => {
164
142
  if (options.forPrerender || options.forJest || options.forJavaScriptLinting) {
165
143
  let reactPresetConfig = { runtime: "automatic" };
166
144
  if (getWebSideBabelConfigPath()) {
167
- const userProjectConfig = require(getWebSideBabelConfigPath());
145
+ const userProjectConfig = require2(getWebSideBabelConfigPath());
168
146
  userProjectConfig.presets?.forEach(
169
147
  (preset) => {
170
148
  if (!Array.isArray(preset)) {
@@ -193,8 +171,8 @@ const getWebSideBabelPresets = (options) => {
193
171
  return [];
194
172
  };
195
173
  const getWebSideBabelConfigPath = () => {
196
- const customBabelConfig = import_node_path.default.join((0, import_project_config.getPaths)().web.base, "babel.config.js");
197
- if (import_node_fs.default.existsSync(customBabelConfig)) {
174
+ const customBabelConfig = path.join(getPaths().web.base, "babel.config.js");
175
+ if (fs.existsSync(customBabelConfig)) {
198
176
  return customBabelConfig;
199
177
  } else {
200
178
  return void 0;
@@ -216,9 +194,9 @@ const registerWebSideBabelHook = ({
216
194
  options = {}
217
195
  } = {}) => {
218
196
  const defaultOptions = getWebSideDefaultBabelConfig(options);
219
- (0, import_common.registerBabel)({
197
+ registerBabel({
220
198
  ...defaultOptions,
221
- root: (0, import_project_config.getPaths)().base,
199
+ root: getPaths().base,
222
200
  extensions: [".js", ".ts", ".tsx", ".jsx"],
223
201
  plugins: [...defaultOptions.plugins, ...plugins],
224
202
  cache: false,
@@ -227,12 +205,11 @@ const registerWebSideBabelHook = ({
227
205
  overrides: [...getWebSideOverrides({ forPrerender: true }), ...overrides]
228
206
  });
229
207
  };
230
- // Annotate the CommonJS export names for ESM import in node:
231
- 0 && (module.exports = {
208
+ export {
232
209
  getWebSideBabelConfigPath,
233
210
  getWebSideBabelPlugins,
234
211
  getWebSideBabelPresets,
235
212
  getWebSideDefaultBabelConfig,
236
213
  getWebSideOverrides,
237
214
  registerWebSideBabelHook
238
- });
215
+ };
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@cedarjs/babel-config",
3
- "version": "5.0.3",
3
+ "version": "5.0.4-next.167",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/cedarjs/cedar.git",
7
7
  "directory": "packages/babel-config"
8
8
  },
9
9
  "license": "MIT",
10
- "type": "commonjs",
10
+ "type": "module",
11
11
  "exports": {
12
12
  ".": "./dist/index.js",
13
13
  "./dist/plugins/*": "./dist/plugins/*"
@@ -17,9 +17,9 @@
17
17
  "dist"
18
18
  ],
19
19
  "scripts": {
20
- "build": "node ./build.mts && run build:types",
20
+ "build": "node ./build.mts",
21
21
  "build:pack": "yarn pack -o cedarjs-babel-config.tgz",
22
- "build:types": "tsc --build --verbose",
22
+ "build:types": "tsc --build --verbose ./tsconfig.build.json",
23
23
  "build:watch": "nodemon --watch src --ext \"js,ts,tsx\" --ignore dist --exec \"yarn build\"",
24
24
  "prepublishOnly": "NODE_ENV=production yarn build",
25
25
  "test": "vitest run",
@@ -35,7 +35,7 @@
35
35
  "@babel/preset-typescript": "7.29.7",
36
36
  "@babel/register": "7.29.7",
37
37
  "@babel/traverse": "7.29.7",
38
- "@cedarjs/project-config": "5.0.3",
38
+ "@cedarjs/project-config": "5.0.4-next.167",
39
39
  "babel-plugin-auto-import": "1.1.0",
40
40
  "babel-plugin-graphql-tag": "3.3.0",
41
41
  "babel-plugin-module-resolver": "5.0.3",
@@ -44,14 +44,14 @@
44
44
  "typescript": "5.9.3"
45
45
  },
46
46
  "devDependencies": {
47
- "@cedarjs/framework-tools": "5.0.3",
47
+ "@cedarjs/framework-tools": "5.0.4-next.167",
48
48
  "@jridgewell/trace-mapping": "0.3.31",
49
49
  "@types/babel-plugin-tester": "11.0.0",
50
50
  "@types/babel__core": "7.20.5",
51
51
  "@types/babel__register": "7.17.3",
52
52
  "@types/node": "24.10.4",
53
53
  "babel-plugin-tester": "11.0.4",
54
- "vitest": "3.2.6"
54
+ "vitest": "4.1.10"
55
55
  },
56
56
  "engines": {
57
57
  "node": ">=24"
@@ -1,32 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,154 +0,0 @@
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
- }
@@ -1,5 +0,0 @@
1
- import type { PluginObj, types } from '@babel/core';
2
- export default function ({ types: t }: {
3
- types: typeof types;
4
- }): PluginObj;
5
- //# sourceMappingURL=babel-plugin-cedar-graphql-options-extract.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"babel-plugin-cedar-graphql-options-extract.d.ts","sourceRoot":"","sources":["../../src/plugins/babel-plugin-cedar-graphql-options-extract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAY,SAAS,EAAc,KAAK,EAAE,MAAM,aAAa,CAAA;AAkCzE,MAAM,CAAC,OAAO,WAAW,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IAAE,KAAK,EAAE,OAAO,KAAK,CAAA;CAAE,GAAG,SAAS,CAyEzE"}