{"id":13803729,"url":"https://github.com/babel/gulp-babel","last_synced_at":"2025-05-14T06:14:27.390Z","repository":{"id":21318499,"uuid":"24635108","full_name":"babel/gulp-babel","owner":"babel","description":"Gulp plugin for Babel","archived":false,"fork":false,"pushed_at":"2023-01-04T21:48:59.000Z","size":1008,"stargazers_count":1320,"open_issues_count":33,"forks_count":120,"subscribers_count":36,"default_branch":"master","last_synced_at":"2024-10-29T15:14:02.304Z","etag":null,"topics":["babel","gulp-plugin"],"latest_commit_sha":null,"homepage":"https://babeljs.io","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":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","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":"2014-09-30T11:11:00.000Z","updated_at":"2024-10-11T12:15:49.000Z","dependencies_parsed_at":"2023-01-13T21:24:09.291Z","dependency_job_id":null,"html_url":"https://github.com/babel/gulp-babel","commit_stats":null,"previous_names":["6to5/gulp-6to5"],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/babel%2Fgulp-babel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/babel%2Fgulp-babel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/babel%2Fgulp-babel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/babel%2Fgulp-babel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/babel","download_url":"https://codeload.github.com/babel/gulp-babel/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248314404,"owners_count":21083046,"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","gulp-plugin"],"created_at":"2024-08-04T01:00:37.300Z","updated_at":"2025-04-10T23:28:26.188Z","avatar_url":"https://github.com/babel.png","language":"JavaScript","readme":"\u003e This readme is for gulp-babel v8 + Babel v7\n\u003e Check the [7.x branch](https://github.com/babel/gulp-babel/tree/v7-maintenance) for docs with Babel v6 usage\n\n# gulp-babel [![npm](https://img.shields.io/npm/v/gulp-babel.svg?maxAge=2592000)](https://www.npmjs.com/package/gulp-babel) [![Build Status](https://travis-ci.org/babel/gulp-babel.svg?branch=master)](https://travis-ci.org/babel/gulp-babel)\n\n\u003e Use next generation JavaScript, today, with [Babel](https://babeljs.io)\n\n*Issues with the output should be reported on the Babel [issue tracker](https://phabricator.babeljs.io/).*\n\n\n## Install\n\nInstall `gulp-babel` if you want to get the pre-release of the next version of `gulp-babel`.\n\n```\n# Babel 7\n$ npm install --save-dev gulp-babel @babel/core @babel/preset-env\n\n# Babel 6\n$ npm install --save-dev gulp-babel@7 babel-core babel-preset-env\n```\n\n## Usage\n\n```js\nconst gulp = require('gulp');\nconst babel = require('gulp-babel');\n\ngulp.task('default', () =\u003e\n\tgulp.src('src/app.js')\n\t\t.pipe(babel({\n\t\t\tpresets: ['@babel/preset-env']\n\t\t}))\n\t\t.pipe(gulp.dest('dist'))\n);\n```\n\n\n## API\n\n### babel([options])\n\n#### options\n\nSee the Babel [options](http://babeljs.io/docs/en/options), except for `sourceMaps` and `filename` which is handled for you. Also, keep in mind that options will be loaded from [config files](http://babeljs.io/docs/en/config-files) that apply to each file.\n\n## Source Maps\n\nUse [gulp-sourcemaps](https://github.com/floridoo/gulp-sourcemaps) like this:\n\n```js\nconst gulp = require('gulp');\nconst sourcemaps = require('gulp-sourcemaps');\nconst babel = require('gulp-babel');\nconst concat = require('gulp-concat');\n\ngulp.task('default', () =\u003e\n\tgulp.src('src/**/*.js')\n\t\t.pipe(sourcemaps.init())\n\t\t.pipe(babel({\n\t\t\tpresets: ['@babel/preset-env']\n\t\t}))\n\t\t.pipe(concat('all.js'))\n\t\t.pipe(sourcemaps.write('.'))\n\t\t.pipe(gulp.dest('dist'))\n);\n```\n\n\n## Babel Metadata\n\nFiles in the stream are annotated with a `babel` property, which contains the metadata from [`babel.transform()`](https://babeljs.io/docs/usage/api/).\n\n#### Example\n\n```js\nconst gulp = require('gulp');\nconst babel = require('gulp-babel');\nconst through = require('through2');\n\nfunction logBabelMetadata() {\n\treturn through.obj((file, enc, cb) =\u003e {\n\t\tconsole.log(file.babel.test); // 'metadata'\n\t\tcb(null, file);\n\t});\n}\n\ngulp.task('default', () =\u003e\n\tgulp.src('src/**/*.js')\n\t\t.pipe(babel({\n\t\t\t// plugin that sets some metadata\n\t\t\tplugins: [{\n\t\t\t\tpost(file) {\n\t\t\t\t\tfile.metadata.test = 'metadata';\n\t\t\t\t}\n\t\t\t}]\n\t\t}))\n\t\t.pipe(logBabelMetadata())\n)\n```\n\n\n## Runtime\n\nIf you're attempting to use features such as generators, you'll need to add `transform-runtime` as a plugin, to include the Babel runtime. Otherwise, you'll receive the error: `regeneratorRuntime is not defined`.\n\nInstall the runtime:\n\n```\n$ npm install --save-dev @babel/plugin-transform-runtime\n$ npm install --save @babel/runtime\n```\n\nUse it as plugin:\n\n```js\nconst gulp = require('gulp');\nconst babel = require('gulp-babel');\n\ngulp.task('default', () =\u003e\n\tgulp.src('src/app.js')\n\t\t.pipe(babel({\n\t\t\tplugins: ['@babel/transform-runtime']\n\t\t}))\n\t\t.pipe(gulp.dest('dist'))\n);\n```\n\n\n## License\n\nMIT © [Sindre Sorhus](http://sindresorhus.com)\n","funding_links":["https://github.com/sponsors/babel","https://opencollective.com/babel","https://gitcoin.co/grants/2906/babel-compiler-for-next-generation-javascript"],"categories":["Build-time transpilation","插件","Plugins"],"sub_categories":["Gulp Plugins","编译","Transpilation"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbabel%2Fgulp-babel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbabel%2Fgulp-babel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbabel%2Fgulp-babel/lists"}