Skip to content
This repository has been archived by the owner on Jul 29, 2022. It is now read-only.

fix: platform agnostic react-renderer build process #13

Merged
merged 1 commit into from
Nov 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions src/main/js/react-renderer/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
const fs = require('fs');
const babel = require('babel-core');

if (!fs.existsSync('./build')) {
fs.mkdirSync('./build');
}

if (!fs.existsSync('../../app/build/asset-manifest.json')) {
return console.log('../../app/build/asset-manifest.json does not exist - has the build run?')
}

fs.writeFile('./build/renderer.js','// polyfill.js\n\n', function(err) {
if (err) { return console.log(err); }
fs.readFile('./polyfill.js', 'utf-8', function(err, data) {
if (err) { return console.log(err); }
// Running this through Babel breaks one of the polyfills. Until I work
// that out, merge it in manually.
fs.appendFile('./build/renderer.js', data, function (err) {
if (err) { return console.log(err); }
fs.appendFile('./build/renderer.js', '\n// asset-manifest.json\nvar assetManifest = \n', function (err) {
if (err) { return console.log(err); }
fs.readFile('../../app/build/asset-manifest.json', 'utf-8', function(err, data) {
if (err) { return console.log(err); }
// It's unreasonably difficult to load this file from the classpath at
// runtime, so I'm just adding it in at build time.
fs.appendFile('./build/renderer.js', data, function (err) {
if (err) { return console.log(err); }
fs.appendFile('./build/renderer.js', ';\n\n\n// renderer.js\n\n', function (err) {
if (err) { return console.log(err); }
fs.readFile('./renderer.js', 'utf-8', function(err, data) {
if (err) { return console.log(err); }
const transformedRendererJs = babel.transform(data, {
"presets": ["es2015"],
"plugins": ["transform-object-rest-spread"]
});
fs.appendFile('./build/renderer.js',transformedRendererJs.code, function (err) {
if (err) { return console.log(err); }
});
});
});
});
});
});
});
});
});
1 change: 1 addition & 0 deletions src/main/js/react-renderer/build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
# !!!! Converted to build.js in the spirit of being platform agnostic !!!!

set -eo pipefail

Expand Down
2 changes: 1 addition & 1 deletion src/main/js/react-renderer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"eslint": "^4.6.1"
},
"scripts": {
"build": "./build.sh",
"build": "node build.js",
"lint": "eslint --ext .js ."
}
}