bernard-lin / babel-plugin-glamorous-displayname

A babel plugin for Glamorous displayNames 💄
http://npm.im/babel-plugin-glamorous-displayname
MIT License
32 stars 2 forks source link

Fix error with imports #2

Closed bernard-lin closed 7 years ago

bernard-lin commented 7 years ago

I think this might be a result of my own lack of understanding of babel/webpack (time to watch that FEM course 😓) but for some reason, when using an import statement, !isRequireCall(node.init) (from the VariableDeclarator pattern) evaluates to false even though there is no require present in the file and thus doesn't return. I'm also not sure if it's because the import is being converted into require by a preset before this plugins runs - Babel docs say plugins should run before presets. Anyway, it ends up running path.scope.getBinding(name), but says referencePaths is undefined and throws an error: image

Wrapping that code in an if statement seems like a hacky solution but it appears to work regardless of require/import. Is there a better way to solve this?

bernard-lin commented 7 years ago

This was an error with both Webpack 1 & 2 - I don't think it was an error with setup though. I took the Simple Example and modified the webpack file.

image

@kentcdodds

bernard-lin commented 7 years ago

Oops forgot to wait for the review to finish