Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why is a transform-react-jsx required #5

Open
sebald opened this issue Feb 13, 2017 · 12 comments
Open

Why is a transform-react-jsx required #5

sebald opened this issue Feb 13, 2017 · 12 comments

Comments

@sebald
Copy link

sebald commented Feb 13, 2017

I was wondering why this example requires the BabelPlugin, since TypeScript can transpile JSX by itself.

Removing the plugin and using a custom tsconfig.json that sets "jsx" property to "react" works (at least it compiles), but the output seems to be broken. Opening the app in the browser is not possible -> http://localhost:4444/default/index.jsx

Is it not possible for FuseBox to compile JSX without any plugins?

@ada-lovecraft
Copy link

I'm not affiliated with the project, but I think a decent answer is:

The more features fuse-box supports "out of the box" means more technical debt that has to be taken on. The js community is -incredibly fast- paced, so taking on the endeavour of supporting jsx "in-house", as opposed to letting other people set the standards for it, and supplying a pluggable interface -into- fusebox, would mean having to play catchup all the time.

@nchanged
Copy link
Contributor

hi @sebald you can check this seed it uses typescript.

@8-uh thanks for your input, Our mission is to make developer's life easier, is all.

@ada-lovecraft
Copy link

@nchanged I've been playing with fuse-box for about 30 minutes... and I already have an electron + react + babel + css-modules + HMR build up and running.

A thing I spent a full week trying to figure out (without relying on boilerplates and generators) last week.

I'd say you're doing a fine job of making my life easier. 👍

@nchanged
Copy link
Contributor

@8-uh Glad to hear that!

@sebald
Copy link
Author

sebald commented Feb 14, 2017

The more features fuse-box supports "out of the box" means more technical debt that has to be taken on. The js community is -incredibly fast- paced, so taking on the endeavour of supporting jsx "in-house", as opposed to letting other people set the standards for it, and supplying a pluggable interface -into- fusebox, would mean having to play catchup all the time.

I don't quite follow. There should be no extra work required to support JSX since FuseBox already supports TypeScript. Meaning, all "extra work" to support JSX is already done by the TypeScript team.

@nchanged Thanks for pointing me to this example. Just a personal note: I think examples using other task runner/bundlers (in this example gulp) if not absolutely necessary disguises the simplicity that comes with using FuseBox and some folks might think that (e.g.) gulp is required, where actually a simple node fuse.js added not the npm scripts suffice. 🙂

The issue I had was completely on my side, because I didn't get the "can't find index.jsx" file error message that was thrown on run time. I thought if something is wrong with the build FuseBox will let me know on compile time, but I guess that will change in the future.

This is what I ended up with as a configuration for using React with TypeScript. Freakin awesome!!!

const fsbx = require("fuse-box");

// Create FuseBox Instance
let fuseBox = new fsbx.FuseBox({
    homeDir: "src/",
    sourceMap: {
        bundleReference: "sourcemaps.js.map",
        outFile: "./build/sourcemaps.js.map",
    },
    outFile: "./build/out.js",
    plugins: [
        fsbx.SVGPlugin(),
        fsbx.CSSPlugin()
    ]
});

fuseBox.devServer(">index.tsx");

Thanks @nchanged for all the hard work you put into this project ❤️ I will definitely tinker a bit more with it and maybe replace our webpack setup with it! Don't tell Mr. Larkin!

@nchanged
Copy link
Contributor

@sebald thank you for your support!

Regarding gulp, I agree, don't like it either. We should have our own task runner =)

@sebald
Copy link
Author

sebald commented Feb 14, 2017

@nchanged Please don't! 😄 No need to reinvent the wheel. The current API + maybe a CLI is more than enough.

@AngelMunoz
Copy link

AngelMunoz commented Mar 13, 2017

@sebald could you share a repo with your settings? having a hard time with ReactDOM.render is not a function 😢
edit: trying to use typescript

@AngelMunoz
Copy link

nevermind, made it work, but had to import react and react-dom as

import * as React from 'react'
import * as ReactDOM from 'react-dom'

@sebald
Copy link
Author

sebald commented Mar 13, 2017

@AngelMunoz I did use this repo. Just changed the fuse.js to the above mentioned configuration. But the configuration changed since then, so I do not know if my configuration is still valid.

@AngelMunoz
Copy link

AngelMunoz commented Mar 13, 2017

@sebald yeah I meant tsconfig and other stuff, weird things were happening, but it seems the way I was importing

import ReactDOM from 'react-dom';
import React from 'react';
// or import React, { Component } from 'react';

is not working at least for me
thanks!

@sebald
Copy link
Author

sebald commented Mar 13, 2017

Since TypeScript adheres to the ESModule specification you have to import like

import * as React from 'react';
import * as ReactDOM from 'react-dom';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants