jcoreio / crater

Meteor/Webpack/React SSR app skeleton that runs your app code outside of Meteor Isobuild
ISC License
82 stars 10 forks source link

Does not work with react-meteor-data #48

Open evelant opened 7 years ago

evelant commented 7 years ago

Add react-meteor-data plugin to meteor and react-addons-pure-render-mixing to package.json and the following happens on the client if you try to import from meteor/react-meteor-data:

WARNING: npm peer requirements (for react-meteor-data) not installed:
 - react@15.x not installed.
 - react-addons-pure-render-mixin@15.x not installed.

Read more about installing npm peer dependencies:
  http://guide.meteor.com/using-packages.html#peer-npm-dependencies

modules-runtime.js:128 Uncaught Error: Cannot find module 'react'
require.resolve @   modules-runtime.js:128
Module.resolve  @   modules-runtime.js:84
Mp.import   @   modules.js:282
meteorInstall.node_modules.meteor.react-meteor-data.createContainer.jsx @   react-meteor-data.js:243
fileEvaluate    @   modules-runtime.js:180
require @   modules-runtime.js:109
meteorInstall.node_modules.meteor.react-meteor-data.react-meteor-data.jsx   @   react-meteor-data.js:45
fileEvaluate    @   modules-runtime.js:180
require @   modules-runtime.js:109
(anonymous function)    @   react-meteor-data.js:299
(anonymous function)    @   react-meteor-data.js:310
(anonymous function)    @   app.js:2098
__webpack_require__ @   app.js:556
fn  @   app.js:87
webpackContext  @   packages_nonrecursive_\.js$:33
(anonymous function)    @   meteor-imports.js:18
(anonymous function)    @   meteor-imports.js:16
(anonymous function)    @   app.js:3178
__webpack_require__ @   app.js:556
fn  @   app.js:87
(anonymous function)    @   index.js:3
(anonymous function)    @   app.js:2524
__webpack_require__ @   app.js:556
fn  @   app.js:87
(anonymous function)    @   multi_main:1
(anonymous function)    @   app.js:586
__webpack_require__ @   app.js:556
(anonymous function)    @   app.js:579
(anonymous function)    @   app.js:582

Looks like meteor packages can't resolve npm packages. I'm not sure how to fix this.

jedwards1211 commented 7 years ago

It's happening because Isobuild transpiles import statements into stuff that's not webpack-compatible. I don't approve of much of anything isobuild does.

You would be able to npm install --save meteor/react-packages#react@15.0.1 except that react-packages doesn't provide a version in its package.json. One option is to clone the react-meteor-data package using git subtree and import from that folder instead. I'll try to get them to add a proper version to package.json...

jedwards1211 commented 7 years ago

See https://github.com/meteor/react-packages/pull/201

jedwards1211 commented 7 years ago

I might be able to figure out a way to de-transpile isobuild's module statements though...

evelant commented 7 years ago

As an easy workaround I just copied the code for react-meteor-data from here https://github.com/meteor/react-packages/tree/devel/packages/react-meteor-data into my project since it is quite simple. It builds fine under webpack with the meteor-imports-webpack-plugin.

jedwards1211 commented 7 years ago

@fignuts yeah that works too. I only suggested using git subtree because you'd be able to pull updates from their repo.

jedwards1211 commented 7 years ago

I was almost tempted to preemptively start publishing a react-meteor-data npm package 😸

jedwards1211 commented 7 years ago

@fignuts okay, I created a react-meteor-data npm package. Now you should just be able to npm i --save react-meteor-data react-addons-pure-render-mixin :)

evelant commented 7 years ago

Awesome! Thanks!

ouya99 commented 7 years ago

When I do

npm install --save-dev react-meteor-data react-addons-pure-render-mixin

I get

ReferenceError: Tracker is not defined MeteorDataManager.calculateData webpack:///./~/react-meteor-data/lib/ReactMeteorData.js?:93:26

kawikadkekahuna commented 7 years ago

@java99

I had to add var { Tracker } = Package.tracker at the top of node_modules/react-meteor-data/lib/ReactMeteorData.js. This is a hacky fix. Hopefully the NPM package could be republished to include this dependency or we could find some alternative solution.

jedwards1211 commented 7 years ago

@kawikadkekahuna I just published a fix for that, could you install the latest version of react-meteor-data (0.2.10) and let me know how it works?

kawikadkekahuna commented 7 years ago

@jedwards1211

Awesome. Fixed now. Thanks for updating it.

jedwards1211 commented 7 years ago

@kawikadkekahuna you're welcome!