acorn-hammerhead is a specialized JavaScript parser derived from Acorn.js, specifically adapted for use within the TestCafe Hammerhead project. It is not intended as a general-purpose Acorn.js replacement, but rather provides a subset of Acorn's features tailored to Hammerhead's requirements. The current stable version is 0.6.3. Its release cadence appears irregular, driven by the needs and updates of the TestCafe Hammerhead project rather than independent feature development. Key differentiators include enhanced Unicode support and tighter integration with the Esotope library, alongside a deliberate reduction in the overall feature set compared to a full Acorn.js distribution, focusing only on the syntax elements pertinent to TestCafe's proxying and instrumentation logic. This package ships with TypeScript type definitions, enabling robust usage in TypeScript projects.
npm install acorn-hammerheadVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates parsing a simple JavaScript code snippet using `acorn-hammerhead`'s `parse` function, logging the top-level AST nodes and details of the first node.
Ensure the code being parsed adheres to the subset of features supported by TestCafe Hammerhead. If you need full Acorn.js functionality, use the original `acorn` package instead.
Only use `acorn-hammerhead` if you are specifically integrating with TestCafe's internal architecture or have confirmed its feature set meets your limited parsing needs. For general-purpose JavaScript parsing, use `acorn` or `@babel/parser`.
Upgrade to `acorn-hammerhead@0.6.3` or newer to incorporate the security fixes. Review any custom parser logic you might have that relies on specific Acorn.js internal behaviors if upgrading from very old versions.
Ensure the `ecmaVersion` option passed to `parse` (e.g., `{ ecmaVersion: 2020 }`) matches or exceeds the features used in your code. If the feature is very recent or experimental, `acorn-hammerhead` might not support it at all due to its specialized nature.Use `import { parse } from 'acorn-hammerhead';` for ESM, or `const { parse } = require('acorn-hammerhead');` for CommonJS. Verify that `parse` is indeed exported by the module in your environment.No dependency data recorded yet.