@cedarjs/babel-config 6.0.0-canary.2696 → 6.0.0-canary.2697

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/api.d.ts CHANGED
@@ -9,26 +9,56 @@ type PluginShape = [PluginTarget, PluginOptions, undefined | string] | [PluginTa
9
9
  export declare const getApiSideBabelPlugins: ({ forVite, projectIsEsm, }?: {
10
10
  forVite?: boolean | undefined;
11
11
  projectIsEsm?: boolean | undefined;
12
- }) => ([PluginTarget, PluginOptions, string | undefined] | [PluginTarget, PluginOptions])[];
12
+ }) => PluginList;
13
+ /**
14
+ * Purpose-built equivalent of `getApiSideBabelPlugins({ forVite: true })` for
15
+ * the Vite-driven api pipelines (buildCedarApp, the api dev middleware, and
16
+ * the esbuild/standalone-Vite api builds in @cedarjs/internal).
17
+ *
18
+ * Every Cedar-specific Babel plugin is gated behind `!forVite` in
19
+ * `getApiSideBabelPlugins` because these pipelines replace them with
20
+ * dedicated Vite/esbuild transforms:
21
+ * - JSX/TypeScript compilation: handled natively by Vite/esbuild
22
+ * - babel-plugin-module-resolver (`src/` and tsconfig `paths` aliases):
23
+ * cedar-api-src-redirect + vite-tsconfig-paths (Vite) or applySrcAlias +
24
+ * applyTsconfigPaths (esbuild); ESM extension rewriting is covered by
25
+ * applyEsmExtensions
26
+ * - directory-named imports: cedarDirectoryNamedImportPlugin /
27
+ * applyDirectoryNamedImport
28
+ * - auto-imports (gql, context): cedarAutoImportsPlugin / applyAutoImports
29
+ * - graphql-tag: vite-plugin-graphql-tag
30
+ * - glob imports: cedarImportDirPlugin / applyImportDir
31
+ *
32
+ * Only the common plugins remain — and that list is currently empty, which
33
+ * is why the Vite pipelines skip Babel entirely unless the project has a
34
+ * custom api/babel.config.js.
35
+ *
36
+ * The `projectIsEsm` option needs no equivalent here: it only affects the
37
+ * module-resolver `resolvePath` hook, which is a `!forVite` plugin.
38
+ */
39
+ export declare const getApiSideBabelPluginsForVite: () => PluginList;
13
40
  export declare const getApiSideBabelConfigPath: () => string | undefined;
14
41
  export declare const getApiSideBabelOverrides: ({ forVite, projectIsEsm, forJest, }?: {
15
42
  forVite?: boolean | undefined;
16
43
  projectIsEsm?: boolean | undefined;
17
44
  forJest?: boolean | undefined;
18
45
  }) => TransformOptions[];
