parcel-bundler/parcel · error · Error
${pluginName} does not have a generate method
Error message
${pluginName} does not have a generate method What it means
`generateFromAST` (in assetUtils) loads the transformer plugin that produced the asset's AST, then calls its `generate()`. If the plugin object has no `generate` function bound, there is nothing to run and Parcel reports which plugin is at fault via the interpolated name.
Source
Thrown at packages/core/core/src/assetUtils.js:168
if (ast == null) {
throw new Error('Asset has no AST');
}
let pluginName = nullthrows(asset.value.plugin);
let {plugin} = nullthrows(
await loadPlugin<Transformer<mixed>>(
pluginName,
fromProjectPath(
asset.options.projectRoot,
nullthrows(asset.value.configPath),
),
nullthrows(asset.value.configKeyPath),
asset.options,
),
);
let generate = plugin.generate?.bind(plugin);
if (!generate) {
throw new Error(`${pluginName} does not have a generate method`);
}
let {content, map} = await generate({
asset: new PublicAsset(asset),
ast,
options: new PluginOptions(asset.options),
logger: new PluginLogger({origin: pluginName}),
tracer: new PluginTracer({origin: pluginName, category: 'asset-generate'}),
});
let mapBuffer = map?.toBuffer();
// Store the results in the cache so we can avoid generating again next time
await Promise.all([
asset.options.cache.setStream(
nullthrows(asset.value.contentKey),
blobToStream(content),
),
mapBuffer != null &&View on GitHub (pinned to 59484858a1)
Solutions
- Ensure the named plugin implements `generate`.
- Switch to a transformer that supports generation (e.g. `@parcel/transformer-js`).
- If you authored the plugin, add `generate({asset, ast, options})` returning `{content, map}`.
Example fix
// before
export default new Transformer({ transform({asset}) { ... } });
// after
export default new Transformer({
transform({asset}) { ... },
generate({asset, ast}) { return {content: print(ast)}; }
}); Defensive patterns
Strategy: type-guard
Validate before calling
// Confirm the plugin exposes generate before relying on AST generation.
if (typeof plugin.generate !== 'function') {
throw new Error(`${name} cannot generate; choose an AST-capable transformer`);
} Type guard
function hasGenerate(p: {generate?: Function}): boolean {
return typeof p.generate === 'function';
} Prevention
- Prefer @parcel/transformer-js for JS AST flows.
- Document generate() as required in your transformer's README.
When it happens
Trigger: An asset whose `configPath`/`configKeyPath` points at a transformer plugin that lacks a `generate` method is asked to generate code from its AST.
Common situations: A third-party transformer that parses but doesn't implement generate; a transformer plugin that was partially authored.
Related errors
- Asset has an AST but no generate method is available on the
- Cannot call getCode() on an asset with a dirty AST. For tran
- Bundle is not inline and unable to retrieve contents
- Local plugins are not supported in Parcel config packages. P
- Could not determine version of ${pluginName} in ${path.relat
AI-assisted analysis of parcel-bundler/parcel@59484858a1 (2026-08-13).
Data as JSON: /api/errors/4eba8e708a1fd262.
Report an issue: GitHub.