andreypopp / reactify

[DEPRECATED] Browserify transform for JSX (superset of JavaScript used in React library by Facebook)
MIT License
690 stars 68 forks source link

Reactify not transforming JSX file #57

Closed super-cache-money closed 9 years ago

super-cache-money commented 9 years ago

OK so this is super weird, I'm usually a happy user of reactify, but in one case of mine, I can't get it to perform the transform! I have this:

 b2 = browserify();
 b2.transform(reactify);
 b2.require(path.resolve(__dirname, 'client.jsx'), {basedir: '.', expose: '__isoclient'});
 b2.bundle(...);

At the top of client.jsx, I have specified:

/**
* @jsx React.DOM
*/

This throws an Unexpected token error on the first < of a jsx tag.

Weirdly, browserify -t reactify client.jsx works fine.

What could be going on here?

NicholasGWK commented 9 years ago

I'm getting similarly weird behaviour that may be related...when rendering a react component that I want < as text (for example in a breadcrumb menu), it also breaks.

tcurdt commented 9 years ago

I might have the same thing on this project https://github.com/tcurdt/react-app. When I run

$ browserify -o bundle.js -t reactify ./app/client/main.js

it is not transforming some of the jsx files.

Error: Parsing file react-app/node_modules/react-tc-typeahead/src/typeahead/index.jsx: Unexpected token (101:8)
    at Deps.parseDeps (/usr/local/lib/node_modules/browserify/node_modules/module-deps/index.js:418:28)
    at fromSource (/usr/local/lib/node_modules/browserify/node_modules/module-deps/index.js:361:48)
    at /usr/local/lib/node_modules/browserify/node_modules/module-deps/index.js:356:17
    at ConcatStream.<anonymous> (/usr/local/lib/node_modules/browserify/node_modules/concat-stream/index.js:32:43)
    at ConcatStream.emit (events.js:129:20)
    at finishMaybe (/usr/local/lib/node_modules/browserify/node_modules/readable-stream/lib/_stream_writable.js:460:14)
    at endWritable (/usr/local/lib/node_modules/browserify/node_modules/readable-stream/lib/_stream_writable.js:469:3)
    at ConcatStream.Writable.end (/usr/local/lib/node_modules/browserify/node_modules/readable-stream/lib/_stream_writable.js:436:5)
    at DuplexWrapper.onend (/usr/local/lib/node_modules/browserify/node_modules/readable-stream/lib/_stream_readable.js:537:10)
    at DuplexWrapper.g (events.js:199:16)
tcurdt commented 9 years ago

Same behaviour when calling it directly via browserify API

var b = browserify({
  basedir: root,
  entries: [ "./app/client/main.js" ],
  debug: true,
  transform: [ reactify ],
  extensions: [ ".jsx" ],
  cache: {},
  packageCache: {},
  fullPaths: true
});

b.bundle(function(err, src) {
  if (err) return cb(err, src);
  cb(null, src);
})
.pipe(fs.createWriteStream("bundle.js"));
gisborne commented 9 years ago

I ran into a problem along these lines. I was able to get it to work by using -g reactify rather than -t reactify. Not sure what the difference is or why this works, but you might try it.

andreypopp commented 9 years ago

I added troubleshooting section to README: https://github.com/andreypopp/reactify#troubleshooting