{"id":13671370,"url":"https://github.com/babel/babel-standalone","last_synced_at":"2025-10-02T23:35:34.823Z","repository":{"id":39422347,"uuid":"47487544","full_name":"babel/babel-standalone","owner":"babel","description":":video_game: Now located in the Babel repo! Standalone build of Babel for use in non-Node.js environments, including browsers.","archived":true,"fork":false,"pushed_at":"2017-12-22T17:32:02.000Z","size":243,"stargazers_count":820,"open_issues_count":12,"forks_count":122,"subscribers_count":47,"default_branch":"master","last_synced_at":"2024-05-19T16:02:16.008Z","etag":null,"topics":["babel","babel-standalone","es2015","es6","javascript"],"latest_commit_sha":null,"homepage":"https://github.com/babel/babel/tree/master/packages/babel-standalone","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/babel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["babel"],"open_collective":"babel","custom":"https://gitcoin.co/grants/2906/babel-compiler-for-next-generation-javascript"}},"created_at":"2015-12-06T07:17:30.000Z","updated_at":"2024-03-29T03:41:00.000Z","dependencies_parsed_at":"2022-09-10T18:22:26.869Z","dependency_job_id":null,"html_url":"https://github.com/babel/babel-standalone","commit_stats":null,"previous_names":["daniel15/babel-standalone"],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/babel%2Fbabel-standalone","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/babel%2Fbabel-standalone/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/babel%2Fbabel-standalone/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/babel%2Fbabel-standalone/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/babel","download_url":"https://codeload.github.com/babel/babel-standalone/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219866485,"owners_count":16554237,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["babel","babel-standalone","es2015","es6","javascript"],"created_at":"2024-08-02T09:01:07.793Z","updated_at":"2025-10-02T23:35:34.473Z","avatar_url":"https://github.com/babel.png","language":"JavaScript","readme":"# `babel-standalone` is now part of `babel`! Go [check it out](https://github.com/babel/babel/tree/master/packages/babel-standalone) :warning::warning::warning::warning:\n\nbabel-standalone\n================\n\nbabel-standalone is a standalone build of Babel for use in non-Node.js environments, including browsers. It's bundled with all the standard Babel plugins and presets, and [a build of babili (babel-minify)](http://dl.vc/babili-standalone) is optionally available too.\n\nBut why?!\n=========\n\nIt's true that using Babel through Webpack, Browserify or Gulp should be sufficient for most use cases. However, there are some valid use cases for babel-standalone:\n\n - Sites like [JSFiddle](https://jsfiddle.net/), [JS Bin](https://jsbin.com/), the [REPL on the Babel site](http://babeljs.io/repl/), etc. These sites compile user-provided JavaScript in real-time.\n - Apps that embed a JavaScript engine such as V8 directly, and want to use Babel for compilation\n  - Apps that want to use JavaScript as a scripting language for extending the app itself, including all the goodies that ES2015 provides.\n  - Integration of Babel into a non-Node.js environment ([ReactJS.NET](http://reactjs.net/), [ruby-babel-transpiler](https://github.com/babel/ruby-babel-transpiler), [php-babel-transpiler](https://github.com/talyssonoc/php-babel-transpiler), etc).\n\nInstallation\n============\n\nThere are several ways to get a copy of babel-standalone. Pick whichever one you like:\n\n- Use it via UNPKG: https://unpkg.com/babel-standalone@6/babel.min.js. This is a simple way to embed it on a webpage without having to do any other setup.\n- Install via Bower: `bower install babel-standalone`\n- Install via NPM: `npm install --save babel-standalone`\n- Manually grab `babel.js` and/or `babel.min.js` from the [GitHub releases page](https://github.com/Daniel15/babel-standalone/releases). Every release includes these files.\n- Install it via Git: You can use the repo at https://github.com/Daniel15/babel-standalone-bower to pull a prebuilt version from Git. Note that this is generally only advised for systems that *must* pull artifacts from Git, such as Bower.\n\nUsage\n=====\n\nLoad `babel.js` or `babel.min.js` in your environment. This will expose [Babel's API](http://babeljs.io/docs/usage/api/) in a `Babel` object:\n\n```js\nvar input = 'const getMessage = () =\u003e \"Hello World\";';\nvar output = Babel.transform(input, { presets: ['es2015'] }).code;\n```\n\nWhen loaded in a browser, babel-standalone will automatically compile and execute all script tags with type `text/babel` or `text/jsx`:\n```html\n\u003cdiv id=\"output\"\u003e\u003c/div\u003e\n\u003c!-- Load Babel --\u003e\n\u003cscript src=\"https://unpkg.com/babel-standalone@6/babel.min.js\"\u003e\u003c/script\u003e\n\u003c!-- Your custom script here --\u003e\n\u003cscript type=\"text/babel\"\u003e\nconst getMessage = () =\u003e \"Hello World\";\ndocument.getElementById('output').innerHTML = getMessage();\n\u003c/script\u003e\n```\n\nYou can use the `data-plugins` and `data-presets` attributes to specify the Babel plugins/presets to use:\n```html\n\u003cscript type=\"text/babel\" data-presets=\"es2015,stage-2\"\u003e\n```\n\nLoading external scripts via `src` attribute is supported too:\n```html\n\u003cscript type=\"text/babel\" src=\"foo.js\"\u003e\u003c/script\u003e\n```\n\nNote that `.babelrc` doesn't work in babel-standalone, as no file system access is available. The presets and/or plugins to use **must** be specified in the options passed to `Babel.transform`.\n\nCustomisation\n=============\nCustom plugins and presets can be added using the `registerPlugin` and `registerPreset` methods respectively:\n\n```js\n// Simple plugin that converts every identifier to \"LOL\"\nfunction lolizer() {\n  return {\n    visitor: {\n      Identifier(path) {\n        path.node.name = 'LOL';\n      }\n    }\n  }\n}\nBabel.registerPlugin('lolizer', lolizer);\n```\n\nOnce registered, just use the name of the plugin:\n\n```js\nvar output = Babel.transform(\n  'function helloWorld() { alert(hello); }',\n  {plugins: ['lolizer']}\n);\n// Returns \"function LOL() { LOL(LOL); }\"\n```\n\nCustom plugins also work for inline `\u003cscript\u003e`s:\n\n```html\n\u003cscript type=\"text/babel\" data-plugins=\"lolizer\"\u003e\n```\n\nManually Building\n=================\n\nIf you want to manually upgrade the Babel version used by babel-standalone (or build your own release), follow these steps:\n\n1. Upgrade the Babel versions in `package.json`. This can be done with `npm-check-upgrades` (eg. `npm-check-updates -u -a --packageFile ./package.json /^babel\\-/`)\n2. Delete `node_modules`, as npm often produces inefficient directory layouts if you upgrade in-place\n3. Run `npm install \u0026\u0026 npm run build`\n4. Run `npm run test` to ensure it works\n5. Open `examples/example.htm` and ensure it works\n","funding_links":["https://github.com/sponsors/babel","https://opencollective.com/babel","https://gitcoin.co/grants/2906/babel-compiler-for-next-generation-javascript"],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbabel%2Fbabel-standalone","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbabel%2Fbabel-standalone","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbabel%2Fbabel-standalone/lists"}