@_pearofducks/require-extension-hooks-babel-7 中文文档教程
require-extension-hooks-babel-7
使用 require-extension-hooks 你可以转译 ES6/7/.. 代码以在节点中运行。 尽管 node 支持 99.999% 的 ES6 特性,但有一个主要遗漏:导出/导入语法。
Installation
npm install require-extension-hooks require-extension-hooks-babel-7 --save-dev
Usage
const hooks = require('require-extension-hooks');
hooks('js').exclude(({filename}) => filename.match(/\/node_modules\//).plugin('babel', {}).push();
// elsewhere...
import {foo} from './foo';
注意:这个 fork 不会尝试为你排除文件,你必须指定一个如上所示的“排除”条件,否则事情会变得非常糟糕。
第二个参数允许你配置将哪些选项传递给 babel 的转换函数。 默认情况下,它包含一个节点:当前配置仅使用该节点没有的 babel polyfills。
require-extension-hooks-babel-7
Using require-extension-hooks you can transpile ES6/7/.. code to run in node. Although node supports 99.999% of ES6 features there is one major omission: export/import syntax.
Installation
npm install require-extension-hooks require-extension-hooks-babel-7 --save-dev
Usage
const hooks = require('require-extension-hooks');
hooks('js').exclude(({filename}) => filename.match(/\/node_modules\//).plugin('babel', {}).push();
// elsewhere...
import {foo} from './foo';
Note: This fork makes no attempt to exclude files for you, you must specify an 'exclude' condition as shown above or things will go horribly wrong for you.
The second argument allows you to configure which options are passed into babel's transform function. By default this contains a node : current configuration to only use babel polyfills that node doesn't have.