giuseppeg / styled-jsx-postcss

Use PostCSS with styled-jsx 💥
MIT License
64 stars 11 forks source link

Catch actual errors in case of syntax issues. #5

Open aga5tya opened 7 years ago

aga5tya commented 7 years ago

Everytime there is an compilation error, lets say we miss out semicolons, the build fails with a generic error as below always.

Would be good if it gives the actual error provided by postcss plugins. I have tried with the example provided at next.js repo, same issue.

Module build failed: TypeError: /Users/prithviraju/Code/sample/with-styled-jsx-postcss/pages/index.js?entry: css.map is not a function
    at PluginPass.enter (/Users/prithviraju/Code/sample/with-styled-jsx-postcss/node_modules/styled-jsx-postcss/dist/babel.js:110:15)
    at newFn (/Users/prithviraju/Code/sample/with-styled-jsx-postcss/node_modules/babel-traverse/lib/visitors.js:276:21)
    at NodePath._call (/Users/prithviraju/Code/sample/with-styled-jsx-postcss/node_modules/babel-traverse/lib/path/context.js:76:18)
    at NodePath.call (/Users/prithviraju/Code/sample/with-styled-jsx-postcss/node_modules/babel-traverse/lib/path/context.js:48:17)
    at NodePath.visit (/Users/prithviraju/Code/sample/with-styled-jsx-postcss/node_modules/babel-traverse/lib/path/context.js:105:12)
    at TraversalContext.visitQueue (/Users/prithviraju/Code/sample/with-styled-jsx-postcss/node_modules/babel-traverse/lib/context.js:150:16)
    at TraversalContext.visitSingle (/Users/prithviraju/Code/sample/with-styled-jsx-postcss/node_modules/babel-traverse/lib/context.js:108:19)
    at TraversalContext.visit (/Users/prithviraju/Code/sample/with-styled-jsx-postcss/node_modules/babel-traverse/lib/context.js:192:19)
    at Function.traverse.node (/Users/prithviraju/Code/sample/with-styled-jsx-postcss/node_modules/babel-traverse/lib/index.js:114:17)
    at NodePath.visit (/Users/prithviraju/Code/sample/with-styled-jsx-postcss/node_modules/babel-traverse/lib/path/context.js:115:19)
     @ multi ./~/next/dist/client/webpack-hot-middleware-client ./pages?entry
giuseppeg commented 7 years ago

@aga5tya would you have time to look into this?

aga5tya commented 7 years ago

@giuseppeg,, Sure will give it a shot and create a PR. Meanwhile would be helpful if you could point me in some direction to know about how babel transforms work, new to that. Official docs would suffice ?

giuseppeg commented 7 years ago

@aga5tya awesome! I guess that most of your work will be around the processor and this part of the transform which doesn't require any knowledge of babel.

Anyway the babel-handbook, the babel-types docs, https://astexplorer.net/ and learning about Paths and how to use them in the traversal is what you need to get started with plugins developments for Babel.