petehunt / node-jsx

transparently require() jsx from within node
164 stars 32 forks source link

not working for .jsx (anymore?) #38

Closed tcurdt closed 9 years ago

tcurdt commented 9 years ago

A very simple setup:

var path = require("path");
var express = require("express");

var app = express();
require('node-jsx').install({ extension: '.jsx' })
require('source-map-support').install();

var React = require("react");
var PageHome = React.createFactory(require("../components/PageHome/PageHome.jsx"));

In theory requiring the jsx should transform it but I am getting an error:

..../app/components/PageHome/PageHome.jsx.js:6
  <div>
  ^
  SyntaxError: Unexpected token <

The jsx should be fine though:

var React = require('react');

var Home = React.createClass({
  render: function() {
    return (
      <div>
        <h1>Home!!</h1>
      </div>
    );
  }
});

module.exports = Home;

The dependencies are minimal

"dependencies": {
  "node-jsx": "^0.12.4",
  "source-map-support": "^0.2.10",
  "express": "^4.12.3",
  "react": "^0.13.1"
}

Poking into node-jsx it seems like the require extensions are not being called at all. https://github.com/petehunt/node-jsx/blob/master/index.js#L17

I am really not sure what's going on. Any thoughts?

$ node --version v0.12.0 $ npm -version 2.5.1

tcurdt commented 9 years ago

Meeh! Both editor and system were hiding the extension that was actually jsx.js. Working now.