{"record":{"id":"43ce304e51449547","repo":"parcel-bundler/parcel","slug":"exportname-in-src-is-not-a-function","errorCode":null,"errorMessage":"\"${exportName}\" in \"${src}\" is not a function.","messagePattern":"\"(.+?)\" in \"(.+?)\" is not a function\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/transformers/js/src/JSTransformer.js","lineNumber":578,"sourceCode":"                    asset.invalidateOnFileChange(filePath);\n                  },\n                  invalidateOnFileCreate(invalidation) {\n                    asset.invalidateOnFileCreate(invalidation);\n                  },\n                  invalidateOnEnvChange(env) {\n                    asset.invalidateOnEnvChange(env);\n                  },\n                  invalidateOnStartup() {\n                    asset.invalidateOnStartup();\n                  },\n                  invalidateOnBuild() {\n                    asset.invalidateOnBuild();\n                  },\n                };\n\n                return mod[exportName].apply(ctx, args);\n              } else {\n                throw new Error(\n                  `\"${exportName}\" in \"${src}\" is not a function.`,\n                );\n              }\n            } catch (err) {\n              // Remove parcel core from stack and build string so Rust can process errors more easily.\n              let stack = (err.stack || '').split('\\n').slice(1);\n              let message = err.message;\n              for (let line of stack) {\n                if (line.includes(__filename)) {\n                  break;\n                }\n                message += '\\n' + line;\n              }\n              throw {\n                kind: 2,\n                message,\n              };\n            }","sourceCodeStart":560,"sourceCodeEnd":596,"githubUrl":"https://github.com/parcel-bundler/parcel/blob/59484858a1a0bcbb71f74088956bb437a2db6505/packages/transformers/js/src/JSTransformer.js#L560-L596","documentation":"Thrown from the SWC macro callback right before mod[exportName].apply(ctx, args) when typeof mod[exportName] !== 'function'. So the export exists (you got past 130) but is not callable. Like 130 it is rewrapped into `{kind: 2, message}` after stripping Parcel frames out of the stack so the Rust layer can surface a clean macro-execution error.","triggerScenarios":"A macro call site names a valid export that is a value/object/constant rather than a function. The macro machinery only supports function exports because it invokes them with a MacroContext and the call's argument list.","commonSituations":"Package rename that turned a function export into a constant; importing a non-function sibling export by mistake; version skew where the macro was replaced by a config object; calling a macro before its declaration in the same module so the binding is still a let-placeholder.","solutions":["Inspect the export in the macro module: `console.log(typeof require('pkg').foo)` — it must be 'function'.","Pick the correct function export name from the package.","Pin/upgrade the macro package to a version that ships a function for that export.","If you own the macro, export a function (or a curried factory) rather than a plain object."],"exampleFix":"// before: config exported as an object\nexport const theme = { color: 'red' };\n// macro call: theme({primary: 'color'}) -> not a function\n\n// after\nexport function theme(opts) { return `...`; }","handlingStrategy":"type-guard","validationCode":"function assertMacroCallable(mod, exportName) {\n  if (typeof mod[exportName] !== 'function') {\n    throw new TypeError(`${exportName} in macro module is ${typeof mod[exportName]}, expected function`);\n  }\n}","typeGuard":"function isMacroFunction(mod, exportName) {\n  return typeof mod?.[exportName] === 'function';\n}","tryCatchPattern":null,"preventionTips":["When authoring macro packages, export functions only.","Add a unit test that asserts each public macro name resolves to a function."],"tags":["macros","swc","type-mismatch","callable"],"backgroundTag":null,"analyzedSha":"59484858a1a0bcbb71f74088956bb437a2db6505","analyzedAt":"2026-08-13T04:06:35.925Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}