jeffling / wallaby-webpack

webpack preprocessor for wallabyjs
25 stars 8 forks source link

Wallaby webpack resolve.modules doesn't seem to resolve to modules. #23

Closed nathanvale closed 7 years ago

nathanvale commented 7 years ago

Hi I have a webpack config file working in my karma config file that resolve modules to the root of the project so from anywhere in my project I can import like this

import { User } from 'components/icons/FontAwesomeIcon';

instead of

import { User } from '../../../../../components/icons/FontAwesomeIcon';

npm test works and resolve is fine but my wallaby config cant seem to resolve to it.

The configs are almost identical

https://github.com/nathanvale/react-enterprise/blob/master/app/test/karma.conf.js

https://github.com/nathanvale/react-enterprise/blob/master/wallaby.js

Are you able to see where I am going wrong here?

i really dont want to be seeing messages like

​​Error: Cannot find module "components/icons/FontAwesomeIcon"​​

Thanks!

ArtemGovorov commented 7 years ago

You need to point resolve.modules paths to the the wallaby cache folder. You may quickly try by moving the config under module.exports = function (wallaby) { and replacing the local project path with the wallaby cache path (for project code, but not for node modules):

const PATHS = require('./webpack/paths');

...

module.exports = function (wallaby) {

  PATHS.app = PATHS.app.replace(process.cwd(), wallaby.projectCacheDir);
  PATHS.test = PATHS.test.replace(process.cwd(), wallaby.projectCacheDir);

  var config = { ...

...
nathanvale commented 7 years ago

Thanks for your prompt support. This solved my problem.