Registry /
testing / babel-plugin-transform-hook-names
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
default import (plugin)
✓ module.exports = { plugins: ['babel-plugin-transform-hook-names'] }
✗ plugins: ['transform-hook-names']
Use full npm package name in babel config; not just the suffix
addHookName
✓ import { addHookName } from 'preact/devtools'
✗ import { addHookName } from 'babel-plugin-transform-hook-names'
addHookName is exported by preact/devtools, not by this plugin
Plugin programmatic use
✓ const plugin = require('babel-plugin-transform-hook-names')
✗ const plugin = require('babel-plugin-transform-hook-names').default
Plugin is CommonJS; no default export
Installs the Babel plugin and shows how it transforms hook calls to include names for Preact DevTools.
// Install: npm install --save-dev babel-plugin-transform-hook-names
// Add to .babelrc or babel.config.js:
{
"plugins": ["babel-plugin-transform-hook-names"]
}
// Example input:
import { useState, useReducer, useRef, useMemo } from 'preact/hooks';
function Foo() {
const [text, setText] = useState('hello');
const [counter, increment] = useReducer(c => c + 1, 0);
const rootElement = useRef();
const memo = useMemo(() => text.toUpperCase(), [text]);
}
// Output (in bundle):
// import { addHookName } from 'preact/devtools';
// ... const [text, setText] = addHookName(useState('hello'), 'text');
Errors
Common errors & fixes
Error: Cannot find module 'babel-plugin-transform-hook-names'
Plugin not installed or not saved as devDependency
fixnpm install --save-dev babel-plugin-transform-hook-names
SyntaxError: Unexpected token: plugin 'babel-plugin-transform-hook-names' is missing
Babel version < 7.12
fixUpdate @babel/core to version >= 7.12.10
Hook names not appearing in Preact DevTools
addHookName from preact/devtools not being called (e.g., plugin not transforming)
fixVerify plugin is in babel config, and preact/devtools is imported at runtime
TypeError: addHookName is not a function
preact/devtools not installed or addHookName not exported in that version
fixEnsure preact is installed and version includes addHookName (preact >= 10.5)
Audit
Dependencies
@babel/corerequiredpeer dependency required for Babel plugin to function