{"version":3,"file":"webpack-loader.cjs","names":[],"sources":["../../src/webpack-loader.ts"],"sourcesContent":["import { createLoader } from './webpack-loader-factory.js';\nimport { type CustomTransform } from '@apm-js-collab/code-transformer';\nimport { type AnyInstrumentationConfig } from './instrumentation-serde.js';\n\nconst loader = createLoader();\n\n/**\n * Webpack loader that instruments JavaScript code using code-transformer\n *\n * This is a webpack loader (not a plugin) for compatibility with tools that only support loaders,\n * such as Next.js Turbopack. Unlike the other exports in this package, this does not use unplugin.\n *\n * Everything it needs arrives through loader options, which have to be\n * JSON-serializable. To use custom transforms — which are functions, and so\n * cannot — build your own loader module with `createLoader` from the\n * `/webpack-loader-factory` export and point the bundler at that instead.\n */\nfunction codeTransformerLoader(\n    this: any,\n    code: string,\n    inputSourceMap?: any\n) {\n    return loader.call(this, code, inputSourceMap);\n}\n\n// Namespace to attach types to the function\nnamespace codeTransformerLoader {\n    /**\n     * Options for the code transformer webpack loader.\n     *\n     * Turbopack requires loader options to be JSON-serializable, so any\n     * `RegExp` in `module.filePath` must be passed in its serialized\n     * `{ source, flags }` form there — see `serializeInstrumentations` in the\n     * `/core` export.\n     */\n    export interface Options {\n        /** Array of instrumentation configurations */\n        instrumentations: AnyInstrumentationConfig[];\n        /** Optional path to a polyfill module for diagnostics_channel */\n        dcModule?: string;\n        /**\n         * Custom transforms registered on the matcher via orchestrion's\n         * `addTransform`. Functions, so webpack only: Turbopack and\n         * worker-based loaders serialize their options. Bind them with\n         * `createLoader` from the `/webpack-loader-factory` export instead.\n         */\n        customTransforms?: Record<string, CustomTransform>;\n    }\n}\n\nexport default codeTransformerLoader;\n"],"mappings":";AAIA,IAAM,+CAAS,EAAA,aAAa;;;;;;;;;;;;AAa5B,SAAS,sBAEL,MACA,gBACF;CACE,OAAO,OAAO,KAAK,MAAM,MAAM,cAAc;AACjD"}