gja / react-templatify

MIT License
7 stars 3 forks source link

error when building - Cannot find module 'react/addons' #7

Open fayzaan opened 8 years ago

fayzaan commented 8 years ago

Hi,

I am using react-templatify for our .rt files, and I am trying to upgrade our react version to 15.0.1. But when I try to build/watch, I get errors pointing to the path of our template files that 'react/addons' module cannot be found..

If I look at the components importing the template files, we are only requiring 'react', not react/addons.

As of react 15, react/addons is no longer supported, it was deprecated in version 14, as of 15 its completely removed.

the command I use is: "watch": "./node_modules/.bin/watchify -t react-templatify . -o js/bundle.js -v",

is there a way to get react-templatify to not add react/addons as a required module, and just to require 'react'? or am I doing something wrong??

gja commented 8 years ago

Does this still hapen in v0.4.5?

fayzaan commented 8 years ago

Yes, it's still happening on version 0.4.5.

fayzaan commented 8 years ago

Alright, found out something regarding this, was very difficult to find so I am posting here incase some one else comes across this issue.

So, what you have to do is pass in the options the key targetVersion and set value to '0.14.0', this resolves the issue.

code from the link below:

  var updated_react_templatify = function (file, options) {
    var opts = options || {};
    opts.targetVersion= '0.14.0';
    return react_templatify(file, opts);
  };

So essentially, you're upgrading it by creating a wrapper around the react templatify and ensuring that targetVersion is passed in with any other options.

One thing I do want to mention though is that we were initially using npm, with a single line in the scripts to create our bundle...but because we have to pass in targetVersion, I had to use gulp in order to set the new version.

ref link: https://github.com/wix/react-templates/issues/77

marcusrbrown commented 8 years ago

This issue is solved by upgrading react-templatify to the most recent version of react-templates. I used npm shrinkwrap to do this in my project and react-addons is no longer being imported.

gja commented 8 years ago

Thanks, will update version soon