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

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 +10 -42
  2. package/dist/api.d.ts.map +1 -1
  3. package/dist/api.js +111 -84
  4. package/dist/common.d.ts +10 -2
  5. package/dist/common.d.ts.map +1 -1
  6. package/dist/common.js +75 -20
  7. package/dist/index.d.ts +3 -3
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +48 -28
  10. package/dist/plugins/babel-plugin-cedar-gqlorm-inject.d.ts +32 -0
  11. package/dist/plugins/babel-plugin-cedar-gqlorm-inject.d.ts.map +1 -0
  12. package/dist/plugins/babel-plugin-cedar-gqlorm-inject.js +154 -0
  13. package/dist/plugins/babel-plugin-cedar-graphql-options-extract.d.ts +5 -0
  14. package/dist/plugins/babel-plugin-cedar-graphql-options-extract.d.ts.map +1 -0
  15. package/dist/plugins/babel-plugin-cedar-graphql-options-extract.js +88 -0
  16. package/dist/plugins/{babel-plugin-handler-als-wrapping.d.ts → babel-plugin-redwood-context-wrapping.d.ts} +1 -1
  17. package/dist/plugins/babel-plugin-redwood-context-wrapping.d.ts.map +1 -0
  18. package/dist/plugins/{babel-plugin-handler-als-wrapping.js → babel-plugin-redwood-context-wrapping.js} +39 -19
  19. package/dist/plugins/babel-plugin-redwood-directory-named-import.js +39 -9
  20. package/dist/plugins/babel-plugin-redwood-import-dir.js +40 -10
  21. package/dist/plugins/babel-plugin-redwood-job-path-injector.js +37 -7
  22. package/dist/plugins/babel-plugin-redwood-mock-cell-data.d.ts.map +1 -1
  23. package/dist/plugins/babel-plugin-redwood-mock-cell-data.js +52 -19
  24. package/dist/plugins/babel-plugin-redwood-otel-wrapping.d.ts +5 -0
  25. package/dist/plugins/babel-plugin-redwood-otel-wrapping.d.ts.map +1 -0
  26. package/dist/plugins/babel-plugin-redwood-otel-wrapping.js +329 -0
  27. package/dist/plugins/babel-plugin-redwood-remove-dev-fatal-error-page.js +23 -3
  28. package/dist/plugins/babel-plugin-redwood-routes-auto-loader.js +51 -27
  29. package/dist/plugins/prettier.config.js +28 -0
  30. package/dist/web.d.ts.map +1 -1
  31. package/dist/web.js +71 -48
  32. package/package.json +7 -7
  33. package/dist/plugins/babel-plugin-handler-als-wrapping.d.ts.map +0 -1
