ardatan / meteor-webpack

https://medium.com/@ardatan/meteor-with-webpack-in-2018-faster-compilation-better-source-handling-benefit-from-bc5ccc5735ef
MIT License
123 stars 29 forks source link

Uncaught TypeError: Cannot read property 'Mongo' of undefined #29

Closed michaelcerne closed 6 years ago

michaelcerne commented 6 years ago

Hey there,

After testing both the React example and my own application, I'm coming across identical errors:

Uncaught TypeError: Cannot read property 'Mongo' of undefined

In the example, Webpack transpiles the code to:

var Tasks = exports.Tasks = new _mongo.Mongo.Collection('tasks');

It is attempting to read _mongo.Mongo, which I'm fairly certain isn't an object. This prevents the entire app from running. Any ideas as to why?

OS: Linux Mint 18.3

Thanks.

ardatan commented 6 years ago

try to remove devServer field in your webpack.config file

michaelcerne commented 6 years ago

@ardatan Looks like that fixed it. Thanks! Any way for me to keep native hot reload functions?

ardatan commented 6 years ago

@michaelcerne you can remove ardatan:webpack-dev-middleware package, and devServer fields in your webpack.config. Then, you can work with Meteor's hot-code-push.

michaelcerne commented 6 years ago

@ardatan Thank you. Is there any possibility that you can point me to why this error occurs at all?

ardatan commented 6 years ago

It is a known issue. Browser loads scripts async. That's why. this error occurs if Webpack bundle is loaded before Meteor's one is loaded. Generally this problem occurs in Firefox, not Chrome.