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.

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.
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.
npm install babel-runtime-amd
yarn add babel-runtime-amd
pnpm add babel-runtime-amd

Configure RequireJS paths and import a specific babel-runtime helper AMD module.

// 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;
});