braintrust 3.24.0 → 3.26.0
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/NOTICE +6 -0
- package/dev/dist/index.d.mts +135 -2
- package/dev/dist/index.d.ts +135 -2
- package/dev/dist/index.js +4426 -2040
- package/dev/dist/index.mjs +3594 -1208
- package/dist/apply-auto-instrumentation.js +445 -403
- package/dist/apply-auto-instrumentation.mjs +249 -207
- package/dist/auto-instrumentations/bundler/esbuild.cjs +1449 -799
- package/dist/auto-instrumentations/bundler/esbuild.d.mts +4 -4
- package/dist/auto-instrumentations/bundler/esbuild.d.ts +4 -4
- package/dist/auto-instrumentations/bundler/esbuild.mjs +5 -8
- package/dist/auto-instrumentations/bundler/next.cjs +1448 -818
- package/dist/auto-instrumentations/bundler/next.mjs +6 -29
- package/dist/auto-instrumentations/bundler/rollup.cjs +1449 -799
- package/dist/auto-instrumentations/bundler/rollup.d.mts +4 -4
- package/dist/auto-instrumentations/bundler/rollup.d.ts +4 -4
- package/dist/auto-instrumentations/bundler/rollup.mjs +5 -8
- package/dist/auto-instrumentations/bundler/vite.cjs +1449 -799
- package/dist/auto-instrumentations/bundler/vite.d.mts +4 -4
- package/dist/auto-instrumentations/bundler/vite.d.ts +4 -4
- package/dist/auto-instrumentations/bundler/vite.mjs +5 -8
- package/dist/auto-instrumentations/bundler/webpack-loader.cjs +1602 -728
- package/dist/auto-instrumentations/bundler/webpack-loader.d.ts +20 -12
- package/dist/auto-instrumentations/bundler/webpack.cjs +1449 -799
- package/dist/auto-instrumentations/bundler/webpack.d.mts +4 -4
- package/dist/auto-instrumentations/bundler/webpack.d.ts +4 -4
- package/dist/auto-instrumentations/bundler/webpack.mjs +5 -4
- package/dist/auto-instrumentations/{chunk-GSZHTAQW.mjs → chunk-6E22MYSW.mjs} +194 -93
- package/dist/auto-instrumentations/{chunk-VT6DDNKM.mjs → chunk-AKKPLXTP.mjs} +631 -194
- package/dist/auto-instrumentations/chunk-NRE4QUQR.mjs +509 -0
- package/dist/auto-instrumentations/{chunk-BURMPO7L.mjs → chunk-V5LEODRX.mjs} +2 -6
- package/dist/auto-instrumentations/{chunk-M6DLIJ2Z.mjs → chunk-XYN63IG5.mjs} +124 -194
- package/dist/auto-instrumentations/{chunk-F43DNLPD.mjs → chunk-XZHHE4Y3.mjs} +646 -510
- package/dist/auto-instrumentations/hook.mjs +894 -657
- package/dist/auto-instrumentations/index.cjs +1125 -490
- package/dist/auto-instrumentations/index.d.mts +6 -2
- package/dist/auto-instrumentations/index.d.ts +6 -2
- package/dist/auto-instrumentations/index.mjs +6 -1
- package/dist/auto-instrumentations/loader/cjs-patch.cjs +492 -195
- package/dist/auto-instrumentations/loader/cjs-patch.d.mts +2 -2
- package/dist/auto-instrumentations/loader/cjs-patch.d.ts +2 -2
- package/dist/auto-instrumentations/loader/cjs-patch.mjs +3 -2
- package/dist/auto-instrumentations/loader/esm-hook.mjs +1 -1
- package/dist/auto-instrumentations/plugin-B-aZh7EP.d.ts +30 -0
- package/dist/auto-instrumentations/plugin-Bnj4E_6B.d.mts +30 -0
- package/dist/auto-instrumentations/{types-RNPaKi9o.d.mts → types-C1fVeiCp.d.mts} +1 -1
- package/dist/auto-instrumentations/{types-RNPaKi9o.d.ts → types-C1fVeiCp.d.ts} +1 -1
- package/dist/browser.d.mts +824 -197
- package/dist/browser.d.ts +824 -197
- package/dist/browser.js +3897 -1228
- package/dist/browser.mjs +3897 -1228
- package/dist/chunk-PN7EWK66.mjs +1784 -0
- package/dist/{chunk-SU6EHKJV.js → chunk-VRZZQPAA.js} +3289 -1577
- package/dist/chunk-VYNNEKSA.js +1784 -0
- package/dist/{chunk-XE5FS7QY.mjs → chunk-XIZOM2HO.mjs} +2470 -758
- package/dist/cli.js +3596 -1211
- package/dist/edge-light.d.mts +1 -1
- package/dist/edge-light.d.ts +1 -1
- package/dist/edge-light.js +3897 -1231
- package/dist/edge-light.mjs +3897 -1231
- package/dist/index.d.mts +824 -197
- package/dist/index.d.ts +824 -197
- package/dist/index.js +750 -445
- package/dist/index.mjs +334 -29
- package/dist/instrumentation/index.d.mts +135 -6
- package/dist/instrumentation/index.d.ts +135 -6
- package/dist/instrumentation/index.js +3696 -1257
- package/dist/instrumentation/index.mjs +3696 -1257
- package/dist/vitest-evals-reporter.js +16 -16
- package/dist/vitest-evals-reporter.mjs +2 -2
- package/dist/workerd.d.mts +1 -1
- package/dist/workerd.d.ts +1 -1
- package/dist/workerd.js +3897 -1231
- package/dist/workerd.mjs +3897 -1231
- package/licenses/node-diagnostics-channel/LICENSE +19 -0
- package/package.json +34 -35
- package/dist/auto-instrumentations/plugin-D0KHwSJv.d.mts +0 -44
- package/dist/auto-instrumentations/plugin-G6fgxk1b.d.ts +0 -44
- package/dist/chunk-7AUY2XWX.js +0 -1090
- package/dist/chunk-7F6GCRHH.mjs +0 -1090
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { WebpackPluginInstance } from 'unplugin';
|
|
2
|
-
import {
|
|
3
|
-
export { I as InstrumentationConfig } from '../types-
|
|
2
|
+
import { B as BundlerPluginOptions } from '../plugin-Bnj4E_6B.mjs';
|
|
3
|
+
export { I as InstrumentationConfig } from '../types-C1fVeiCp.mjs';
|
|
4
4
|
|
|
5
5
|
declare function braintrustWebpackPlugin(options?: BundlerPluginOptions): WebpackPluginInstance;
|
|
6
|
-
type WebpackPluginOptions =
|
|
6
|
+
type WebpackPluginOptions = BundlerPluginOptions;
|
|
7
7
|
/**
|
|
8
8
|
* @deprecated Use {@link braintrustWebpackPlugin} instead.
|
|
9
9
|
*/
|
|
10
|
-
declare const webpackPlugin: (options:
|
|
10
|
+
declare const webpackPlugin: (options: BundlerPluginOptions) => WebpackPluginInstance;
|
|
11
11
|
|
|
12
12
|
export { type WebpackPluginOptions, braintrustWebpackPlugin, webpackPlugin };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { WebpackPluginInstance } from 'unplugin';
|
|
2
|
-
import {
|
|
3
|
-
export { I as InstrumentationConfig } from '../types-
|
|
2
|
+
import { B as BundlerPluginOptions } from '../plugin-B-aZh7EP.js';
|
|
3
|
+
export { I as InstrumentationConfig } from '../types-C1fVeiCp.js';
|
|
4
4
|
|
|
5
5
|
declare function braintrustWebpackPlugin(options?: BundlerPluginOptions): WebpackPluginInstance;
|
|
6
|
-
type WebpackPluginOptions =
|
|
6
|
+
type WebpackPluginOptions = BundlerPluginOptions;
|
|
7
7
|
/**
|
|
8
8
|
* @deprecated Use {@link braintrustWebpackPlugin} instead.
|
|
9
9
|
*/
|
|
10
|
-
declare const webpackPlugin: (options:
|
|
10
|
+
declare const webpackPlugin: (options: BundlerPluginOptions) => WebpackPluginInstance;
|
|
11
11
|
|
|
12
12
|
export { type WebpackPluginOptions, braintrustWebpackPlugin, webpackPlugin };
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
braintrustWebpackPlugin,
|
|
3
3
|
webpackPlugin
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-V5LEODRX.mjs";
|
|
5
|
+
import "../chunk-6E22MYSW.mjs";
|
|
6
|
+
import "../chunk-XZHHE4Y3.mjs";
|
|
7
|
+
import "../chunk-XYN63IG5.mjs";
|
|
8
|
+
import "../chunk-NRE4QUQR.mjs";
|
|
8
9
|
export {
|
|
9
10
|
braintrustWebpackPlugin,
|
|
10
11
|
webpackPlugin
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
|
+
INSTRUMENTATION_NAMES,
|
|
2
3
|
aiSDKConfigs,
|
|
3
4
|
anthropicConfigs,
|
|
4
5
|
bedrockRuntimeConfigs,
|
|
5
6
|
channel,
|
|
6
7
|
claudeAgentSDKConfigs,
|
|
8
|
+
cloudflareAIChatConfigs,
|
|
9
|
+
cloudflareAgentsConfigs,
|
|
7
10
|
cohereConfigs,
|
|
8
11
|
cursorSDKConfigs,
|
|
9
12
|
defineChannels,
|
|
@@ -22,11 +25,11 @@ import {
|
|
|
22
25
|
openRouterConfigs,
|
|
23
26
|
openaiConfigs,
|
|
24
27
|
piCodingAgentConfigs
|
|
25
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-XZHHE4Y3.mjs";
|
|
26
29
|
import {
|
|
27
30
|
applySpecialCasePatch,
|
|
28
31
|
create
|
|
29
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-XYN63IG5.mjs";
|
|
30
33
|
|
|
31
34
|
// src/auto-instrumentations/bundler/plugin.ts
|
|
32
35
|
import { createUnplugin } from "unplugin";
|
|
@@ -52,6 +55,9 @@ var envIntegrationAliases = {
|
|
|
52
55
|
strandsagentsdk: "strandsAgentSDK",
|
|
53
56
|
"strands-agent-sdk": "strandsAgentSDK",
|
|
54
57
|
"@strands-agents/sdk": "strandsAgentSDK",
|
|
58
|
+
agents: "cloudflareAgents",
|
|
59
|
+
"cloudflare-agents": "cloudflareAgents",
|
|
60
|
+
cloudflareagents: "cloudflareAgents",
|
|
55
61
|
anthropic: "anthropic",
|
|
56
62
|
aisdk: "aisdk",
|
|
57
63
|
"ai-sdk": "aisdk",
|
|
@@ -59,6 +65,9 @@ var envIntegrationAliases = {
|
|
|
59
65
|
vercel: "vercel",
|
|
60
66
|
claudeagentsdk: "claudeAgentSDK",
|
|
61
67
|
"claude-agent-sdk": "claudeAgentSDK",
|
|
68
|
+
cloudflareaichat: "cloudflareAIChat",
|
|
69
|
+
"cloudflare-ai-chat": "cloudflareAIChat",
|
|
70
|
+
"@cloudflare/ai-chat": "cloudflareAIChat",
|
|
62
71
|
cursor: "cursor",
|
|
63
72
|
"cursor-sdk": "cursorSDK",
|
|
64
73
|
cursorsdk: "cursorSDK",
|
|
@@ -73,6 +82,8 @@ var envIntegrationAliases = {
|
|
|
73
82
|
"google-genai": "googleGenAI",
|
|
74
83
|
googlegenai: "googleGenAI",
|
|
75
84
|
huggingface: "huggingface",
|
|
85
|
+
"@huggingface/transformers": "huggingface",
|
|
86
|
+
transformers: "huggingface",
|
|
76
87
|
openrouter: "openrouter",
|
|
77
88
|
openrouteragent: "openrouterAgent",
|
|
78
89
|
"openrouter-agent": "openrouterAgent",
|
|
@@ -117,12 +128,16 @@ function isInstrumentationIntegrationDisabled(integrations, ...names) {
|
|
|
117
128
|
}
|
|
118
129
|
|
|
119
130
|
// src/instrumentation/plugins/flue-channels.ts
|
|
120
|
-
var flueChannels = defineChannels(
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
131
|
+
var flueChannels = defineChannels(
|
|
132
|
+
"@flue/runtime",
|
|
133
|
+
{
|
|
134
|
+
createContext: channel({
|
|
135
|
+
channelName: "createFlueContext",
|
|
136
|
+
kind: "sync-stream"
|
|
137
|
+
})
|
|
138
|
+
},
|
|
139
|
+
{ instrumentationName: INSTRUMENTATION_NAMES.FLUE }
|
|
140
|
+
);
|
|
126
141
|
|
|
127
142
|
// src/auto-instrumentations/configs/flue.ts
|
|
128
143
|
var flueVersionRange = ">=0.8.0 <1.0.0";
|
|
@@ -141,21 +156,102 @@ var flueConfigs = [
|
|
|
141
156
|
}
|
|
142
157
|
];
|
|
143
158
|
|
|
159
|
+
// src/instrumentation/plugins/huggingface-transformers-channels.ts
|
|
160
|
+
var huggingFaceTransformersChannels = defineChannels(
|
|
161
|
+
"@huggingface/transformers",
|
|
162
|
+
{
|
|
163
|
+
pipeline: channel({
|
|
164
|
+
channelName: "pipeline",
|
|
165
|
+
kind: "async"
|
|
166
|
+
}),
|
|
167
|
+
pipelineCall: channel({
|
|
168
|
+
channelName: "pipeline.call",
|
|
169
|
+
kind: "async"
|
|
170
|
+
})
|
|
171
|
+
},
|
|
172
|
+
{ instrumentationName: INSTRUMENTATION_NAMES.HUGGINGFACE }
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
// src/auto-instrumentations/configs/huggingface-transformers.ts
|
|
176
|
+
var moduleFiles = [
|
|
177
|
+
{
|
|
178
|
+
filePath: "dist/transformers.mjs",
|
|
179
|
+
versionRange: ">=3.0.0 <3.4.0"
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
filePath: "dist/transformers.cjs",
|
|
183
|
+
versionRange: ">=3.0.0 <3.4.0"
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
filePath: "dist/transformers.js",
|
|
187
|
+
versionRange: ">=3.0.0 <3.4.0"
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
filePath: "dist/transformers.node.mjs",
|
|
191
|
+
versionRange: ">=3.4.0 <5.0.0"
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
filePath: "dist/transformers.node.cjs",
|
|
195
|
+
versionRange: ">=3.4.0 <5.0.0"
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
filePath: "dist/transformers.web.js",
|
|
199
|
+
versionRange: ">=3.4.0 <5.0.0"
|
|
200
|
+
}
|
|
201
|
+
];
|
|
202
|
+
var pipelineClasses = [
|
|
203
|
+
"TextGenerationPipeline",
|
|
204
|
+
"Text2TextGenerationPipeline",
|
|
205
|
+
"FeatureExtractionPipeline",
|
|
206
|
+
"QuestionAnsweringPipeline"
|
|
207
|
+
];
|
|
208
|
+
var huggingFaceTransformersConfigs = moduleFiles.flatMap(({ filePath, versionRange }) => [
|
|
209
|
+
{
|
|
210
|
+
channelName: huggingFaceTransformersChannels.pipeline.channelName,
|
|
211
|
+
module: {
|
|
212
|
+
name: "@huggingface/transformers",
|
|
213
|
+
versionRange,
|
|
214
|
+
filePath
|
|
215
|
+
},
|
|
216
|
+
functionQuery: {
|
|
217
|
+
functionName: "pipeline",
|
|
218
|
+
kind: "Async"
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
...pipelineClasses.map((className) => ({
|
|
222
|
+
channelName: huggingFaceTransformersChannels.pipelineCall.channelName,
|
|
223
|
+
module: {
|
|
224
|
+
name: "@huggingface/transformers",
|
|
225
|
+
versionRange,
|
|
226
|
+
filePath
|
|
227
|
+
},
|
|
228
|
+
functionQuery: {
|
|
229
|
+
className,
|
|
230
|
+
methodName: "_call",
|
|
231
|
+
kind: "Async"
|
|
232
|
+
}
|
|
233
|
+
}))
|
|
234
|
+
]);
|
|
235
|
+
|
|
144
236
|
// src/instrumentation/plugins/strands-agent-sdk-channels.ts
|
|
145
|
-
var strandsAgentSDKChannels = defineChannels(
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
237
|
+
var strandsAgentSDKChannels = defineChannels(
|
|
238
|
+
"@strands-agents/sdk",
|
|
239
|
+
{
|
|
240
|
+
agentStream: channel({
|
|
241
|
+
channelName: "Agent.stream",
|
|
242
|
+
kind: "sync-stream"
|
|
243
|
+
}),
|
|
244
|
+
graphStream: channel({
|
|
245
|
+
channelName: "Graph.stream",
|
|
246
|
+
kind: "sync-stream"
|
|
247
|
+
}),
|
|
248
|
+
swarmStream: channel({
|
|
249
|
+
channelName: "Swarm.stream",
|
|
250
|
+
kind: "sync-stream"
|
|
251
|
+
})
|
|
252
|
+
},
|
|
253
|
+
{ instrumentationName: INSTRUMENTATION_NAMES.STRANDS_AGENT_SDK }
|
|
254
|
+
);
|
|
159
255
|
|
|
160
256
|
// src/auto-instrumentations/configs/strands-agent-sdk.ts
|
|
161
257
|
var strandsAgentSDKVersionRange = ">=1.0.0 <2.0.0";
|
|
@@ -221,6 +317,14 @@ var defaultInstrumentationConfigGroups = [
|
|
|
221
317
|
integrations: ["claudeAgentSDK"],
|
|
222
318
|
configs: claudeAgentSDKConfigs
|
|
223
319
|
},
|
|
320
|
+
{
|
|
321
|
+
integrations: ["cloudflareAIChat"],
|
|
322
|
+
configs: cloudflareAIChatConfigs
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
integrations: ["cloudflareAgents"],
|
|
326
|
+
configs: cloudflareAgentsConfigs
|
|
327
|
+
},
|
|
224
328
|
{ integrations: ["cursor", "cursorSDK"], configs: cursorSDKConfigs },
|
|
225
329
|
{
|
|
226
330
|
integrations: ["openAIAgents"],
|
|
@@ -230,7 +334,10 @@ var defaultInstrumentationConfigGroups = [
|
|
|
230
334
|
integrations: ["google", "googleGenAI"],
|
|
231
335
|
configs: googleGenAIConfigs
|
|
232
336
|
},
|
|
233
|
-
{
|
|
337
|
+
{
|
|
338
|
+
integrations: ["huggingface"],
|
|
339
|
+
configs: [...huggingFaceConfigs, ...huggingFaceTransformersConfigs]
|
|
340
|
+
},
|
|
234
341
|
{
|
|
235
342
|
integrations: ["langchain", "langgraph"],
|
|
236
343
|
configs: langchainConfigs
|
|
@@ -301,78 +408,72 @@ function getModuleVersion(basedir) {
|
|
|
301
408
|
}
|
|
302
409
|
return void 0;
|
|
303
410
|
}
|
|
304
|
-
var unplugin = createUnplugin(
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
`No 'package.json' version found for module ${moduleName} at ${moduleDetails.basedir}. Skipping transformation.`
|
|
346
|
-
);
|
|
347
|
-
return null;
|
|
348
|
-
}
|
|
349
|
-
const transformer = instrumentationMatcher.getTransformer(
|
|
350
|
-
moduleName,
|
|
351
|
-
moduleVersion,
|
|
352
|
-
normalizedModulePath
|
|
411
|
+
var unplugin = createUnplugin((options = {}) => {
|
|
412
|
+
const browser = options.browser ?? options.useDiagnosticChannelCompatShim ?? false;
|
|
413
|
+
const allInstrumentations = getDefaultInstrumentationConfigs({
|
|
414
|
+
additionalInstrumentations: options.instrumentations
|
|
415
|
+
});
|
|
416
|
+
const instrumentationMatcher = create(allInstrumentations);
|
|
417
|
+
return {
|
|
418
|
+
name: "code-transformer",
|
|
419
|
+
enforce: "pre",
|
|
420
|
+
transform(code, id) {
|
|
421
|
+
if (!id) {
|
|
422
|
+
return null;
|
|
423
|
+
}
|
|
424
|
+
const cleanId = id.replace(/[?#].*$/, "");
|
|
425
|
+
const filePath = cleanId.startsWith("file:") ? fileURLToPath(cleanId) : cleanId;
|
|
426
|
+
const ext = extname(filePath);
|
|
427
|
+
let isModule = ext === ".mjs" || ext === ".ts" || ext === ".tsx";
|
|
428
|
+
if (ext === ".js") {
|
|
429
|
+
isModule = code.includes("export ") || code.includes("import ");
|
|
430
|
+
}
|
|
431
|
+
const normalizedForPlatform = filePath.split("/").join(sep);
|
|
432
|
+
const moduleDetails = moduleDetailsFromPath(normalizedForPlatform);
|
|
433
|
+
if (!moduleDetails) {
|
|
434
|
+
return null;
|
|
435
|
+
}
|
|
436
|
+
const moduleName = moduleDetails.name;
|
|
437
|
+
const normalizedModulePath = moduleDetails.path.replace(/\\/g, "/");
|
|
438
|
+
const moduleVersion = getModuleVersion(moduleDetails.basedir);
|
|
439
|
+
const patched = applySpecialCasePatch({
|
|
440
|
+
packageName: moduleName,
|
|
441
|
+
modulePath: normalizedModulePath,
|
|
442
|
+
source: code,
|
|
443
|
+
format: isModule ? "esm" : "cjs",
|
|
444
|
+
browser
|
|
445
|
+
});
|
|
446
|
+
if (patched !== null) {
|
|
447
|
+
return { code: patched, map: null };
|
|
448
|
+
}
|
|
449
|
+
if (!moduleVersion) {
|
|
450
|
+
console.warn(
|
|
451
|
+
`No 'package.json' version found for module ${moduleName} at ${moduleDetails.basedir}. Skipping transformation.`
|
|
353
452
|
);
|
|
354
|
-
|
|
355
|
-
return null;
|
|
356
|
-
}
|
|
357
|
-
try {
|
|
358
|
-
const moduleType = isModule ? "esm" : "cjs";
|
|
359
|
-
const result = transformer.transform(code, moduleType);
|
|
360
|
-
const transformedCode = result.code.replace(
|
|
361
|
-
/const \{tracingChannel: ([A-Za-z_$][\w$]*)\} = ([A-Za-z_$][\w$]*);/g,
|
|
362
|
-
"const $1 = $2.tracingChannel;"
|
|
363
|
-
);
|
|
364
|
-
return {
|
|
365
|
-
code: transformedCode,
|
|
366
|
-
map: result.map
|
|
367
|
-
};
|
|
368
|
-
} catch (error) {
|
|
369
|
-
console.warn(`Code transformation failed for ${id}: ${error}`);
|
|
370
|
-
return null;
|
|
371
|
-
}
|
|
453
|
+
return null;
|
|
372
454
|
}
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
455
|
+
const transformer = instrumentationMatcher.getTransformer(
|
|
456
|
+
moduleName,
|
|
457
|
+
moduleVersion,
|
|
458
|
+
normalizedModulePath
|
|
459
|
+
);
|
|
460
|
+
if (!transformer) {
|
|
461
|
+
return null;
|
|
462
|
+
}
|
|
463
|
+
try {
|
|
464
|
+
const moduleType = isModule ? "esm" : "cjs";
|
|
465
|
+
const result = transformer.transform(code, moduleType);
|
|
466
|
+
return {
|
|
467
|
+
code: result.code,
|
|
468
|
+
map: result.map
|
|
469
|
+
};
|
|
470
|
+
} catch (error) {
|
|
471
|
+
console.warn(`Code transformation failed for ${id}: ${error}`);
|
|
472
|
+
return null;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
};
|
|
476
|
+
});
|
|
376
477
|
|
|
377
478
|
export {
|
|
378
479
|
unplugin
|