Registry / testing / babel-plugin-canyon

babel-plugin-canyon

JSON →
library2.0.58jsnpmunverified

A Babel plugin that cooperates with Istanbul to report code coverage data to Canyon's coverage backend. This plugin instruments JavaScript code during Babel transformation, capturing coverage information that can be sent to Canyon's server for aggregation and visualization. The current stable version is v3.0.10 and is actively maintained. It is designed specifically for use with the Canyon coverage platform, differentiating itself by tight integration with Canyon's API and support for incremental coverage reports. It requires axios as a peer dependency to communicate with the Canyon server. The plugin is suitable for CI/CD pipelines where coverage reporting is needed.

npm install babel-plugin-canyon
INSTALL
IMPORT
SIG · BABEL-PLUGIN-CANYO
B
babel-plugin-canyon
testingjavascriptv2.0.58
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

babel-plugin-canyon
// In Babel config: module.exports = { plugins: ['canyon'] };
// Using require() in .babelrc.json may not work; use module.exports for .babelrc.js
This is a Babel plugin, not imported directly in code. It is used as a plugin in Babel configuration.
default (plugin)
import canyonPlugin from '@canyonjs/babel-plugin'; // Not the npm package name
The package name is 'babel-plugin-canyon' but the plugin should be referenced as 'canyon' in Babel config.
reportCoverage
import { reportCoverage } from '@canyonjs/babel-plugin'; // Not exported from this package
There is no 'reportCoverage' export; coverage reporting is handled internally by the plugin.

Shows how to install and configure the Babel plugin in a project to instrument code and send coverage to Canyon server.

// Install the plugin npm install --save-dev babel-plugin-canyon // Configure Babel (e.g., in babel.config.js) module.exports = { presets: ['@babel/preset-env'], plugins: [ ['canyon', { // Optional: specify a coverage report endpoint endpoint: 'https://canyon.example.com/api/coverage', // Optional: include CI/CD environment variables repoName: process.env.CI_PROJECT_NAME || 'my-repo', commitSha: process.env.CI_COMMIT_SHA || '' }] ] }; // Run your tests with Babel npx babel src --out-dir lib // Or use with Jest: add to jest.config.js // transform: { '^.+\\.js$': 'babel-jest' }
Debug
Known issues
breakingVersion 2.x uses a different API than v3.x. The plugin configuration options changed in v3.0.0.
fix
Upgrade to v3.x and update plugin options according to the new documentation (https://docs.canyonjs.io/cn/docs/ecosystem/babel-plugin-canyon).
affects: >=2.0.0 <3.0.0
deprecatedThe package is transitioning to @canyonjs/babel-plugin in future releases. The npm package 'babel-plugin-canyon' will be deprecated.
fix
Migrate to @canyonjs/babel-plugin when available.
affects: >=2.0.0
gotchaThe plugin requires axios as a peer dependency. If not installed, coverage reporting will fail silently.
fix
Install axios: npm install axios.
affects: >=2.0.0
gotchaThe plugin only works with Babel 7+. Older Babel versions are not supported.
fix
Ensure your project uses Babel 7 or later.
affects: >=2.0.0
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'coverage')
Axios peer dependency is missing or not properly configured.
fix
Install axios (npm install axios) and ensure it is available at runtime.
Error: Could not find plugin "canyon". Ensure there is an entry in ./node_modules/babel-plugin-canyon.
The package is not installed or Babel cannot resolve it.
fix
Run 'npm install --save-dev babel-plugin-canyon' and check that the package is in node_modules.
Error: [BABEL] unknown plugin "canyon" specified in "..."
The plugin name in Babel config is incorrect.
fix
Use 'canyon' as the plugin name (e.g., plugins: ['canyon']).
Upgrade
Version history
2.0.58latest on npm
Audit
Dependencies
axiosrequiredRequired to send coverage data to the Canyon server
Agent activity
22 hits · last 30 days
node
20
OpenAI (training)
1
Resources
babel-plugin-canyon — npm install babel-plugin-canyon · libregistry