Skip to content

Instantly share code, notes, and snippets.

@tlrobinson
Last active January 17, 2018 10:02
Show Gist options
  • Save tlrobinson/829ff12bc4f190126211920bf8877c21 to your computer and use it in GitHub Desktop.
Save tlrobinson/829ff12bc4f190126211920bf8877c21 to your computer and use it in GitHub Desktop.
React/Nashorn (Java's JavaScript interpreter) proof-of-concept. yarn && yarn build && yarn start
{
"presets": ["env"],
"plugins": ["transform-react-jsx"]
}
import "babel-polyfill";
import React from "react";
import ReactDOMServer from "react-dom/server";
global.console = { log: print };
console.log(ReactDOMServer.renderToString(<div>hi</div>));
{
"name": "nashorn-react",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"babel-polyfill": "^6.26.0",
"react": "^16.2.0",
"react-dom": "^16.2.0"
},
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-plugin-transform-react-jsx": "^6.24.1",
"babel-preset-env": "^1.6.1",
"webpack": "^3.10.0"
},
"scripts": {
"build": "webpack",
"build:watch": "webpack --watch",
"start": "jjs bundle.js"
}
}
module.exports = {
entry: "./index.js",
output: {
filename: "bundle.js"
},
module: {
rules: [
{ test: /\.js$/, exclude: /node_modules/, loader: "babel-loader" }
]
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment