fuse-box / react-example

71 stars 36 forks source link

flow typesystem support #7

Closed cocodrino closed 7 years ago

cocodrino commented 7 years ago

Hi, sorry if it's a noob question but I've added some flow code and I get an error when I run it

Aconr error: unexpected token (9:6) var a: number[] = [2,3,4];

generally flow works out the box with react, because the babel react preset supports flow by default, I changed the babel preset from latest to react but seems doesnt work neither

thank you so much, I'm really enjoying fuse-box over webpack!!!...

nchanged commented 7 years ago

Hi! If you changed your babel presets or configuration in general, make sure you remove .fusebox before restarting your process.

cocodrino commented 7 years ago

hi @nchanged I remove the .fusebox folder but the it still shows the error, this is the full error log

I'm not sure, I just change the preset to react but the logs seems to show than I'm not doing in right way

Acorn error: Unexpected token (9:6)
File: /home/yo/Documentos/proyectos/js/fuse_boilerplate/react/react-example/src/App.jsx

7  import {Button} from 'antd';
8  
9  var a : number[] = [2,3,4]
10  class App extends Component {
11      render() {
12          return (
13              <div className="App">

└── default (1 files,  335 Bytes)
      index.jsx

    Bundle
    Size: 335 Bytes 
    Time: 566ms
(node:32039) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): ReferenceError: [BABEL] unknown: Unknown option: /home/yo/Documentos/proyectos/js/fuse_boilerplate/react/react-example/node_modules/react/react.js.Children. Check out http://babeljs.io/docs/usage/options/ for more information about options.

A common cause of this error is the presence of a configuration options object without the corresponding preset name. Example:

Invalid:
  `{ presets: [{option: value}] }`
Valid:
  `{ presets: [['presetName', {option: value}]] }`

For more detailed information on preset configuration, please see http://babeljs.io/docs/plugins/#pluginpresets-options. (While processing preset: "/home/yo/Documentos/proyectos/js/fuse_boilerplate/react/react-example/node_modules/react/react.js")
(node:32039) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): ReferenceError: [BABEL] unknown: Unknown option: /home/yo/Documentos/proyectos/js/fuse_boilerplate/react/react-example/node_modules/react/react.js.Children. Check out http://babeljs.io/docs/usage/options/ for more information about options.

A common cause of this error is the presence of a configuration options object without the corresponding preset name. Example:

Invalid:
  `{ presets: [{option: value}] }`
Valid:
  `{ presets: [['presetName', {option: value}]] }`

For more detailed information on preset configuration, please see http://babeljs.io/docs/plugins/#pluginpresets-options. (While processing preset: "/home/yo/Documentos/proyectos/js/fuse_boilerplate/react/react-example/node_modules/react/react.js")
//my .babelrc file is
{
    "sourceMaps": true,
    "presets": ["react"],
    "plugins": [
        ["transform-react-jsx"]
    ]
}

is it correct???...thank you

nchanged commented 7 years ago

It feels like babel can't capture your code. Please run with --debug options, and copy paste the output.

Make sure you .babelrc is in your appRoot (next to node_modules)

nchanged commented 7 years ago

If nothing helps, please provide a repository where we can reproduce your error.

cocodrino commented 7 years ago

hi...thanks for the support @nchanged , I could resolve the problem, I change my babel config adding es2015 (I was replacing es2015 for react because I though than the react-preset include the same es2015 functionalities plus react, now I include both)

 "presets": ["es2015","react"],

thank you