( esbuildCode: string, format: string, )
| 366 | // We don't need to create a MagicString here because both the helpers and |
| 367 | // the headers don't modify the sourcemap |
| 368 | export const injectEsbuildHelpers = ( |
| 369 | esbuildCode: string, |
| 370 | format: string, |
| 371 | ): string => { |
| 372 | const contentIndex = |
| 373 | format === 'iife' |
| 374 | ? Math.max(esbuildCode.search(IIFE_BEGIN_RE), 0) |
| 375 | : format === 'umd' |
| 376 | ? esbuildCode.indexOf(`(function(`) // same for minified or not |
| 377 | : 0 |
| 378 | |
| 379 | if (contentIndex > 0) { |
| 380 | const esbuildHelpers = esbuildCode.slice(0, contentIndex) |
| 381 | return esbuildCode |
| 382 | .slice(contentIndex) |
| 383 | .replace('"use strict";', (m: string) => m + esbuildHelpers) |
| 384 | } |
| 385 | return esbuildCode |
| 386 | } |
| 387 | |
| 388 | export const buildEsbuildPlugin = (): Plugin => { |
| 389 | return { |
no outgoing calls
no test coverage detected