@@ -1,7 +1,40 @@
1
- import fsPath from "node:path";
2
- import { getPaths } from "@cedarjs/project-config";
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_job_path_injector_exports = {};
30
+ __export(babel_plugin_redwood_job_path_injector_exports, {
31
+ default: () => babel_plugin_redwood_job_path_injector_default
32
+ });
33
+ module.exports = __toCommonJS(babel_plugin_redwood_job_path_injector_exports);
34
+ var import_node_path = __toESM(require("node:path"));
35
+ var import_project_config = require("@cedarjs/project-config");
3
36
  function babel_plugin_redwood_job_path_injector_default({ types }) {
4
- const paths = getPaths();
37
+ const paths = (0, import_project_config.getPaths)();
5
38
  return {
6
39
  name: "babel-plugin-redwood-job-path-injector",
7
40
  visitor: {
@@ -56,7 +89,7 @@ function babel_plugin_redwood_job_path_injector_default({ types }) {
56
89
  throw new Error("No file path was found in the state");
57
90
  }
58
91
  const importName = id.name;
59
- const importPath = fsPath.relative(paths.api.jobs, filepath);
92
+ const importPath = import_node_path.default.relative(paths.api.jobs, filepath);
60
93
  const importPathWithoutExtension = importPath.replace(/\.[^/.]+$/, "");
61
94
  const firstArg = init.arguments[0];
62
95
  if (!firstArg) {
@@ -83,6 +116,3 @@ function babel_plugin_redwood_job_path_injector_default({ types }) {
83
116
  }
84
117
  };
85
118
  }
86
- export {
87
- babel_plugin_redwood_job_path_injector_default as default
88
- };
@@ -1 +1 @@
1
- {"version":3,"file":"babel-plugin-redwood-mock-cell-data.d.ts","sourceRoot":"","sources":["../../src/plugins/babel-plugin-redwood-mock-cell-data.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAY5C,MAAM,CAAC,OAAO,WAAW,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IAAE,KAAK,EAAE,OAAO,KAAK,CAAA;CAAE,GAAG,SAAS,CAmKzE;AAED,eAAO,MAAM,eAAe,GAAI,GAAG,MAAM;;;;;;CA0FxC,CAAA;AAkBD,UAAU,YAAY;IACpB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,WAAW,GAAG,UAAU,GAAG,UAAU,GAAG,OAAO,CAAA;CACtD"}
1
+ {"version":3,"file":"babel-plugin-redwood-mock-cell-data.d.ts","sourceRoot":"","sources":["../../src/plugins/babel-plugin-redwood-mock-cell-data.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAO5C,MAAM,CAAC,OAAO,WAAW,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IAAE,KAAK,EAAE,OAAO,KAAK,CAAA;CAAE,GAAG,SAAS,CAmKzE;AAED,eAAO,MAAM,eAAe,GAAI,GAAG,MAAM;;;;;;CA0FxC,CAAA;AAkBD,UAAU,YAAY;IACpB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,WAAW,GAAG,UAAU,GAAG,UAAU,GAAG,OAAO,CAAA;CACtD"}
@@ -1,10 +1,43 @@
1
- import fs from "node:fs";
2
- import path from "path";
3
- import { parse as babelParse } from "@babel/parser";
4
- import babelTraverse from "@babel/traverse";
5
- import fg from "fast-glob";
6
- import { parse as graphqlParse, Kind } from "graphql";
7
- const traverse = babelTraverse.default || babelTraverse;
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_mock_cell_data_exports = {};
30
+ __export(babel_plugin_redwood_mock_cell_data_exports, {
31
+ default: () => babel_plugin_redwood_mock_cell_data_default,
32
+ getCellMetadata: () => getCellMetadata
33
+ });
34
+ module.exports = __toCommonJS(babel_plugin_redwood_mock_cell_data_exports);
35
+ var import_node_fs = __toESM(require("node:fs"));
36
+ var import_path = __toESM(require("path"));
37
+ var import_parser = require("@babel/parser");
38
+ var import_traverse = __toESM(require("@babel/traverse"));
39
+ var import_fast_glob = __toESM(require("fast-glob"));
40
+ var import_graphql = require("graphql");
8
41
  function babel_plugin_redwood_mock_cell_data_default({ types: t }) {
9
42
  let nodesToRemove = [];
10
43
  let nodesToInsert = [];
@@ -68,9 +101,9 @@ function babel_plugin_redwood_mock_cell_data_default({ types: t }) {
68
101
  default:
69
102
  return;
70
103
  }
71
- const dirname = path.dirname(state.file.opts.filename);
72
- const cellName = path.basename(dirname);
73
- const [cellPath] = fg.sync(`${cellName}.{js,jsx,ts,tsx}`, {
104
+ const dirname = import_path.default.dirname(state.file.opts.filename);
105
+ const cellName = import_path.default.basename(dirname);
106
+ const [cellPath] = import_fast_glob.default.sync(`${cellName}.{js,jsx,ts,tsx}`, {
74
107
  cwd: dirname,
75
108
  absolute: true,
76
109
  ignore: ["node_modules"]
@@ -95,7 +128,7 @@ function babel_plugin_redwood_mock_cell_data_default({ types: t }) {
95
128
  t.identifier("afterQuery")
96
129
  )
97
130
  ],
98
- t.stringLiteral(`./${path.basename(cellPath)}`)
131
+ t.stringLiteral(`./${import_path.default.basename(cellPath)}`)
99
132
  );
100
133
  nodesToInsert = [
101
134
  ...nodesToInsert,
@@ -124,7 +157,7 @@ const getCellMetadata = (p) => {
124
157
  let hasDefaultExport = false;
125
158
  const namedExports = [];
126
159
  let operation;
127
- traverse(ast, {
160
+ (0, import_traverse.default)(ast, {
128
161
  ExportDefaultDeclaration() {
129
162
  hasDefaultExport = true;
130
163
  return;
@@ -176,9 +209,9 @@ const getCellMetadata = (p) => {
176
209
  );
177
210
  let operationName = "";
178
211
  if (operation) {
179
- const document = graphqlParse(operation);
212
+ const document = (0, import_graphql.parse)(operation);
180
213
  for (const definition of document.definitions) {
181
- if (definition.kind === Kind.OPERATION_DEFINITION && definition.name?.value) {
214
+ if (definition.kind === import_graphql.Kind.OPERATION_DEFINITION && definition.name?.value) {
182
215
  operationName = definition.name.value;
183
216
  }
184
217
  }
@@ -192,10 +225,10 @@ const getCellMetadata = (p) => {
192
225
  };
193
226
  };
194
227
  function getCellAst(filePath) {
195
- const code = fs.readFileSync(filePath, "utf-8");
228
+ const code = import_node_fs.default.readFileSync(filePath, "utf-8");
196
229
  const plugins = ["typescript", "jsx"].filter(Boolean);
197
230
  try {
198
- return babelParse(code, {
231
+ return (0, import_parser.parse)(code, {
199
232
  sourceType: "module",
200
233
  plugins
201
234
  });
@@ -205,7 +238,7 @@ function getCellAst(filePath) {
205
238
  throw new Error(e?.message);
206
239
  }
207
240
  }
208
- export {
209
- babel_plugin_redwood_mock_cell_data_default as default,
241
+ // Annotate the CommonJS export names for ESM import in node:
242
+ 0 && (module.exports = {
210
243
  getCellMetadata
211
- };
244
+ });
@@ -0,0 +1,5 @@
1
+ import type { PluginObj, types } from '@babel/core';
2
+ export default function ({ types: t }: {
3
+ types: typeof types;
4
+ }): PluginObj;
5
+ //# sourceMappingURL=babel-plugin-redwood-otel-wrapping.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"babel-plugin-redwood-otel-wrapping.d.ts","sourceRoot":"","sources":["../../src/plugins/babel-plugin-redwood-otel-wrapping.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAY,SAAS,EAAc,KAAK,EAAE,MAAM,aAAa,CAAA;AA2VzE,MAAM,CAAC,OAAO,WAAW,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IAAE,KAAK,EAAE,OAAO,KAAK,CAAA;CAAE,GAAG,SAAS,CAYzE"}
@@ -0,0 +1,329 @@
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_otel_wrapping_exports = {};
30
+ __export(babel_plugin_redwood_otel_wrapping_exports, {
31
+ default: () => babel_plugin_redwood_otel_wrapping_default
32
+ });
33
+ module.exports = __toCommonJS(babel_plugin_redwood_otel_wrapping_exports);
34
+ var nodejsPath = __toESM(require("path"));
35
+ var import_project_config = require("@cedarjs/project-config");
36
+ function addOpenTelemetryImport(path, t) {
37
+ path.node.body.unshift(
38
+ t.importDeclaration(
39
+ [
40
+ t.importSpecifier(
41
+ t.identifier("RW_OTEL_WRAPPER_TRACE"),
42
+ t.identifier("trace")
43
+ )
44
+ ],
45
+ t.stringLiteral("@opentelemetry/api")
46
+ )
47
+ );
48
+ }
49
+ function getRedwoodPaths(state) {
50
+ if (process.env.NODE_ENV === "test") {
51
+ return {
52
+ filename: "__MOCKED_FILENAME__",
53
+ apiFolder: "__MOCKED_API_FOLDER__"
54
+ };
55
+ }
56
+ const filename = state.file.opts.filename;
57
+ const filenameOffset = filename ? (0, import_project_config.getBaseDirFromFile)(filename).length + 9 : 0;
58
+ const apiFolder = filename ? filename.substring(
59
+ filenameOffset,
60
+ filename.substring(filenameOffset).indexOf(nodejsPath.sep) + filenameOffset
61
+ ) : "?";
62
+ return {
63
+ filename,
64
+ apiFolder
65
+ };
66
+ }
67
+ function wrapExportNamedDeclaration(path, state, t) {
68
+ const declaration = path.node.declaration;
69
+ const declarationIsSupported = declaration?.type === "VariableDeclaration" && declaration.declarations[0].init?.type === "ArrowFunctionExpression";
70
+ if (!declarationIsSupported) {
71
+ return;
72
+ }
73
+ const originalFunction = declaration.declarations[0].init;
74
+ if (!originalFunction) {
75
+ return;
76
+ }
77
+ const originalFunctionName = declaration.declarations[0].id.type === "Identifier" ? declaration.declarations[0].id.name : "?";
78
+ const wrappedFunctionName = `__${originalFunctionName === "?" ? "RW_OTEL_WRAPPER_UNKNOWN_FUNCTION" : originalFunctionName}`;
79
+ const originalFunctionArgumentsWithoutDefaults = [];
80
+ for (const param of originalFunction.params) {
81
+ if (param.type === "Identifier") {
82
+ originalFunctionArgumentsWithoutDefaults.push(param);
83
+ continue;
84
+ }
85
+ if (param.type === "ObjectPattern") {
86
+ const objectProperties = param.properties.filter(
87
+ (p) => p.type === "ObjectProperty"
88
+ );
89
+ originalFunctionArgumentsWithoutDefaults.push(
90
+ t.objectExpression(
91
+ objectProperties.map((p) => {
92
+ if (p.value.type === "AssignmentPattern") {
93
+ return t.objectProperty(p.key, p.value.left);
94
+ }
95
+ return p;
96
+ })
97
+ )
98
+ );
99
+ continue;
100
+ }
101
+ if (param.type === "AssignmentPattern") {
102
+ if (param.left.type === "Identifier") {
103
+ originalFunctionArgumentsWithoutDefaults.push(param.left);
104
+ } else if (param.left.type === "ObjectPattern") {
105
+ const objectProperties = param.left.properties.filter(
106
+ (p) => p.type === "ObjectProperty"
107
+ );
108
+ originalFunctionArgumentsWithoutDefaults.push(
109
+ t.objectExpression(
110
+ objectProperties.map((p) => {
111
+ if (p.value.type === "AssignmentPattern") {
112
+ return t.objectProperty(p.key, p.value.left);
113
+ }
114
+ return p;
115
+ })
116
+ )
117
+ );
118
+ } else {
119
+ return;
120
+ }
121
+ }
122
+ if (param.type === "ArrayPattern" || param.type === "RestElement") {
123
+ return;
124
+ }
125
+ }
126
+ const { filename, apiFolder } = getRedwoodPaths(state);
127
+ const activeSpanBlock = t.callExpression(
128
+ t.memberExpression(
129
+ t.identifier("RW_OTEL_WRAPPER_TRACER"),
130
+ t.identifier("startActiveSpan")
131
+ ),
132
+ [
133
+ t.stringLiteral(`redwoodjs:api:${apiFolder}:${originalFunctionName}`),
134
+ t.arrowFunctionExpression(
135
+ [t.identifier("span")],
136
+ t.blockStatement([
137
+ t.expressionStatement(
138
+ t.callExpression(
139
+ t.memberExpression(
140
+ t.identifier("span"),
141
+ t.identifier("setAttribute")
142
+ ),
143
+ [
144
+ t.stringLiteral("code.function"),
145
+ t.stringLiteral(originalFunctionName)
146
+ ]
147
+ )
148
+ ),
149
+ t.expressionStatement(
150
+ t.callExpression(
151
+ t.memberExpression(
152
+ t.identifier("span"),
153
+ t.identifier("setAttribute")
154
+ ),
155
+ [
156
+ t.stringLiteral("code.filepath"),
157
+ t.stringLiteral(filename || "?")
158
+ ]
159
+ )
160
+ ),
161
+ t.tryStatement(
162
+ t.blockStatement([
163
+ t.variableDeclaration("const", [
164
+ t.variableDeclarator(
165
+ t.identifier("RW_OTEL_WRAPPER_INNER_RESULT"),
166
+ originalFunction.async ? t.awaitExpression(
167
+ t.callExpression(
168
+ t.identifier(wrappedFunctionName),
169
+ originalFunctionArgumentsWithoutDefaults
170
+ )
171
+ ) : t.callExpression(
172
+ t.identifier(wrappedFunctionName),
173
+ originalFunctionArgumentsWithoutDefaults
174
+ )
175
+ )
176
+ ]),
177
+ t.expressionStatement(
178
+ t.callExpression(
179
+ t.memberExpression(t.identifier("span"), t.identifier("end")),
180
+ []
181
+ )
182
+ ),
183
+ t.returnStatement(t.identifier("RW_OTEL_WRAPPER_INNER_RESULT"))
184
+ ]),
185
+ t.catchClause(
186
+ t.identifier("error"),
187
+ t.blockStatement([
188
+ t.expressionStatement(
189
+ t.callExpression(
190
+ t.memberExpression(
191
+ t.identifier("span"),
192
+ t.identifier("recordException")
193
+ ),
194
+ [t.identifier("error")]
195
+ )
196
+ ),
197
+ t.expressionStatement(
198
+ t.callExpression(
199
+ t.memberExpression(
200
+ t.identifier("span"),
201
+ t.identifier("setStatus")
202
+ ),
203
+ [
204
+ t.objectExpression([
205
+ t.objectProperty(
206
+ t.identifier("code"),
207
+ t.numericLiteral(2)
208
+ ),
209
+ t.objectProperty(
210
+ t.identifier("message"),
211
+ t.logicalExpression(
212
+ "??",
213
+ t.optionalMemberExpression(
214
+ t.optionalCallExpression(
215
+ t.optionalMemberExpression(
216
+ t.optionalMemberExpression(
217
+ t.identifier("error"),
218
+ t.identifier("message"),
219
+ false,
220
+ true
221
+ ),
222
+ t.identifier("split"),
223
+ false,
224
+ true
225
+ ),
226
+ [t.stringLiteral("\n")],
227
+ false
228
+ ),
229
+ t.numericLiteral(0),
230
+ true,
231
+ false
232
+ ),
233
+ t.optionalMemberExpression(
234
+ t.optionalCallExpression(
235
+ t.optionalMemberExpression(
236
+ t.optionalCallExpression(
237
+ t.optionalMemberExpression(
238
+ t.identifier("error"),
239
+ t.identifier("toString"),
240
+ false,
241
+ true
242
+ ),
243
+ [],
244
+ false
245
+ ),
246
+ t.identifier("split"),
247
+ false,
248
+ true
249
+ ),
250
+ [t.stringLiteral("\n")],
251
+ false
252
+ ),
253
+ t.numericLiteral(0),
254
+ true,
255
+ false
256
+ )
257
+ )
258
+ )
259
+ ])
260
+ ]
261
+ )
262
+ ),
263
+ t.expressionStatement(
264
+ t.callExpression(
265
+ t.memberExpression(
266
+ t.identifier("span"),
267
+ t.identifier("end")
268
+ ),
269
+ []
270
+ )
271
+ ),
272
+ t.throwStatement(t.identifier("error"))
273
+ ])
274
+ )
275
+ )
276
+ ]),
277
+ originalFunction.async
278
+ )
279
+ ]
280
+ );
281
+ const wrapper = t.arrowFunctionExpression(
282
+ originalFunction.params,
283
+ t.blockStatement(
284
+ [
285
+ t.variableDeclaration("const", [
286
+ t.variableDeclarator(
287
+ t.identifier(wrappedFunctionName),
288
+ originalFunction
289
+ )
290
+ ]),
291
+ t.variableDeclaration("const", [
292
+ t.variableDeclarator(
293
+ t.identifier("RW_OTEL_WRAPPER_TRACER"),
294
+ t.callExpression(
295
+ t.memberExpression(
296
+ t.identifier("RW_OTEL_WRAPPER_TRACE"),
297
+ t.identifier("getTracer")
298
+ ),
299
+ [t.stringLiteral("redwoodjs")]
300
+ )
301
+ )
302
+ ]),
303
+ t.variableDeclaration("const", [
304
+ t.variableDeclarator(
305
+ t.identifier("RW_OTEL_WRAPPER_RESULT"),
306
+ originalFunction.async ? t.awaitExpression(activeSpanBlock) : activeSpanBlock
307
+ )
308
+ ]),
309
+ t.returnStatement(t.identifier("RW_OTEL_WRAPPER_RESULT"))
310
+ ],
311
+ originalFunction.body.type === "BlockStatement" ? originalFunction.body.directives : void 0
312
+ ),
313
+ originalFunction.async
314
+ );
315
+ declaration.declarations[0].init = wrapper;
316
+ }
317
+ function babel_plugin_redwood_otel_wrapping_default({ types: t }) {
318
+ return {
319
+ name: "babel-plugin-redwood-otel-wrapping",
320
+ visitor: {
321
+ Program(path) {
322
+ addOpenTelemetryImport(path, t);
323
+ },
324
+ ExportNamedDeclaration(path, state) {
325
+ wrapExportNamedDeclaration(path, state, t);
326
+ }
327
+ }
328
+ };
329
+ }
@@ -1,3 +1,26 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var babel_plugin_redwood_remove_dev_fatal_error_page_exports = {};
20
+ __export(babel_plugin_redwood_remove_dev_fatal_error_page_exports, {
21
+ default: () => babel_plugin_redwood_remove_dev_fatal_error_page_default
22
+ });
23
+ module.exports = __toCommonJS(babel_plugin_redwood_remove_dev_fatal_error_page_exports);
1
24
  function babel_plugin_redwood_remove_dev_fatal_error_page_default({ types: t }) {
2
25
  return {
3
26
  name: "babel-plugin-redwood-remove-dev-fatal-error-page",
@@ -16,6 +39,3 @@ function babel_plugin_redwood_remove_dev_fatal_error_page_default({ types: t })
16
39
  }
17
40
  };
18
41
  }
19
- export {
20
- babel_plugin_redwood_remove_dev_fatal_error_page_default as default
21
- };