basic JSPM React sample failing erroring on loading react-tools/vendor/fbtransform/visitors

228 views Asked by At

Trying to get a very basic react/jspm example working over on plnkr.co but it is erroring out with a number of 404's. Most notably the following:

Uncaught (in promise) Error: XHR error (404 Not Found) loading https://npm.jspm.io/[email protected]/vendor/fbtransform/visitors
    Error loading https://npm.jspm.io/[email protected]/vendor/fbtransform/visitors as "./vendor/fbtransform/visitors" from https://npm.jspm.io/[email protected]/main.js
    Error loading https://registry.jspm.io/js/app.jsx.js!https://registry.jspm.io/jsx.js
    at r (https://jspm.io/[email protected]:5:11565)
    at XMLHttpRequest.o.onreadystatechange (https://jspm.io/[email protected]:5:12090)

Any thoughts on how to get past these and get the sample to render?

--> problem plnkr.co sample here <--


The code was also copied in the following code snippet (which obviously will never work here as different JSX files are required) just for SO readers that doesn't want to go to plnkr.co.

// app.jsx
import React from 'react'
import Test from './test.jsx!'

React.render(
  <Test />
, document.getElementById('main')
);

//------------------------------
// test.jsx
import React from 'react'

export default React.createClass({
    displayName: 'Test'
  , render: function () {
      return (
        <div>Awesome Test!</div>
      )
    }
})

//------------------------------
//config.js
System.config({
});
<!-- index.html -->
<!DOCTYPE html>
<html>
  <head>
  </head>
  <body>
    <div id="main"></div>
    <script src="https://jspm.io/[email protected]"></script> 
    <script type="text/javascript" src="config.js"></script>
    <script type="text/javascript">
      System.import('js/app.jsx!jsx')
    </script>
  </body>
</html>

1

There are 1 answers

0
Mariano Desanze On

You have these problems:

  1. index.html: System.import('js/app.jsx!jsx') should have been System.import('./app')

  2. app.jsx: import Test from './test.jsx!' should have been import Test from './test'

  3. Missing map to your libraries in config.js:

    System.config({
      map: {
        "react": "npm:[email protected]"
      }
    });
    

Here is the fixed plunker