babel plugin for bit runner and transform for bit imports.
npm install babel-bits
Configuration for bit-imports
Options are forwarded right to babel. Take a look at all available options to fine tune babel. bit imports will automatically handle filename
.
You can take a look at bit sandbox for a sample where you can play with babel in the browser.
bitimports.plugin("js", {
transform: {
handler: "babel",
options: {
sourceMaps: "inline"
}
}
});
Or alternatively:
bitimports.config({
plugins: {
js: {
transform: {
handler: "./node_modules/babel-bits/dist/index.js",
options: {
ast: false,
sourceMaps: "inline"
}
}
}
}
});
Configuration bit runner bitrunnerfile.js
var bitRunner = require('bit-runner');
var babel = require('babel-bits');
/**
* JavaScript pipeline
*/
bitRunner.register('default', function buildPipeline(task) {
task
.load('index.js')
.then(babel)
});
The configuration settings are passed right to babel, so please refer to their docs for details on the available options.
var bitRunner = require('bit-runner');
var babel = require('babel-bits');
/**
* JavaScript pipeline
*/
bitRunner.register('default', function buildPipeline(task) {
task
.load('index.js')
.then(babel.config({ast: false}))
});
babel needs an external tool called regenerator in order to support generator
s. To bring generator
support into your application, you can just load regenerator via script tag (or equivalent) and all generator
code produced by babel will run just fine. The idea here is that the code produced by babel can find the method regeneratorRuntime
whenever it is executed.