choking on jsx syntax
See original GitHub issueI’ve just updated babelify
in order to get rid of reactify
and hopefully fix the messed up sourcemaps I’ve been having. However, I was getting some trouble along the lines of
Unexpected token (13:1) while parsing file: ./client/scripts/index.jsx
I’ve installed the latest version of babelify
(7.0.2), which includes babel-core
6.0.12.
My gulpfile:
'use strict';
const browserify = require('browserify');
const buffer = require('vinyl-buffer');
const gulp = require('gulp');
const gutil = require('gulp-util');
const source = require('vinyl-source-stream');
const sourcemaps = require('gulp-sourcemaps');
const watchify = require('watchify');
gulp.task('scripts', () => {
let bundler = browserify({
debug: true,
entries: './client/scripts/index.jsx',
transform: [
require('babelify')
]
});
bundler.on('log', (msg) => {
gutil.log(gutil.colors.cyan('scripts') + ': ' + msg);
});
const bundle = () => {
return bundler.bundle()
.on('error', (err) => {
console.error(err.message);
})
.pipe(source('app.js'))
.pipe(buffer())
.pipe(sourcemaps.init({ loadMaps: true }))
.pipe(gutil.env.production ? require('gulp-uglify')() : gutil.noop())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('./public/js'));
};
if (!gutil.env.production) {
bundler = watchify(bundler);
bundler.on('update', bundle);
}
return bundle();
});
gulp.task('default', [ 'scripts' ]);
And the ./client/scripts/index.jsx
it’s choking on:
'use strict';
import { createStore } from 'redux';
import { Provider} from 'react-redux';
import React from 'react';
import ReactDOM from 'react-dom';
import reducers from './reducers';
import routes from './routes.jsx';
const store = createStore(reducers);
ReactDOM.render((
<Provider store={store}>{routes}</Provider>
), document.querySelector('[data-app]'));
Anything obvious I’m missing, or some config I should be using?
Cheers.
Issue Analytics
- State:
- Created 8 years ago
- Comments:9 (1 by maintainers)
Top Results From Across the Web
React render is choking on nested object in property
I have this react component. It is passed a prop called data. data is an object like { "title" : "some title", "meta"...
Read more >Introducing JSX - React
It is called JSX, and it is a syntax extension to JavaScript. We recommend using it with React to describe what the UI...
Read more >How to Work with and Manipulate State in React - SitePoint
To set the initial state, use this.state in the constructor with your ES6 class React.Component syntax. Don't forget to invoke super() with ...
Read more >Install - Prettier
... format all tests in a directory (see fast-glob for supported glob syntax). ... (without mangling files you don't want, or choking on...
Read more >prettier ignore
How to add ESLint and Prettier to a React TypeScript Project. ... more information. prettierignore uses gitignore syntax. gitignore file must be edited...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Under the section titled Plugin Presets from http://babeljs.io/blog/2015/10/29/6.0.0
You probably want
npm install --save-dev babel-preset-react
Then use it as part of your Babelify options https://github.com/babel/babelify#options
Summary:
Basically you just have to
npm install
thebabel-preset-react
preset and add'react'
to the babel presets: