First the question:
Where can I find the external-helpers.js script, or how can I build the external-helpers for Babel 6?
In Babel 5.x, I was able to use the externalHelpers
option, which required including external-helpers.js
, which used to be in the babel-core package. Moving on to Babel 6, I see that external-helpers is now external-helpers-2 plugin. This does the job of including the relevant babelHelper
calls in my transpiled code, but that is it; I need the actual helper definitions!
In the issue add missing build script for external-helpers.js
, it is suggested to " build it yourself with the CLI". I don't see any CLI options that seem to deal with building external helpers.
I managed to build the external-helpers.js
with the babel-core package and the Node REPL:
var helperBuilder = require('./lib/tools/build-external-helpers');
fs.writeFileSync('external-helpers.js', helperBuilder());
I imagine that, depending on your situation, you could also build the external helpers file by build script (Grunt, Gulp, etc.)
The CLI command referred to in the issue you mention is babel-external-helpers
, which is part of the babel-cli
npm package. With the babel-cli
package installed, running babel-external-helpers --help
gives the following self-explanatory output:
Usage: babel-external-helpers [options]
Options:
-h, --help output usage information
-l, --whitelist [whitelist] Whitelist of helpers to ONLY include
-t, --output-type [type] Type of output (global|umd|var)
It simply outputs the file to stdout, so to print the code to a file, you do babel-external-helpers [options] > babel-helpers.js
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With