Open fbastian opened 4 years ago
In GitLab by @fbastian on Jan 20, 2016, 15:40
I managed to activate JSX/ES6 support in Eclipse, see https://github.com/angelozerr/tern-react/issues/2#issuecomment-173222751
I'll update the Eclipse configuration files in a new react
branch, and update the webapp documentation (you'll need to install the Tern Eclipse plugin).
In GitLab by @fbastian on Jan 27, 2016, 17:20
we should entirely develop our frontend outside of maven/eclipse/tomcat, otherwise:
we should develop using NPM and webpack, because:
webpack configuration is complicated. hjs-webpack is a nice tool to make it easy:
We will write code in JSX/webpack/ES6 syntax. This code will then be transpiled using Babel
babel-preset-es2015
, babel-preset-react
, babel-preset-react-hmre
, see https://github.com/HenrikJoreteg/hjs-webpack#changing-babel-configWhen building our WAR file, we'll use the frontend-maven-plugin mentioned above to compile our webpack source files into CSS/JS files, and include them in the WAR directory. No need for two separate build processes.
In development, the HTML calling our JS/CSS files (i.e., index.html) will be produced by webpack see https://github.com/HenrikJoreteg/hjs-webpack#html-optional-can-be-boolean-or-function.
In production, the HTML will be sent by the server. This is to allow server-side rendering in the future if we wish.
Our code will need to be module based, using CommonJS, AMD, or ES6 syntax. This is the standard for webpack development. See http://www.jbrantly.com/es6-modules-with-typescript-and-webpack/. From webpack-howto, "If you don't know what to use, use CommonJS".
Don't use ES6 class declarations. Use Render.createClass
. See react-router documentation update, and this tweet by react developer
Use ES6 features, but only those supported by Babel, see http://babeljs.io/docs/learn-es2015/
Don't write components in an App entry point, an entry point cannot be hot reloaded in dev. environment, see here and here
Always use react-document-title, to potentially get access to document.title for server-side rendering.
Avoid using global vars/global functions, data should be provided through states/props. But if you do, use React Context
Which routing library to use: react-router or react-router-component?
How to keep URL parameters in sync between server and client code? Potential solutions:
Should we formally implement JSON-API in our responses? Currently we are based more on JSend. See the update of our JSON responses
Should we make one App for all the website, with one Component per page (e.g., GeneComponent, AboutComponent), or one App per page?
management of query parameter with react-router: get URL parameters, Example
Update URLs outside of components:
In GitLab by @fbastian on Jan 20, 2016, 11:34
It is necessary to improve the generation of the views in the webapp. From discussion with @pmoret and @vrechdelaval, we agreed:
to use React for managing our HTML and Javascript.
to not create a separate frontend webapp containing only HTML/Javascript (as, e.g., neXtProt): we have legacy code generated in Java, and we don't have the time to do a complete migration of this code, the Java webapp needs to remain; also, it is convenient to generate some HTML code from the Java webapp.
to not move to the NPM/grunt/Webpack ecosystem; we will rather continue compiling/minifying/concatenating JS file with Maven. Because of the previous point, because we want to keep only one build process, and because none of us is familiar with these tools.
that the Java webapp will still generate some HTML code, lightweight and convenient. Notably, to be able to include raw JS files in development, and minified/concatenated files in production; otherwise, we would need either to use different HTML files for development/production, or to move to the NPM/Grunt ecosystem.
to use the JSX language. And to not externalize it in separate files (to externalize, cf. react-templates (looks a bit like Angular syntax...), or "manual externalization")
that we'll start using React for new HTML code that we'll write.
TODO
Notes
tern-react
in/Applications/Eclipse.app/Contents/Eclipse/plugins/ternjs_1.1.0.201511082254/node_modules
, and put in it package.json and react.js