babel-runtime-amd
raw JSON → 1.1.4 verified Sat Apr 25 auth: no javascript maintenance
AMD version of babel-runtime (v1.1.4, last updated 2016). Provides AMD modules of babel-runtime, core-js, regenerator-runtime, and babel-polyfill for use in AMD environments like RequireJS. Includes a pre-built bundle (bundle.min.js) for easy inclusion. Enables Babel's transform-runtime plugin in browser-based AMD setups. Low maintenance, no recent updates, intended for legacy projects.
Common errors
error Module name 'babel-runtime' has not been loaded yet for context: use require([]) ↓
cause Using synchronous require instead of AMD async require.
fix
Use require(['babel-runtime'], function(runtime) { ... }) instead of var runtime = require('babel-runtime');
error Error: Mismatched anonymous define() module: function (...) { ... } ↓
cause Multiple anonymous define calls, possibly from bundle and individual modules.
fix
Ensure you either use the pre-built bundle OR individual modules, not both. If using bundle, exclude other babel-runtime paths.
error ReferenceError: regeneratorRuntime is not defined ↓
cause regenerator-runtime not loaded before using generators/async.
fix
Require ['regenerator-runtime'] before using generator functions, or use the bundle that includes it.
Warnings
deprecated Package is based on outdated babel-runtime v6 and babel-plugin-transform-runtime. Modern Babel (v7+) uses @babel/runtime and @babel/plugin-transform-runtime. ↓
fix Use @babel/runtime and @babel/plugin-transform-runtime for current Babel versions.
gotcha The pre-built bundle.js is large (>1MB) and may not be tree-shaken. For optimal performance, prefer individual modules. ↓
fix Use the per-module approach with paths and exclude from bundle, or only include needed helpers.
gotcha Package has not been updated since 2016. No support for newer JavaScript features or Babel versions. ↓
fix Consider using alternative AMD-friendly runtime polyfills like core-js-bundle.
gotcha The bundle.min.js includes all helpers unconditionally; may conflict with other AMD modules if not properly excluded. ↓
fix Add excludeShallow configuration to opt out of bundling duplicate helpers.
Install
npm install babel-runtime-amd yarn add babel-runtime-amd pnpm add babel-runtime-amd Imports
- babel-runtime wrong
var runtime = require('babel-runtime');correctrequire(['babel-runtime'], function(runtime) { ... }) - core-js wrong
import 'core-js'correctrequire(['core-js'], function(core) { ... }) - regenerator-runtime wrong
const regeneratorRuntime = require('regenerator-runtime');correctrequire(['regenerator-runtime'], function(generator) { ... }) - babel-polyfill wrong
import 'babel-polyfill'correctrequire(['babel-polyfill'])
Quickstart
// 1. Install: npm install babel-runtime-amd --save-dev
// 2. In your RequireJS config, add paths:
requirejs.config({
paths: {
'babel-runtime': 'node_modules/babel-runtime-amd/babel-runtime',
'core-js': 'node_modules/babel-runtime-amd/core-js',
'regenerator-runtime': 'node_modules/babel-runtime-amd/regenerator-runtime'
}
});
// 3. Use in your module:
define(['babel-runtime/helpers/classCallCheck'], function(classCallCheck) {
function MyClass() {
classCallCheck(this, MyClass);
}
return MyClass;
});