Since you are just using gulp and not some kind of module node (like a web package)
You should follow this guide https://github.com/babel/gulp-babel#runtime
npm install
and then use it like this:
.pipe(babel({ plugins: ['transform-runtime'] }))
Gotta do the trick :)
EDIT:
It seems that babel-plugin-transform-runtime add requires calls to the converted file, so I think you will need to use the module loader. I would suggest webpack, although there are alternatives like browserify and jspm.
You will need
npm install -g webpack npm install babel-loader babel-core babel-polyfill babel-preset-es2015
Then you need to create the webpack.config.js file. Here is a very primitive setup.
module.exports = { context: __dirname + '/app', entry: ['babel-polyfill', './entries/index.js'], output: { path: 'dist', filename: '[name].js' }, module: { loaders: [ { test: /\.js/, exclude: /node_modules/, loader: 'babel', query: { presets: ['es2015'] } } ] } };
With the configuration above, the file structure should look like this:
project/ node_modules/ app/ entries/ main.js dist/ main.js webpack.config.js package.json
Then just start webpack
from the command line. If you want to run the webpack -p
mini version webpack -p
source share