jedwards1211 / meteor-webpack-react

(DEPRECATED) use jedwards1211/crater instead
https://github.com/jedwards1211/crater
374 stars 75 forks source link

TypeError: undefined is not an object (evaluating 'Template.loginButtons') #101

Closed mtsewrs closed 8 years ago

mtsewrs commented 8 years ago

Getting this error running dev, using react 0.14.

mtsewrs commented 8 years ago

Also, when running in production it seems that es7 decorators are not working...

edit: although works by adding ?stage=0

jthomaschewski commented 8 years ago

Try switching back to commit bfc71981a7008adf007e7b5a94c17f28a0a12adb or less - Or try the new https://github.com/jedwards1211/meteor-webpack-react/tree/webpack-meteor-tools branch.

Or: merge the PR's of haydnhkim #91 and #98

Currently master is broken due to incomplete SSR additions.

jedwards1211 commented 8 years ago

The webpack-meteor-tools branch should have this problem as well -- I need to figure out a different hack for server side source maps/original files in the debugger.

jedwards1211 commented 8 years ago

Also the first and so far only release shouldn't have this problem

jedwards1211 commented 8 years ago

Okay, this is now fixed in the latest version of the branch: https://github.com/jedwards1211/meteor-webpack-react/tree/webpack-meteor-tools I figured out a way to support server-side source maps without having to require in the server bundle.

mtsewrs commented 8 years ago

@jedwards1211 Alright, progress! Are you going to merge it soon?

jedwards1211 commented 8 years ago

We'll see...I've been terribly busy lately

jedwards1211 commented 8 years ago

I'm still confused how ?stage=0 fixes this problem, several people have reported that. Do the login buttons actually show up in the webpage or does it simply not error out?

jthomaschewski commented 8 years ago

@jedwards1211 It's easy:

Babel config in webpack.config.dev.js: stage=0, transform plugins ... Babel config in webpack.config.prod.js: None Babel config in common webpack.config.js: Default (stage=2)

decorators are stage 1 - so when build prod decorators did not work (used for reactMixin)

Adding stage=0 to webpack.config.js adds decorator support for production builds

EDIT: But you are right - this shouldn't fix any "Template" is undefined error. The babel error appeared due to the move of babel config to config.dev. The "Template" error is fixed with #91

jedwards1211 commented 8 years ago

Okay, I finally revisited this. I was confused since I never use Blaze -- Template isn't available on the server side, so I got rid of the PR that monkeypatched it for the sake of SSR (which was ruining the client side anyway due to var hoisting, which I didn't think about.

In short, wrap all references to Template in Meteor.isClient checks.

Also, I revamped how the webpack configs are created to use webpack-merge and babel options in the query parameter as necessary.

Cheers!