{"record":{"id":"ea17a99431437a8e","repo":"remix-run/remix","slug":"import-meta-hot-accept-can-only-accept-a-callbac","errorCode":null,"errorMessage":"import.meta.hot.accept() can only accept a callback, a string literal, or an array of string literals.","messagePattern":"import\\.meta\\.hot\\.accept\\(\\) can only accept a callback, a string literal, or an array of string literals\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/node-hmr/src/lib/hmr-analysis.ts","lineNumber":66,"sourceCode":"  }\n\n  walkAst(parseResult.program, (node) => {\n    if (isImportMetaHotNode(node)) {\n      usesImportMetaHot = true\n    }\n\n    if (node.type !== 'CallExpression') return\n    if (!isImportMetaHotAcceptCallee(node.callee)) return\n\n    let [firstArgument] = node.arguments\n    if (firstArgument === undefined || isSelfAcceptArgument(firstArgument)) {\n      selfAccepting = true\n      return\n    }\n\n    let deps = getAcceptedDependencies(firstArgument)\n    if (deps === null) {\n      throw new TypeError(invalidAcceptMessage)\n    }\n\n    acceptedDeps.push(...deps)\n  })\n\n  return {\n    acceptedDeps,\n    selfAccepting,\n    usesImportMetaHot,\n  }\n}\n\nfunction isImportMetaHotAcceptCallee(node: Node): boolean {\n  let callee = unwrapChainExpression(node)\n  if (callee.type !== 'MemberExpression') return false\n  if (callee.computed || !isIdentifierNode(callee.property, 'accept')) return false\n\n  return isImportMetaHotNode(callee.object)","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/remix-run/remix/blob/9696913134be3a4423513d2775f7b31d6917c049/packages/node-hmr/src/lib/hmr-analysis.ts#L48-L84","documentation":"During HMR accept-analysis, import.meta.hot.accept() must be called with no arguments (self-accept), a single string literal dependency, or an array of string literals. Passing variables, expressions, non-string values, or unexpected extra arguments makes hot-update boundaries unresolvable statically, so analysis throws a TypeError with this message.","triggerScenarios":"Calling import.meta.hot.accept(someVariable), accept(['a', condition ? 'b' : 'c']), accept(123), or accept with dynamic/computed dependency expressions in a module processed by node-hmr's HMR analysis.","commonSituations":"Refactoring HMR code to use computed dependency names; copy-pasting Vite patterns that use variables; generated code inserting non-literal arguments.","solutions":["Use literal strings: import.meta.hot.accept('./dep.ts') or accept(['./a.ts', './b.ts'])","For self-accepting modules call import.meta.hot.accept() with no arguments","Keep dependency lists static — build literal arrays at the call site, not from variables"],"exampleFix":"// before\nlet dep = './counter.ts'\nimport.meta.hot.accept(dep)\n\n// after\nimport.meta.hot.accept(['./counter.ts'])\n// or, if the module accepts its own updates:\nimport.meta.hot.accept()","handlingStrategy":"validation","validationCode":"// keep accept calls static; verify with a quick grep before running:\n// every import.meta.hot.accept( call should have (), ('...') or (['...','...'])","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only pass string literals or literal arrays to import.meta.hot.accept","Use import.meta.hot.accept() with no args for self-accepting modules","Never compute dependency paths dynamically inside accept()"],"tags":["node-hmr","vite-hmr","static-analysis"],"backgroundTag":"hmr-accept-invalid-arguments","analyzedSha":"9696913134be3a4423513d2775f7b31d6917c049","analyzedAt":"2026-08-27T19:55:01.024Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}