- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我试图在运行 AVA 测试时转换源文件(及其在 node_modules 中的依赖项)。我已将 AVA 配置为需要 babel-register
并继承我的.babelrc
在 package.json
中包含以下内容的文件:
"ava": {
"require": "babel-register",
"babel": "inherit"
}
.babelrc
:
{
"presets": [ "es2015" ],
"ignore": false
}
ava
我懂了:
/Users/me/code/esri-rollup-example/node_modules/capitalize-word/index.js:2
export default input => input.replace(regexp, match => match.charAt(0).toUpperCase() + match.substr(1));
^^^^^^
SyntaxError: Unexpected token export
src/app/utils.js
)确实转换了,但它在 node_modules 中的依赖项(
capitalize-string/index
)没有。
.babelrc
的
"ignore": false
设置未传递给
babel-register
.我可以从 babel 文档中看到您可以
explicitly pass an ignore option to babel-register
,但我看不出如何从 AVA 配置中做到这一点。我什至尝试在导入源文件的行之前将以下内容添加到我的测试文件中,但我仍然看到相同的错误:
require("babel-register")({
ignore: false
});
最佳答案
这与 babel 本身的问题有关 – https://phabricator.babeljs.io/T6726
但是你可以把 babel-register
需要在单独的文件中(让我们称之为 .setup.js
):
require('babel-register')({
ignore: /node_modules\/(?!capitalize\-word)/i
});
const noop = function () {};
require.extensions['.css'] = noop; // If you want to ignore some CSS imports
"require": "babel-register"
至
"require": "./.setup.js"
关于babeljs - 使用带有 AVA 的 babel-register 和 .babelrc 的 `"ignore": false`, 但 node_modules 没有被转译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36857210/
我想使用 Ant Design 创建 React 应用程序 在文档中,它说我需要更改 .babelrc 以模块化加载文件,也来自 https://medium.com/@GeoffMiller/how
情况 所以我有一个 .babelrc像这样: { "presets": [ "es2015", "stage-2", "react" ]
我在构建我的发布 apk 时遇到问题。当我安装 lightstreamer-client 模块时出现问题。在他们的网站上,他们说你应该将此行添加到 .babelrc: “忽略”:[ “./node_m
有没有办法将 .babelrc 文件的路径提供给 babel-cli?像这样的东西: babel src --out-dir lib --config random-folder/sub-folder
如何强制 babel 不查看 .babelrc 的父目录? 我有两个 .babelrc文件:./a/.babelrc和 ./a/example/.babelrc . 我在运行 babel在 ./a/e
我对 babel.rc 配置文件有疑问。 我搜索并看到了两个不同的配置文件示例。 { "presets": [["es2015", { "modules": false }]], "plugi
在 Atom 1.18 中,每次我打开编辑器时,我的 .babelrc 文件默认为 JSON 文件类型,这使得语法突出显示看起来很不对。而且我必须不断将它改回 Babel 类型。 如何修复(暂时):
我有一个使用 babel 的项目,我很好奇 .babelrc 文件是否通常被 gitignore。我正在使用一些预设,它们是我在 .babelrc 文件中的 package.json 文件的一部分,所
这是我的 .babelrc 的样子。显然它不起作用,因为 JSON 文件中的正则表达式: { "presets": ["es2015", "react"], "plugins": ["tran
我试过了: { "env": { "development": { "option": { "cacheDirector
所以我开始了一个新的 react-native 项目,并从我之前的项目中复制了 .babelrc 文件。我已经安装了必要的插件,但出现错误 Unknown plugin transform-decor
当 require('babel/register)() 时,即使我告诉它一个自定义的 .babelrc 路径,它仍然会加载原始的 .babelrc 。如何禁止它读取.babelrc? 最佳答案 答案
我的目录结构是这样的: > build > node_modules > webpack.config.js > .babelrc > .gitignore 我的 .babelrc 看
我正在尝试运行 the exhibits在 Deck.gl 项目中。我已经克隆了存储库,切换到 exhibits 目录,然后运行: npm run browserify 这将安装软件包,没有错误,并运
目前正在探索与之相关的 webpack 不同工具。现在我正在使用 Babel 将 ES6 代码转换为 ES5 代码。我发现需要一个包含 Babel 配置的 .babelrc 文件。但是,在Babel的
我在 es2015 中使用 Babel 6 并且 react 需要 babel-preset-es2015 和 babel-preset-react。 我在 .babelrc 中添加了 presets
当我单独运行 babel 时,它会读取 .babelrc 并按预期进行转译。但是,当我使用 webpack 和 babel-loader 运行 webpack 时,它不起作用。 .babelrc {
我正在尝试将 React 添加到一个非常大的解决方案中,但网站上的一个组件使用了 Preact。我当前的 .bablerc 是 { "presets": ["env"], "ignore":
我在 IE 中运行 React 应用程序时遇到问题。于是我安装了一个babel插件并安装了。它在我同事的机器上运行良好,但我遇到了错误。 ReferenceError: Unknown plugin
我正在尝试使用 wepback cli 构建一个非常简单的脚本......几乎: import 'somelib'; import '../mylib'; 我在运行 webpack --output-
我是一名优秀的程序员,十分优秀!