wallabyjs / public

Repository for Wallaby.js questions and issues
http://wallabyjs.com
760 stars 45 forks source link

Unknown option .babelrc.presets #455

Closed thebuilder closed 8 years ago

thebuilder commented 8 years ago

For some reason i'm suddenly seeing this error whenever i run Wallaby. Running the tests with Karma works fine, and compiling the .js also works fine.

Failed to run compilers on src/exports.js, ReferenceError: [BABEL] src/exports.js: Unknown option: /Development/project/.babelrc.presets
at Logger.error (/Development/project/node_modules/babel-core/lib/transformation/file/logger.js:58:11)
at OptionManager.mergeOptions (/Development/project/node_modules/babel-core/lib/transformation/file/options/option-manager.js:126:29)
at OptionManager.addConfig (/Development/project/node_modules/babel-core/lib/transformation/file/options/option-manager.js:107:10)
at OptionManager.findConfigs (/Development/project/node_modules/babel-core/lib/transformation/file/options/option-manager.js:168:35)
at OptionManager.init (/Development/project/node_modules/babel-core/lib/transformation/file/options/option-manager.js:229:12)
at File.initOptions (/Development/project/node_modules/babel-core/lib/transformation/file/index.js:147:75)
at new File (/Development/project/node_modules/babel-core/lib/transformation/file/index.js:137:22)
at Pipeline.transform (/Development/project/node_modules/babel-core/lib/transformation/pipeline.js:164:16)
at Array.forEach (native)
at emitTwo (events.js:87:13)
at process.emit (events.js:172:7)
at handleMessage (internal/child_process.js:686:10)
at Pipe.channel.onread (internal/child_process.js:440:11)

My babel file currently looks like:

var wallabify = require('wallabify');

/**
 * IDE Test runner: https://github.com/wallabyjs/public
 * Runs your Jasmine tests inline
 **/
module.exports = function(wallaby) {
  return {
    files: [
      {pattern: 'node_modules/document-register-element/build/document-register-element.js"', load: true, instrument: false},
      {pattern: 'test/utils/console-error.js', load: true, instrument: false},
      {pattern: 'node_modules/gsap/src/minified/TweenMax.min.js', load: true, instrument: false},
      {pattern: 'node_modules/react/dist/react-with-addons.js', instrument: false},
      {pattern: 'src/**/*.spec.jsx', ignore: true},
      {pattern: 'src/**/*.spec.js', ignore: true},
      {pattern: 'src/**', load: false},
      {pattern: 'test/**', load: false}
    ],

    tests: [
      {pattern: 'src/**/*.spec.jsx', load: false},
      {pattern: 'src/**/*.spec.js', load: false}
    ],

    env: {
      runner: require('phantomjs-prebuilt').path,
      params: {
        runner: '--web-security=no'
      }
    },

    compilers: {
      '**/*.{js,jsx}': wallaby.compilers.babel({
        sourceMap: true
      })
    },

    setup: function() {
      require('babel-polyfill');
    },

    postprocessor: wallabify({
      // browserify options
      extensions: ['.js', '.jsx'],
      fullPaths: false
    }, function(browserify) {
      //Exclude these React libs in order for Enzyme to work
      browserify.exclude('react/lib/ExecutionEnvironment');
      browserify.exclude('react/lib/ReactContext');

      browserify.transform(require('envify'));

    }),

    bootstrap: function() {
      // required to trigger tests loading
      window.__moduleBundler.loadTests();
    }
  };
};

And .babelrc has the following presets: "presets": ["es2015", "stage-0", "react"]

I have also tried to edit the compile method in wallaby.js so it doesn't use the .babelrc, but the error message remains.

compilers: {
      '**/*.{js,jsx}': wallaby.compilers.babel({
        sourceMap: true,
        babelrc: false,
        presets: ['es2015', 'stage-0', 'react'],
        plugins: ['import-glob']
      })
    },
ArtemGovorov commented 8 years ago

From the stack trace and the error it looks like your /Development/project/node_modules/babel-core/ is 5.x, hence the error. Do you have babel 6 installed locally for the project?

ArtemGovorov commented 8 years ago

By default, wallaby.js is using local project babel version, which looks like it's v5.x in your case. If you'd like to use a different version, you may need to pass the version with the setting: babel: require(...):

compilers: {
      '**/*.{js,jsx}': wallaby.compilers.babel({
        ...
        babel: require(...) // path to the desired babel version 
      })
    },
thebuilder commented 8 years ago

Hey Artem, that was the issue - thanks! I hadn't actually saved babel-core in package.json, so after running npm dedupe it was using babel-core 5 because of babel-eslint.

Installing babel-core fixed it.

ArtemGovorov commented 8 years ago

Awesome, thanks for the update!