trayio / babel-plugin-webpack-alias

babel 6 plugin which allows to use webpack resolve options
MIT License
150 stars 32 forks source link

Proper error reporting if there are issues with webpack config #28

Closed devarsh closed 8 years ago

devarsh commented 8 years ago

Had faced an issue when i forgot to put comma to seperate webpack alias, and every time i tried running the babel with babel-plugin-webpack-alias it failed with the following error.

error

SyntaxError: src/server/__test__/models.tokens.specs.js: Unexpected identifier
undefined

webpack config

resolve : {
    extensions: ['','.js','.jsx'],
    modules : [srcPath,path.join(basePath,'./node_modules')],
    alias : {
      config : path.join(basePath,'./config'),
      controller : path.join(srcPath,'./controller'),
      models : path.join(srcPath,'./models'),
      template: path.join(srcPath,'./template') // comma was missing which caused the error
      helpers: path.join(srcPath,'./helpers')
    },
  }
adriantoine commented 8 years ago

Hi @devarsh!

It is quite annoying indeed that our plugin doesn't show exactly what is missing and where. However we are not planning to support it. At the moment we are getting your webpack config file just by running a standard require, we are not parsing the file, then we can't do more than what node provides, in terms of error messages, and parsing the file would be too much work for little benefits. I recommend you to use a linter like Eslint, it would show the missing comma in your editor, also if you use babel-register, it should show an error as well.

Sorry for the inconvenience!

devarsh commented 8 years ago

@adriantoine thanks, perhaps we can add it to troubleshooting