jeffling / wallaby-webpack

webpack preprocessor for wallabyjs
25 stars 8 forks source link

using resolve.root for app code #13

Closed aaronjensen closed 9 years ago

aaronjensen commented 9 years ago

If I use resolve.root for my app code, wallaby doesn't see to pick up changes to files that I require via require('myfile') (as opposed to require('../app/myfile').

Is there something I can do to set resolve.root to the wallaby cache version of my app dir?

aaronjensen commented 9 years ago

I figured it out.

Instead of:

resolve.root = path.resolve(__dirname, 'app')

I can do:

resolve.modulesDirectories = ['js']
aaronjensen commented 9 years ago

I'm going to reopen, ideally there's a way to still use root as the semantics are different. If I can get access to the cache path, I can set the full path.

ArtemGovorov commented 9 years ago

You may use the parameter of your bootstrap function (the function executes before any tests in each worker) to get the cache folder (projectCacheDir). Would it suffice?

ArtemGovorov commented 9 years ago

Sorry, I didn't realise you were talking about Webpack until I have seen what repo this issue is in. The main configuration function (the one config object gets returned from) parameter has the same projectCacheDir property that you may use to get the cache folder path.

aaronjensen commented 9 years ago

Awesome, yeah, I forgot to update the issue by I discovered this as well. Thanks! Wallaby is amazing btw.

For posterity:

var babel = require('babel');
var wallabyWebpack = require('wallaby-webpack');
var webpackConfig = require('./webpack.wallaby.config');
var path = require('path');

module.exports = function(wallaby) {
  webpackConfig.resolve.root = path.join(wallaby.projectCacheDir, 'app');
  var wallabyPostprocessor = wallabyWebpack(webpackConfig);

  return {...}
};
ArtemGovorov commented 9 years ago

@aaronjensen Awesome, thanks!