admin管理员组文章数量:1336632
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.
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.
-
Please read tag descriptions.
babel
is for questions for a Python library with said name. – Felix Kling Commented Nov 15, 2015 at 8:36 - Doh! Thanks, @FelixKling. – Lokua Commented Nov 15, 2015 at 9:52
2 Answers
Reset to default 4I 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 mand 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
.
本文标签: javascriptHow to use Babel 6 external helpers in the browserStack Overflow
版权声明:本文标题:javascript - How to use Babel 6 external helpers in the browser? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742414220a2470393.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论