MCPcopy Index your code
hub / github.com/getsentry/sentry-javascript / constructFunctionReExport

Function constructFunctionReExport

packages/nuxt/src/vite/utils.ts:183–205  ·  view source on GitHub ↗
(pathWithQuery: string, entryId: string)

Source from the content-addressed store, hash-verified

181 * Constructs a code snippet with function reexports (can be used in Rollup plugins as a return value for `load()`)
182 */
183export function constructFunctionReExport(pathWithQuery: string, entryId: string): string {
184 const { wrap: wrapFunctions, reexport: reexportFunctions } = extractFunctionReexportQueryParameters(pathWithQuery);
185
186 return wrapFunctions
187 .reduce(
188 (functionsCode, currFunctionName) =>
189 functionsCode.concat(
190 `async function ${currFunctionName}_sentryWrapped(...args) {\n` +
191 ` const res = await import(${JSON.stringify(entryId)});\n` +
192 ` return res.${currFunctionName}.call(this, ...args);\n` +
193 '}\n' +
194 `export { ${currFunctionName}_sentryWrapped as ${currFunctionName} };\n`,
195 ),
196 '',
197 )
198 .concat(
199 reexportFunctions.reduce(
200 (functionsCode, currFunctionName) =>
201 functionsCode.concat(`export { ${currFunctionName} } from ${JSON.stringify(entryId)};`),
202 '',
203 ),
204 );
205}
206
207/**
208 * Sets up alias to work around OpenTelemetry's incomplete ESM imports.

Callers 2

utils.test.tsFile · 0.90
loadFunction · 0.90

Tested by

no test coverage detected