{"id":18996,"library":"babel-helper-modules","title":"babel-helper-modules","description":"Provides Babel's internal helper functions (like _classCallCheck, _extends, etc.) as individual ES5 modules that can be imported directly. Version 6.0.0 is the latest stable release. Unlike babel-runtime which bundles core-js, this package avoids core-js dependencies, giving users freedom to choose their own polyfill (e.g., @babel/polyfill). Designed to be used with babel-plugin-transform-helper-modules to replace helper calls with direct imports, reducing bundle size and avoiding duplicate helper code. Supports only CommonJS require syntax and is intended for Node/Babel build pipelines.","status":"active","version":"6.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/mntnoe/babel-helper-modules","tags":["javascript"],"install":[{"cmd":"npm install babel-helper-modules","lang":"bash","label":"npm"},{"cmd":"yarn add babel-helper-modules","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-helper-modules","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package does not ship ESM; only CommonJS require is supported.","wrong":"import { classCallCheck } from 'babel-helper-modules';","symbol":"classCallCheck","correct":"var classCallCheck = require('babel-helper-modules').classCallCheck;"},{"note":"The helper name 'extends' conflicts with a JavaScript reserved word; assign to a different variable.","wrong":"import extends from 'babel-helper-modules';","symbol":"extends","correct":"var _extends = require('babel-helper-modules').extends;"},{"note":"CommonJS only; no default export.","wrong":"import { objectWithoutProperties } from 'babel-helper-modules';","symbol":"objectWithoutProperties","correct":"var objectWithoutProperties = require('babel-helper-modules').objectWithoutProperties;"}],"quickstart":{"code":"var classCallCheck = require('babel-helper-modules').classCallCheck;\nvar inherits = require('babel-helper-modules').inherits;\nvar extendsHelper = require('babel-helper-modules').extends;\nvar objectWithoutProperties = require('babel-helper-modules').objectWithoutProperties;\nvar possibleConstructorReturn = require('babel-helper-modules').possibleConstructorReturn;\n\n// Example usage\nfunction Child() {\n  classCallCheck(this, Child);\n  var self = possibleConstructorReturn(this, (Child.__proto__ || Object.getPrototypeOf(Child)).call(this));\n  return self;\n}\ninherits(Child, Parent);\nvar _ref = someObject;\nvar a = _ref.a;\nvar rest = objectWithoutProperties(_ref, ['a']);\nvar newObj = extendsHelper({}, rest, { b: 2 });","lang":"javascript","description":"Shows importing and using multiple Babel helper modules from the package, demonstrating classCallCheck, inherits, extends, objectWithoutProperties, and possibleConstructorReturn."},"warnings":[{"fix":"Use `var helper = require('babel-helper-modules').helperName;` instead of `import`.","message":"Package is CommonJS-only; ESM import patterns (import/export) will fail. Only use require().","severity":"gotcha","affected_versions":">=6.0.0"},{"fix":"Assign to a different variable name: `var _extends = require('babel-helper-modules').extends;`","message":"The helper name 'extends' must be aliased when assigning because 'extends' is a reserved word in JavaScript.","severity":"gotcha","affected_versions":">=6.0.0"},{"fix":"Migrate to @babel/runtime and @babel/plugin-transform-runtime for Babel 7+.","message":"This package is a legacy artifact from Babel 6 era. Babel 7 uses @babel/helpers and @babel/runtime. New projects should prefer @babel/runtime with appropriate transform plugin.","severity":"deprecated","affected_versions":">=6.0.0"},{"fix":"Create a custom .d.ts file or use `require` with `@ts-ignore`.","message":"No TypeScript type definitions are provided. Using this package in a TypeScript project will require manual type declarations.","severity":"gotcha","affected_versions":">=6.0.0"},{"fix":"Add @babel/polyfill or core-js to your project and import it early.","message":"Package does not include core-js polyfills; you must provide your own polyfill (e.g., @babel/polyfill) for instance methods like Array.prototype.find.","severity":"gotcha","affected_versions":">=6.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Change to `var helper = require('babel-helper-modules').helperName;`","cause":"Trying to use ES import syntax with a CommonJS-only package.","error":"SyntaxError: Cannot use import statement outside a module"},{"fix":"Ensure you use `require('babel-helper-modules').classCallCheck` and not `require('babel-helper-modules')` alone.","cause":"Incorrectly accessing the helper (e.g., importing default instead of named).","error":"TypeError: _classCallCheck is not a function"},{"fix":"Rename the imported helper: `var _extends = require('babel-helper-modules').extends;`","cause":"Variable name 'extends' is reserved; using it as a variable name without renaming.","error":"Uncaught SyntaxError: Unexpected token 'extends'"},{"fix":"Run `npm install babel-helper-modules --save` or `yarn add babel-helper-modules`.","cause":"Package not installed or missing from node_modules.","error":"Module not found: Error: Can't resolve 'babel-helper-modules'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}