All Projects → griffio → Spring Boot Web Nashorn

griffio / Spring Boot Web Nashorn

Feasibility of rendering React 16.x templates from Nashorn with babel-standalone, with Spring Boot and Kotlin

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to Spring Boot Web Nashorn

Onetwo
一个基于spring和spring boot的快速开发框架……
Stars: ✭ 16 (-38.46%)
Mutual labels:  spring-boot
Mart Holiday Alarm
🛒 마트쉬는날 🏖
Stars: ✭ 22 (-15.38%)
Mutual labels:  spring-boot
Redis Stream Demo
Demo for Redis Streams
Stars: ✭ 24 (-7.69%)
Mutual labels:  spring-boot
Journaldev
JournalDev Projects
Stars: ✭ 897 (+3350%)
Mutual labels:  spring-boot
Vertx Embedded Springboot
Vert.x embeded Springboot
Stars: ✭ 19 (-26.92%)
Mutual labels:  spring-boot
Search Spring Boot Starter
ElasticSearch封装基于ES版本6.4.2,极大简化了ES操作难度
Stars: ✭ 23 (-11.54%)
Mutual labels:  spring-boot
Dubbo Spring Boot Mybatis Redis
通过dubbo+spring boot+mybatis+redis等主流技术搭建成一套分布式服务框架
Stars: ✭ 889 (+3319.23%)
Mutual labels:  spring-boot
Subnode.org
SubNode: Social Media App
Stars: ✭ 25 (-3.85%)
Mutual labels:  spring-boot
Spring Petclinic Gcp
Spring PetClinic Microservices on GCP
Stars: ✭ 22 (-15.38%)
Mutual labels:  spring-boot
Spring Qrcode Example
Demonstrates some of the capabilities of the Spring Boot framework through a small, simple example.
Stars: ✭ 23 (-11.54%)
Mutual labels:  spring-boot
Great Big Example Application
A full-stack example app built with JHipster, Spring Boot, Kotlin, Angular 4, ngrx, and Webpack
Stars: ✭ 899 (+3357.69%)
Mutual labels:  spring-boot
Angular Spring Data Rest Sample
Spring Boot based sample project for the https://github.com/guylabs/angular-spring-data-rest Angular module.
Stars: ✭ 18 (-30.77%)
Mutual labels:  spring-boot
Httpdoc
基于Java标准doc注释构建的代码零侵入的HTTP RESTful API在线测试,文档阅览以及SDK导出框架,支持Spring-Boot和Spring-MVC
Stars: ✭ 23 (-11.54%)
Mutual labels:  spring-boot
Jsql Injection
jSQL Injection is a Java application for automatic SQL database injection.
Stars: ✭ 891 (+3326.92%)
Mutual labels:  spring-boot
Sample Camel Spring Boot
three samples in different branches that illustrates usage of apache camel as microservice framework providing integration with consul, hystrix, ribbon and other tools
Stars: ✭ 24 (-7.69%)
Mutual labels:  spring-boot
Sample Hazelcast Spring Datagrid
sample spring-boot applications integrated with hazelcast imdg, and providing hot cache with hazelcast and striim
Stars: ✭ 16 (-38.46%)
Mutual labels:  spring-boot
Localstack Spring Boot
Spring Boot AutoConfiguration for LocalStack
Stars: ✭ 22 (-15.38%)
Mutual labels:  spring-boot
Blocklang.com
软件拼装工厂/低代码平台
Stars: ✭ 26 (+0%)
Mutual labels:  spring-boot
Micro Server
Microserver is a Java 8 native, zero configuration, standards based, battle hardened library to run Java Rest Microservices via a standard Java main class. Supporting pure Microservice or Micro-monolith styles.
Stars: ✭ 929 (+3473.08%)
Mutual labels:  spring-boot
Spring Postgresql Demo
Spring Boot 2.0 application, backed by PostgreSQL, and designed for deployment to Pivotal Cloud Foundry (PCF)
Stars: ✭ 23 (-11.54%)
Mutual labels:  spring-boot

Render React template from Nashorn

This is just an experiment tracking the feasibility of using v.latest React in Nashorn.

Recent Spring Developer presentation: isomorphic-templating-with-spring-boot-nashorn-and-react

React 16.1.x

0.13.x leaned on JSX Transformer to perform standalone JSX translation; this was removed in current React versions. A BabelJs environment is needed to compile JSX. However, BabelJs also needs NodeJs environment, so use a babel-standalone that bundles all required modules.

Now in 4.2.0.RELEASE

Jira SPR-12266 Spring Framework SPR-12266

Use jdk-8u72-ea or higher. https://jdk8.java.net/download.html

Early access fix for: Method code too large in Babel - https://bugs.openjdk.java.net/browse/JDK-8135190

Note:- this is also the case with Typescript https://github.com/Microsoft/TypeScript/issues/1789

Spring Boot with ReactJs templates with Nashorn and Kotlin 1.2.x

React 16.1.x requires BabelJs environment to compile JSX BabelJs requires nodejs api dependencies.

However, a stand-alone build of Babel for use in non-Node.js environments used as https://babeljs.io/docs/usage/browser/ now removed. https://github.com/Daniel15/babel-standalone

The package create-react-class is used as Java8 Nashorn is ECMAScript 5.x as per https://reactjs.org/docs/react-without-es6.html

Nashorn Extensions - allow map support

global = {};
console = {};
console.debug = print;
console.warn = print;
console.log = print;
console.error = print;

function render(template, model) {
    var data = {};
    for (var k in model) {
        if (model[k] instanceof Java.type("java.lang.Iterable")) {
             data[k] = Java.from(model[k]);
        } else {
            data[k] = model[k];
        }
    }
    var element = React.createElement(eval(template), data);
    return ReactDOMServer.renderToStaticMarkup(element);
}

function renderJsx(template, model) {
    var jsTemplate = Babel.transform(template, { presets: ['react'] }).code;
    return render(jsTemplate, model);
}

Notes on Spring Boot

Test with JDK

./gradlew test

Application

./gradlew bootRun

Route

http://localhost:8080/about.html

Rendered from

https://github.com/griffio/spring-boot-web-nashorn/blob/master/src/main/resources/templates/about.jsx

==============

Kotlin 1.2.x

kotlin_version=1.2.21

basic gradle (4.x) build template for Java 8

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].