npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

babel-runtime-amd

v1.1.3

Published

An AMD version of the babel-runtime

Downloads

1,312

Readme

babel-runtime-amd

An AMD version of the babel-runtime.

This package allows you to use Babel's transform-runtime plugin in an AMD environment - typically a browser using RequireJS. I hacked this together because I could not find anything else for this purpose and my search suggests other people might find this useful too. If you are interested in seeing additional features developed or bugs fixed, don't hesitate to submit an issue on github.

Install

npm install babel-runtime-amd --save-dev

Contents

This package contains an AMD version of babel-runtime, as well as AMD versions of its dependencies, core-js and regenerator-runtime. For convenience, it also contains an AMD version of babel-polyfill. An optimized bundle using RequireJS's r.js is also provided.

Usage

The following instructions assume a browser environment, but should be adaptable to others.

There are two main ways of using this package: either include the entire bundle before including your own code, or optimize your code against specific files and include only the modules you need. In both cases, a change to your Babel build configuration is probably required. If you are using the Babel polyfill, see the notes at the end.

Configure Babel

Install and configure the transform-runtime plugin for Babel:

npm i babel-plugin-transform-runtime --save-dev
{
    "plugins": [
        ["transform-runtime", {
            "helpers": true,
            "regenerator": true,
            "polyfill": false
        }]
    ]
}

Using the pre-built bundle

Include the bundle using a script tag or load it using RequireJS:

<script src="/js/bundle.min.js"></script>
require(['bundle.min']);

When bundling your project, add the following to the RequireJS optimizer config:

const glob = require('glob');
let rjsConfig = {
    paths: {
        'babel-runtime': 'path/to/node_modules/babel-runtime-amd/babel-runtime',
        'core-js': 'path/to/node_modules/babel-runtime-amd/core-js',
        'regenerator-runtime': 'path/to/node_modules/babel-runtime-amd/regenerator-runtime',
    },
    excludeShallow: glob.sync('**/*.js', { cwd: 'path/to/node_modules/babel-runtime-amd' }).map(f => f.replace(/\.js$/, '')),
    findNestedDependencies: true,
};

This tells RequireJS where to find the babel-runtime, core-js and regenerator-runtime modules during optimization, and then to exclude every module present in babel-runtime-amd from the final build, since they are already present in bundle.min.js.

Using only the modules you need

When you don't want to use the pre-built bundle, but only use the modules you actually need, the following configuration should suffice:

let rjsConfig = {
    paths: {
        'babel-runtime': 'path/to/node_modules/babel-runtime-amd/babel-runtime',
        'core-js': 'path/to/node_modules/babel-runtime-amd/core-js',
        'regenerator-runtime': 'path/to/node_modules/babel-runtime-amd/regenerator-runtime',
    },
    findNestedDependencies: true,
};

Notes on the babel-polyfill

It is possible to apply the babel-polyfill when using the pre-built bundle using:

require(['babel-polyfill']);

This applies the core-js shim and also includes the regenerator-runtime in a global variable. If you only want the shim, do:

require(['core-js/shim']);

License

Copyright Bennie Swart. Licensed under the MIT license.