【问题标题】:Configure wallaby for React-redux-es6-typescript-immutable applications为 React-redux-es6-typescript-immutable 应用程序配置 wallaby
【发布时间】:2016-01-08 03:56:38
【问题描述】:

如何为 React-redux-es6-typescript-immutable 应用程序配置 wallaby。我使用 webstorm 编辑器。我的基本代码已提交here

我在 wallaby.js 中尝试了以下代码,但它抛出了

ReferenceError:找不到变量:导出

在 src/store.ts:3

module.exports = function (wallaby) {

    return {
        files: [
            'src/*.ts'
        ],

        tests: [
            'test/*Spec.ts'
        ],

        compilers: {
            '**/*.ts': wallaby.compilers.typeScript({
                module: 5,  // ES6
                target: 2  // ES6
            })
        },
        preprocessors: {
            '**/*.js': file => require('babel-core').transform(
                file.content,
                {sourceMap: true, presets: ['es2015']})
        }
    }
}

【问题讨论】:

  • 看起来您的应用程序正在使用 CommonJs(和 Webpack),因此您需要配置 wallaby.js 以使用 webpack,如下所述wallabyjs.com/docs/integration/webpack.html
  • 添加环境变量完成了工作。我的工作小袋鼠配置如下: module.exports = function (wallaby) { return { files: [ 'src/*.ts' ], tests: [ 'test/*Spec.ts' ], env: { type: '节点'},编译器:{'*/.ts': wallaby.compilers.typeScript({ module: 1 }) } } }

标签: wallaby.js


【解决方案1】:

我的设置和你差不多。您是否尝试将env 变量设置为node

我为 babel 6 工作的 wallaby.js 配置文件如下:

module.exports = function() {
  return {
    files: [
      {pattern: "src/**/*.js*"}
    ],

    tests: [
      {pattern: "tests/integration/*.js"}
    ],

    env: {
      type: "node"
    },

    preprocessors: {
      "**/*.js": file => require("babel-core").transform(file.content, {sourceMap: true, presets: ["es2015"]})
    }
  };
};

【讨论】:

  • 添加环境变量完成了工作。谢谢 :) 我的工作小袋鼠配置如下: module.exports = function (wallaby) { return { files: [ 'src/*.ts' ], tests: [ 'test/*Spec.ts' ], env: {类型:'node' },编译器:{ '*/.ts': wallaby.compilers.typeScript({ /* 1 for CommonJs*/ module: 1 }) } } }
猜你喜欢
  • 2019-09-21
  • 2021-12-08
  • 1970-01-01
  • 2021-01-11
  • 2017-06-24
  • 2016-08-26
  • 1970-01-01
  • 2019-02-07
  • 1970-01-01
相关资源
最近更新 更多