Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
1 line
2.6 KiB
Plaintext
1 line
2.6 KiB
Plaintext
{"version":3,"file":"prefixLoader.js","sources":["../../../../src/config/loaders/prefixLoader.ts"],"sourcesContent":["import { escapeStringForRegex } from '@sentry/core';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport type { LoaderThis } from './types';\n\ntype LoaderOptions = {\n templatePrefix: string;\n replacements: Array<[string, string]>;\n};\n\n/**\n * Inject templated code into the beginning of a module.\n *\n * Options:\n * - `templatePrefix`: The XXX in `XXXPrefixLoaderTemplate.ts`, to specify which template to use\n * - `replacements`: An array of tuples of the form `[<placeholder>, <replacementValue>]`, used for doing global\n * string replacement in the template. Note: The replacement is done sequentially, in the order in which the\n * replacement values are given. If any placeholder is a substring of any replacement value besides its own, make\n * sure to order the tuples in such a way as to avoid over-replacement.\n */\nexport default function prefixLoader(this: LoaderThis<LoaderOptions>, userCode: string): string {\n // We know one or the other will be defined, depending on the version of webpack being used\n const { templatePrefix, replacements } = 'getOptions' in this ? this.getOptions() : this.query;\n\n const templatePath = path.resolve(__dirname, `../templates/${templatePrefix}PrefixLoaderTemplate.js`);\n // make sure the template is included when running `webpack watch`\n this.addDependency(templatePath);\n\n // Fill in placeholders\n let templateCode = fs.readFileSync(templatePath).toString();\n replacements.forEach(([placeholder, value]) => {\n // eslint-disable-next-line @sentry-internal/sdk/no-regexp-constructor -- user input is escaped\n const placeholderRegex = new RegExp(escapeStringForRegex(placeholder), 'g');\n templateCode = templateCode.replace(placeholderRegex, value);\n });\n\n return `${templateCode}\\n${userCode}`;\n}\n"],"names":[],"mappings":";;;;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAAS,YAAY,EAAkC,QAAQ,EAAkB;AAChG;AACA,EAAE,MAAM,EAAE,cAAc,EAAE,YAAA,EAAa,GAAI,YAAA,IAAgB,OAAO,IAAI,CAAC,UAAU,KAAK,IAAI,CAAC,KAAK;;AAEhG,EAAE,MAAM,YAAA,GAAe,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC,aAAa,EAAE,cAAc,CAAC,uBAAuB,CAAC,CAAC;AACvG;AACA,EAAE,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC;;AAElC;AACA,EAAE,IAAI,YAAA,GAAe,EAAE,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,QAAQ,EAAE;AAC7D,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,EAAE,KAAK,CAAC,KAAK;AACjD;AACA,IAAI,MAAM,gBAAA,GAAmB,IAAI,MAAM,CAAC,oBAAoB,CAAC,WAAW,CAAC,EAAE,GAAG,CAAC;AAC/E,IAAI,YAAA,GAAe,YAAY,CAAC,OAAO,CAAC,gBAAgB,EAAE,KAAK,CAAC;AAChE,EAAE,CAAC,CAAC;;AAEJ,EAAE,OAAO,CAAC,EAAA,YAAA,CAAA,EAAA,EAAA,QAAA,CAAA,CAAA;AACA;;;;"} |