{"record":{"id":"3739e3cea719bce9","repo":"GoogleChrome/lighthouse","slug":"uistrings-exported-but-no-definition-found-rela","errorCode":null,"errorMessage":"UIStrings exported but no definition found: ${relativeToRootPath}","messagePattern":"UIStrings exported but no definition found: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/scripts/i18n/collect-strings.js","lineNumber":582,"sourceCode":"  const files = glob.sync(globPattern, {\n    cwd: LH_ROOT,\n    ignore: ignoredPathComponents,\n  });\n\n  for (const relativeToRootPath of files) {\n    const absolutePath = path.join(LH_ROOT, relativeToRootPath);\n    if (!process.env.CI) console.log('Collecting from', relativeToRootPath);\n\n    const content = fs.readFileSync(absolutePath, 'utf8');\n    const exportVars = await import(pathToFileURL(absolutePath).href);\n    const regexMatch = content.match(UISTRINGS_REGEX);\n    const exportedUIStrings = exportVars.UIStrings || exportVars.default?.UIStrings;\n\n    if (!regexMatch) {\n      // No UIStrings found in the file text or exports, so move to the next.\n      if (!exportedUIStrings) continue;\n\n      throw new Error('UIStrings exported but no definition found: ' + relativeToRootPath);\n    }\n\n    if (!exportedUIStrings) {\n      throw new Error('UIStrings defined in file but not exported');\n    }\n\n    // just parse the UIStrings substring to avoid ES version issues, save time, etc\n    const justUIStrings = 'const ' + regexMatch[0];\n    const parsedMessages = parseUIStrings(justUIStrings, exportedUIStrings);\n\n    for (const [key, parsed] of Object.entries(parsedMessages)) {\n      const {message, description, examples} = parsed;\n      const converted = convertMessageToCtc(message, examples);\n\n      // Don't include placeholders if there are none.\n      const placeholders = Object.keys(converted.placeholders).length === 0 ?\n          undefined :\n          converted.placeholders;","sourceCodeStart":564,"sourceCodeEnd":600,"githubUrl":"https://github.com/GoogleChrome/lighthouse/blob/9515cd4e58ebed69f78742d932b501c2cab8ad8f/core/scripts/i18n/collect-strings.js#L564-L600","documentation":"Thrown during collection when a module exports `UIStrings` (or `default.UIStrings`) at runtime, but the UISTRINGS_REGEX pattern cannot find a matching definition in the raw file text. This means the export exists dynamically but the static text-based parser cannot locate the definition to extract messages.","triggerScenarios":"Exporting UIStrings via a computed property, re-export from another module, dynamic spread, or any pattern that defeats the simple regex-based text scan — e.g. `export {UIStrings} from './other'` or `module.exports.UIStrings`.","commonSituations":"Refactoring how UIStrings is exported; using re-exports instead of inline definitions; CommonJS-style exports in a file the scanner expects ESM from.","solutions":["Define UIStrings as a top-level `const UIStrings = {...}` literal in the same file that exports it.","Ensure the export uses `export const UIStrings` or `export {UIStrings}` referencing a directly-defined const matching UISTRINGS_REGEX.","Avoid re-exporting UIStrings from another module in files scanned by collect-strings."],"exampleFix":"// before\nexport {UIStrings} from './strings.js'\n// after\nconst UIStrings = {\n  /** @description My message */\n  myMessage: 'My message',\n};\nexport {UIStrings};","handlingStrategy":"validation","validationCode":"const UISTRINGS_REGEX = /(?:const|let|var)\\s+UIStrings\\s*=\\s*\\{/;\nfunction hasInlineUIStringsDefinition(fileText) {\n  return UISTRINGS_REGEX.test(fileText);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Define UIStrings as a top-level const literal in the same file that exports it.","Avoid re-exporting UIStrings from another module.","Use the standard `const UIStrings = {...}; export {UIStrings};` pattern."],"tags":["i18n","uistrings","export","collect-strings","regex"],"backgroundTag":null,"analyzedSha":"9515cd4e58ebed69f78742d932b501c2cab8ad8f","analyzedAt":"2026-08-13T06:28:10.346Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}