babel-runtime-es2015-instance-methods
raw JSON → 0.1.2 verified Fri May 01 auth: no javascript deprecated
A Babel plugin that transforms calls to ES2015 instance methods on Array and String to helper runtime polyfills, ensuring compatibility in older environments. Version 0.1.2, no longer actively maintained. It targets specific methods (copyWithin, entries, fill, find, findIndex, keys, values for Array; codePointAt, endsWith, includes, repeat, startsWith for String) but lacks broader support and has been superseded by @babel/plugin-transform-runtime or core-js-based polyfills. No release cadence documented; last update likely years ago.
Common errors
error Error: Cannot find module 'babel-runtime-es2015-instance-methods/helpers/includes' ↓
cause Missing runtime helpers; required separate babel-runtime package.
fix
Install babel-runtime: npm install babel-runtime
error TypeError: plugin is not a function ↓
cause Using require() incorrectly with ESM default export.
fix
Use default import: const plugin = require('babel-runtime-es2015-instance-methods').default or import plugin from '...'
error ReferenceError: _includes is not defined ↓
cause Runtime helpers not loaded; likely missing babel-runtime or using in browser without bundler.
fix
Ensure babel-runtime is bundled or use a polyfill like core-js.
error SyntaxError: Unexpected token import ↓
cause Using import syntax without transpilation; only works in ES module context.
fix
Use CommonJS require in Node.js or transpile with Babel first.
error Module not found: Can't resolve 'babel-runtime-es2015-instance-methods' ↓
cause Package not installed or incorrect import path.
fix
Run npm install babel-runtime-es2015-instance-methods --save-dev
Warnings
deprecated No longer maintained; use @babel/plugin-transform-runtime with core-js instead. ↓
fix Replace with @babel/plugin-transform-runtime and configure core-js: https://babeljs.io/docs/en/babel-plugin-transform-runtime
gotcha Plugin only transforms specific methods; may miss some ES2015 methods (e.g., Array.from, Object.assign). ↓
fix Use a comprehensive polyfill like core-js directly.
breaking Requires external runtime helpers; must ensure babel-runtime is installed (deprecated). ↓
fix Install babel-runtime alongside (npm install babel-runtime).
gotcha Output uses require() for helpers; incompatible with ESM-only environments if helpers not bundled. ↓
fix Use a bundler or switch to @babel/plugin-transform-runtime with useESModules.
deprecated Package name includes 'es2015' which is outdated; Babel now uses 'env' preset. ↓
fix Migrate to @babel/preset-env with useBuiltIns: 'usage'.
Install
npm install babel-runtime-es2015-instance-methods yarn add babel-runtime-es2015-instance-methods pnpm add babel-runtime-es2015-instance-methods Imports
- default export wrong
const plugin = require('babel-runtime-es2015-instance-methods').defaultcorrectimport plugin from 'babel-runtime-es2015-instance-methods' - in .babelrc wrong
{"plugins": ["babel-runtime-es2015-instance-methods", {"loose": true}]}correct{"plugins": ["babel-runtime-es2015-instance-methods"]} - require usage wrong
const plugin = require('babel-runtime-es2015-instance-methods/default')correctconst plugin = require('babel-runtime-es2015-instance-methods') - as Babel preset
// Not designed as a preset; use as plugin only.
Quickstart
// Install: npm install --save-dev babel-runtime-es2015-instance-methods
// Then in your Babel configuration:
{
"plugins": ["babel-runtime-es2015-instance-methods"]
}
// Or programmatically:
const babel = require('@babel/core');
const plugin = require('babel-runtime-es2015-instance-methods');
babel.transformSync(code, { plugins: [plugin] });
// Input: [1,2,3].includes(2)
// Output (approximate): var _includes = require("babel-runtime-es2015-instance-methods/helpers/includes");
// _includes([1,2,3], 2);