19
- export declare const getApiSideDefaultBabelConfig: ({ forVite, projectIsEsm, forJest, }?: {
20
- forVite?: boolean | undefined;
21
- projectIsEsm?: boolean | undefined;
22
- forJest?: boolean | undefined;
23
- }) => {
46
+ /**
47
+ * The default api-side Babel config for Jest (@cedarjs/testing) and the
48
+ * Babel ESLint parser (@cedarjs/eslint-config). The Jest-only handler ALS
49
+ * wrapping override is always included: it only matches api/src/functions
50
+ * files, and for the parse-only ESLint consumer transform plugins have no
51
+ * effect.
52
+ */
53
+ export declare const getApiSideDefaultBabelConfig: () => {
24
54
  presets: import("@babel/core").PluginItem[] | null | undefined;
25
- plugins: ([PluginTarget, PluginOptions, string | undefined] | [PluginTarget, PluginOptions])[];
55
+ plugins: PluginList;
26
56
  overrides: TransformOptions[];
27
57
  extends: string | undefined;
28
58
  babelrc: boolean;
29
59
  ignore: string[];
30
60
  };
31
61
  export declare const registerApiSideBabelHook: ({ plugins, ...rest }?: RegisterHookOptions) => void;
32
- export declare const transformWithBabel: (sourceCode: string, filename: string, plugins: TransformOptions["plugins"], sourceMaps?: TransformOptions["sourceMaps"], forVite?: boolean) => Promise<import("@babel/core").BabelFileResult | null>;
62
+ export declare const transformWithBabel: (sourceCode: string, filename: string, plugins: TransformOptions["plugins"], sourceMaps?: TransformOptions["sourceMaps"], forVite?: boolean, inputSourceMap?: TransformOptions["inputSourceMap"]) => Promise<import("@babel/core").BabelFileResult | null>;
33
63
  export {};
34
64
  //# sourceMappingURL=api.d.ts.map
package/dist/api.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aA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ACtC,KAAK,WAAW,GACZ,CAAC,YAAY,EAAE,aAAa,EAAE,SAAS,GAAG,MAAM,CAAC,GACjD,CAAC,YAAY,EAAE,aAAa,CAAC,CAAA;AAEjC,eAAO,MAAM,sBAAsB,GAAI;;;CAGjC,eA8GL,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,6BAA6B,QAAO,UAEhD,CAAA;AAED,eAAO,MAAM,yBAAyB,0BAOrC,CAAA;AAED,eAAO,MAAM,wBAAwB,GAAI;;;;CAInC,KAwBgB,gBAAgB,EACrC,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B;;;;;;;CASxC,CAAA;AAGD,eAAO,MAAM,wBAAwB,GAAI,uBAGtC,mBAAwB,SAgB1B,CAAA;AAED,eAAO,MAAM,kBAAkB,GAC7B,YAAY,MAAM,EAClB,UAAU,MAAM,EAChB,SAAS,gBAAgB,CAAC,SAAS,CAAC,EACpC,aAAY,gBAAgB,CAAC,YAAY,CAAY,EACrD,iBAAe,EAIf,iBAAgB,gBAAgB,CAAC,gBAAgB,CAAa,0DAuB/D,CAAA"}
package/dist/api.js CHANGED
@@ -32,6 +32,7 @@ __export(api_exports, {
32
32
  getApiSideBabelConfigPath: () => getApiSideBabelConfigPath,
33
33
  getApiSideBabelOverrides: () => getApiSideBabelOverrides,
34
34
  getApiSideBabelPlugins: () => getApiSideBabelPlugins,
35
+ getApiSideBabelPluginsForVite: () => getApiSideBabelPluginsForVite,
35
36
  getApiSideBabelPresets: () => getApiSideBabelPresets,
36
37
  getApiSideDefaultBabelConfig: () => getApiSideDefaultBabelConfig,
37
38
  registerApiSideBabelHook: () => registerApiSideBabelHook,
@@ -75,27 +76,24 @@ const getApiSideBabelPlugins = ({
75
76
  forVite = false,
76
77
  projectIsEsm = false
77
78
  } = {}) => {
79
+ if (forVite) {
80
+ return getApiSideBabelPluginsForVite();
81
+ }
78
82
  const tsConfig = (0, import_common.parseTypeScriptConfigFiles)();
79
83
  const plugins = [
80
84
  ...(0, import_common.getCommonPlugins)(),
81
85
  // Needed to support `/** @jsxImportSource custom-jsx-library */`
82
86
  // comments in JSX files
83
- !forVite && ["@babel/plugin-transform-react-jsx", { runtime: "automatic" }],
84
- // For non-Vite consumers (Jest, registerApiSideBabelHook / Babel
85
- // registerRequire paths such as data-migrate CJS and prerender CJS):
87
+ ["@babel/plugin-transform-react-jsx", { runtime: "automatic" }],
88
+ // For the non-Vite consumers this function serves (Jest,
89
+ // registerApiSideBabelHook / Babel registerRequire paths such as
90
+ // data-migrate CJS and prerender CJS):
86
91
  // • alias config: rewrites `src/` and tsconfig paths to relative paths
87
92
  // • resolvePath: appends `.js`/`.jsx` to extensionless imports in ESM
88
93
  // projects so Node's module resolver can find them, and strips `.js`
89
94
  // suffixes in data-migrate / prerender contexts where the TypeScript
90
95
  // source is `.ts` but callers write `.js` import specifiers.
91
- //
92
- // For Vite / esbuild (forVite: true):
93
- // • alias handling: covered by cedar-api-src-redirect + vite-tsconfig-paths
94
- // (Vite) or applySrcAlias + applyTsconfigPaths (esbuild)
95
- // • extension rewriting: covered by applyEsmExtensions in
96
- // runCedarBabelTransformsPlugin (esbuild); Vite / Rollup resolve
97
- // extensions themselves during bundling
98
- !forVite && [
96
+ [
99
97
  "babel-plugin-module-resolver",
100
98
  {
101
99
  alias: {
@@ -130,14 +128,15 @@ const getApiSideBabelPlugins = ({
130
128
  ],
131
129
  // Vite/esbuild use cedarDirectoryNamedImportPlugin / applyDirectoryNamedImport
132
130
  // instead of this babel plugin
133
- !forVite && [
131
+ [
134
132
  import_babel_plugin_redwood_directory_named_import.default,
135
133
  void 0,
136
134
  "rwjs-babel-directory-named-modules"
137
135
  ],
138
- // Auto-import is handled by cedarAutoImportsPlugin for Vite; skip it in
139
- // Vite contexts and keep it for non-Vite consumers (Jest, esbuild builds).
140
- !forVite && [
136
+ // Auto-import is handled by cedarAutoImportsPlugin / applyAutoImports for
137
+ // Vite/esbuild; this Babel plugin serves the remaining non-Vite consumers
138
+ // (Jest, registerApiSideBabelHook).
139
+ [
141
140
  "babel-plugin-auto-import",
142
141
  {
143
142
  declarations: [
@@ -155,17 +154,16 @@ const getApiSideBabelPlugins = ({
155
154
  },
156
155
  "rwjs-babel-auto-import"
157
156
  ],
158
- !forVite && [
159
- "babel-plugin-graphql-tag",
160
- void 0,
161
- "rwjs-babel-graphql-tag"
162
- ],
157
+ ["babel-plugin-graphql-tag", void 0, "rwjs-babel-graphql-tag"],
163
158
  // For Vite builds, glob imports are handled by cedarImportDirPlugin (Vite)
164
159
  // or applyImportDir (esbuild). Keep the Babel plugin only for
165
160
  // non-Vite consumers: Jest, console, and data-migrate.
166
- !forVite && [import_babel_plugin_redwood_import_dir.default, {}, "rwjs-babel-glob-import-dir"]
161
+ [import_babel_plugin_redwood_import_dir.default, {}, "rwjs-babel-glob-import-dir"]
167
162
  ];
168
- return plugins.filter((n) => Boolean(n));
163
+ return plugins;
164
+ };
165
+ const getApiSideBabelPluginsForVite = () => {
166
+ return [...(0, import_common.getCommonPlugins)()];
169
167
  };
170
168
  const getApiSideBabelConfigPath = () => {
171
169
  const p = import_node_path.default.join((0, import_project_config.getPaths)().api.base, "babel.config.js");
@@ -205,15 +203,11 @@ const getApiSideBabelOverrides = ({
205
203
  ].filter(Boolean);
206
204
  return overrides;
207
205
  };
208
- const getApiSideDefaultBabelConfig = ({
209
- forVite = false,
210
- projectIsEsm = false,
211
- forJest = false
212
- } = {}) => {
206
+ const getApiSideDefaultBabelConfig = () => {
213
207
  return {
214
208
  presets: getApiSideBabelPresets(),
215
- plugins: getApiSideBabelPlugins({ forVite, projectIsEsm }),
216
- overrides: getApiSideBabelOverrides({ forVite, projectIsEsm, forJest }),
209
+ plugins: getApiSideBabelPlugins(),
210
+ overrides: getApiSideBabelOverrides({ forJest: true }),
217
211
  extends: getApiSideBabelConfigPath(),
218
212
  babelrc: false,
219
213
  ignore: ["node_modules"]
@@ -223,27 +217,31 @@ const registerApiSideBabelHook = ({
223
217
  plugins = [],
224
218
  ...rest
225
219
  } = {}) => {
226
- const defaultOptions = getApiSideDefaultBabelConfig({
227
- projectIsEsm: (0, import_project_config.projectSideIsEsm)("api")
228
- });
220
+ const projectIsEsm = (0, import_project_config.projectSideIsEsm)("api");
229
221
  (0, import_common.registerBabel)({
230
- ...defaultOptions,
231
222
  presets: getApiSideBabelPresets({
232
223
  presetEnv: true
233
224
  }),
225
+ overrides: getApiSideBabelOverrides({ projectIsEsm }),
226
+ extends: getApiSideBabelConfigPath(),
227
+ babelrc: false,
228
+ ignore: ["node_modules"],
234
229
  extensions: [".js", ".ts", ".jsx", ".tsx"],
235
- plugins: [...defaultOptions.plugins, ...plugins],
230
+ plugins: [...getApiSideBabelPlugins({ projectIsEsm }), ...plugins],
236
231
  cache: false,
237
232
  ...rest
238
233
  });
239
234
  };
240
- const transformWithBabel = async (sourceCode, filename, plugins, sourceMaps = "inline", forVite = false) => {
241
- const defaultOptions = getApiSideDefaultBabelConfig({
242
- forVite,
243
- projectIsEsm: (0, import_project_config.projectSideIsEsm)("api")
244
- });
235
+ const transformWithBabel = async (sourceCode, filename, plugins, sourceMaps = "inline", forVite = false, inputSourceMap = void 0) => {
245
236
  const result = (0, import_core.transformAsync)(sourceCode, {
246
- ...defaultOptions,
237
+ presets: getApiSideBabelPresets(),
238
+ overrides: getApiSideBabelOverrides({
239
+ forVite,
240
+ projectIsEsm: (0, import_project_config.projectSideIsEsm)("api")
241
+ }),
242
+ extends: getApiSideBabelConfigPath(),
243
+ babelrc: false,
244
+ ignore: ["node_modules"],
247
245
  cwd: (0, import_project_config.getPaths)().api.base,
248
246
  filename,
249
247
  // The default 'inline' embeds the map as a data URL in result.code,
@@ -251,7 +249,8 @@ const transformWithBabel = async (sourceCode, filename, plugins, sourceMaps = "i
251
249
  // pass sourceMaps: true because they extract result.map separately for
252
250
  // SSR source map chaining.
253
251
  sourceMaps,
254
- plugins
252
+ plugins,
253
+ inputSourceMap
255
254
  });
256
255
  return result;
257
256
  };
@@ -261,6 +260,7 @@ const transformWithBabel = async (sourceCode, filename, plugins, sourceMaps = "i
261
260
  getApiSideBabelConfigPath,
262
261
  getApiSideBabelOverrides,
263
262
  getApiSideBabelPlugins,
263
+ getApiSideBabelPluginsForVite,
264
264
  getApiSideBabelPresets,
265
265
  getApiSideDefaultBabelConfig,
266
266
  registerApiSideBabelHook,
package/dist/index.d.ts CHANGED
@@ -11,11 +11,13 @@ TARGETS_NODE,
11
11
  getApiSideBabelConfigPath,
12
12
  /** Used by @cedarjs/internal and @cedarjs/testing */
13
13
  getApiSideBabelPlugins,
14
+ /** Used by @cedarjs/internal and @cedarjs/vite */
15
+ getApiSideBabelPluginsForVite,
14
16
  /** Used by @cedarjs/testing */
15
17
  getApiSideBabelPresets,
16
18
  /** Used by @cedarjs/testing and @cedarjs/eslint-config */
17
19
  getApiSideDefaultBabelConfig,
18
- /** Used by @cedarjs/cli, @remix/cli-helpers and @cedarjs/prerender */
20
+ /** Used by @cedarjs/cli, @cedarjs/cli-helpers and @cedarjs/prerender */
19
21
  registerApiSideBabelHook,
20
22
  /** Used by @cedarjs/internal and @cedarjs/vite */
21
23
  transformWithBabel, } from './api.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO;AACL;;;GAGG;AACH,YAAY;AACZ;;;GAGG;AACH,yBAAyB;AACzB,qDAAqD;AACrD,sBAAsB;AACtB,+BAA+B;AAC/B,sBAAsB;AACtB,0DAA0D;AAC1D,4BAA4B;AAC5B,sEAAsE;AACtE,wBAAwB;AACxB,kDAAkD;AAClD,kBAAkB,GACnB,MAAM,UAAU,CAAA;AAEjB,OAAO;AACL;;;GAGG;AACH,yBAAyB;AACzB;;;GAGG;AACH,sBAAsB;AACtB;;;GAGG;AACH,sBAAsB;AACtB,mEAAmE;AACnE,4BAA4B;AAC5B;;;GAGG;AACH,mBAAmB;AACnB,iCAAiC;AACjC,wBAAwB,GACzB,MAAM,UAAU,CAAA;AAEjB,YAAY,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAErC,OAAO;AACL,iCAAiC;AACjC,gBAAgB;AAChB;;;GAGG;AACH,4BAA4B,IAAI,kBAAkB;AAClD,mBAAmB;AACnB,wBAAwB;AACxB;;;GAGG;AACH,0BAA0B;AAC1B;;;GAGG;AACH,aAAa,GACd,MAAM,aAAa,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO;AACL;;;GAGG;AACH,YAAY;AACZ;;;GAGG;AACH,yBAAyB;AACzB,qDAAqD;AACrD,sBAAsB;AACtB,kDAAkD;AAClD,6BAA6B;AAC7B,+BAA+B;AAC/B,sBAAsB;AACtB,0DAA0D;AAC1D,4BAA4B;AAC5B,wEAAwE;AACxE,wBAAwB;AACxB,kDAAkD;AAClD,kBAAkB,GACnB,MAAM,UAAU,CAAA;AAEjB,OAAO;AACL;;;GAGG;AACH,yBAAyB;AACzB;;;GAGG;AACH,sBAAsB;AACtB;;;GAGG;AACH,sBAAsB;AACtB,mEAAmE;AACnE,4BAA4B;AAC5B;;;GAGG;AACH,mBAAmB;AACnB,iCAAiC;AACjC,wBAAwB,GACzB,MAAM,UAAU,CAAA;AAEjB,YAAY,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAErC,OAAO;AACL,iCAAiC;AACjC,gBAAgB;AAChB;;;GAGG;AACH,4BAA4B,IAAI,kBAAkB;AAClD,mBAAmB;AACnB,wBAAwB;AACxB;;;GAGG;AACH,0BAA0B;AAC1B;;;GAGG;AACH,aAAa,GACd,MAAM,aAAa,CAAA"}
package/dist/index.js CHANGED
@@ -21,6 +21,7 @@ __export(index_exports, {
21
21
  TARGETS_NODE: () => import_api.TARGETS_NODE,
22
22
  getApiSideBabelConfigPath: () => import_api.getApiSideBabelConfigPath,
23
23
  getApiSideBabelPlugins: () => import_api.getApiSideBabelPlugins,
24
+ getApiSideBabelPluginsForVite: () => import_api.getApiSideBabelPluginsForVite,
24
25
  getApiSideBabelPresets: () => import_api.getApiSideBabelPresets,
25
26
  getApiSideDefaultBabelConfig: () => import_api.getApiSideDefaultBabelConfig,
26
27
  getCommonPlugins: () => import_common.getCommonPlugins,
@@ -46,6 +47,7 @@ var import_common = require("./common.js");
46
47
  TARGETS_NODE,
47
48
  getApiSideBabelConfigPath,
48
49
  getApiSideBabelPlugins,
50
+ getApiSideBabelPluginsForVite,
49
51
  getApiSideBabelPresets,
50
52
  getApiSideDefaultBabelConfig,
51
53
  getCommonPlugins,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/babel-config",
3
- "version": "6.0.0-canary.2696",
3
+ "version": "6.0.0-canary.2697",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/cedarjs/cedar.git",
@@ -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": "6.0.0-canary.2696",
38
+ "@cedarjs/project-config": "6.0.0-canary.2697",
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,7 +44,7 @@
44
44
  "typescript": "5.9.3"
45
45
  },
46
46
  "devDependencies": {
47
- "@cedarjs/framework-tools": "6.0.0-canary.2696",
47
+ "@cedarjs/framework-tools": "6.0.0-canary.2697",
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",