{"id":26773,"library":"babel-plugin-canyon","title":"babel-plugin-canyon","description":"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.","status":"active","version":"2.0.58","language":"javascript","source_language":"en","source_url":"https://github.com/canyon-project/canyon","tags":["javascript","babel-plugin","canyon","coverage","instrumentation"],"install":[{"cmd":"npm install babel-plugin-canyon","lang":"bash","label":"npm"},{"cmd":"yarn add babel-plugin-canyon","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-plugin-canyon","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required to send coverage data to the Canyon server","package":"axios","optional":false}],"imports":[{"note":"This is a Babel plugin, not imported directly in code. It is used as a plugin in Babel configuration.","wrong":"// Using require() in .babelrc.json may not work; use module.exports for .babelrc.js","symbol":"babel-plugin-canyon","correct":"// In Babel config: module.exports = { plugins: ['canyon'] };"},{"note":"The package name is 'babel-plugin-canyon' but the plugin should be referenced as 'canyon' in Babel config.","wrong":"","symbol":"default (plugin)","correct":"import canyonPlugin from '@canyonjs/babel-plugin'; // Not the npm package name"},{"note":"There is no 'reportCoverage' export; coverage reporting is handled internally by the plugin.","wrong":"","symbol":"reportCoverage","correct":"import { reportCoverage } from '@canyonjs/babel-plugin'; // Not exported from this package"}],"quickstart":{"code":"// Install the plugin\nnpm install --save-dev babel-plugin-canyon\n\n// Configure Babel (e.g., in babel.config.js)\nmodule.exports = {\n  presets: ['@babel/preset-env'],\n  plugins: [\n    ['canyon', {\n      // Optional: specify a coverage report endpoint\n      endpoint: 'https://canyon.example.com/api/coverage',\n      // Optional: include CI/CD environment variables\n      repoName: process.env.CI_PROJECT_NAME || 'my-repo',\n      commitSha: process.env.CI_COMMIT_SHA || ''\n    }]\n  ]\n};\n\n// Run your tests with Babel\nnpx babel src --out-dir lib\n\n// Or use with Jest: add to jest.config.js\n// transform: { '^.+\\\\.js$': 'babel-jest' }","lang":"javascript","description":"Shows how to install and configure the Babel plugin in a project to instrument code and send coverage to Canyon server."},"warnings":[{"fix":"Upgrade to v3.x and update plugin options according to the new documentation (https://docs.canyonjs.io/cn/docs/ecosystem/babel-plugin-canyon).","message":"Version 2.x uses a different API than v3.x. The plugin configuration options changed in v3.0.0.","severity":"breaking","affected_versions":">=2.0.0 <3.0.0"},{"fix":"Migrate to @canyonjs/babel-plugin when available.","message":"The package is transitioning to @canyonjs/babel-plugin in future releases. The npm package 'babel-plugin-canyon' will be deprecated.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Install axios: npm install axios.","message":"The plugin requires axios as a peer dependency. If not installed, coverage reporting will fail silently.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Ensure your project uses Babel 7 or later.","message":"The plugin only works with Babel 7+. Older Babel versions are not supported.","severity":"gotcha","affected_versions":">=2.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Install axios (npm install axios) and ensure it is available at runtime.","cause":"Axios peer dependency is missing or not properly configured.","error":"TypeError: Cannot read properties of undefined (reading 'coverage')"},{"fix":"Run 'npm install --save-dev babel-plugin-canyon' and check that the package is in node_modules.","cause":"The package is not installed or Babel cannot resolve it.","error":"Error: Could not find plugin \"canyon\". Ensure there is an entry in ./node_modules/babel-plugin-canyon."},{"fix":"Use 'canyon' as the plugin name (e.g., plugins: ['canyon']).","cause":"The plugin name in Babel config is incorrect.","error":"Error: [BABEL] unknown plugin \"canyon\" specified in \"...\""}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}