Architecture for Java backend with React in client-side.
- Babel for ES6 syntax, using Babel 6 with the "es2016" and "react" presets.
- Hot module reloading (HMR) of React components
- Redux to manage state, both in the client and when rendering on the server.
- react-router for page routing, on client and server. Note that this is version 4, with a very different (and simpler) API to previous versions.
- Linting integrated with Webpack via eslint.
- Type checking with Flow.
You'll need Java8 installed either way at
a minimum version of
1.8.0_65. Older versions have a bug that makes rendering
# if maven installed mvn # or, from scratch ./mvnw # init webpack module npm start
- Project Lombok
- Jackson to serialize model data before rendering on the server. For more information, see this OpenJDK thread on the subject
Controllers that render views are suffixed with
Controller. REST endpoints are
Resource, and handle requests under
Testing the webpack bundle
In order to pre-empty runtime errors with Nashorn loading the bundle, a test
script is executed by Maven during the
test-compile phase, located at
src/test/js/test_bundle.js. If this script fails, you can diagnose the problem
- Running a debug build with
npm run debug. This runs webpack in a production mode but without uglification.
- Run the script again:
- Look at the line in the bundle from the stacktrace and figure out the problem.
It's easy to create a bundle that's broken on the server by including code that
expects a DOM - and that includes the Webpack style loader. This is the root of
most problems. You should note that server-side rendering does not require a
DOM - which is why
src/main/resources/static/js/polyfill.js doesn't provide