painfull setup no more
You've probably already lost hours configuring Webpack by adding / removing babel plugins for each feature you want to control in a simple project. Blonde promises to meet all the basic needs of a React application by simply installing.
Blonde commits to deliver from the project bundle to the SSR layer. In addition to bringing SSR support for Electron. Everything is ready, with the promise of working from ES5 to the present.
Already behind ecosystem support for flow, object-rest-spread, class-properties ...
npm install -D blonde
Not available yet, working in progress.
import React from 'react'
class Greeting extends React.Component {
render() {
return <h1>Hello, {this.props.name}</h1>
}
}
export default Greeting
const blonde = require('blonde')
blonde.toReactString('./greeting.js')
<h1 data-reactroot="" data-reactid="1" data-react-checksum="1601575969"><!-- react-text: 2 -->Hello, <!-- /react-text --></h1>
const blonde = require('blonde')
blonde.toReactElement('./greeting.js')
/*
{ '$$typeof': Symbol(react.element),
type: [Function: Dialog],
key: null,
ref: null,
props: {},
_owner: null,
_store: {} }
*/
const blonde = require('blonde')
blonde.parse('./greeting.js')
/*
function Dialog(props) {
(0, _helpers.log)('sample');
return _react2.default.createElement(
'section',
{ role: 'dialog', className: 'modal' },
_react2.default.createElement('input', { type: 'text', className: 'modal-search', id: 'modal-search', placeholder: 'Search for packages....' }),
_react2.default.createElement('div', { className: 'modal-items' }),
_react2.default.createElement(_Tab2.default, null)
);
}
*/
const blonde = require('blonde')
const template = require('./template')
function createWindow() {
let mainWindow = new BrowserWindow(config)
let url = blonde.toElectron('src/App.js', template)
mainWindow.loadURL(url)
mainWindow.on('closed', function() {
mainWindow = null
})
mainWindow.once('ready-to-show', () => {
mainWindow.show()
})
}
module.exports = (app) => {
return `<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>My Template</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="root">${app}</div>
<script async src="bundle.js"></script>
</body>
</html>`
I strongly recommend: NO.
Why? Blonde reads any code and parse/transpile it in runtime. It cost a lot, just imagine for every process, you will read/parse/transpile/tokenize/write.
- Read and transpile main component filepath, generating a node module
- Every require in this node module is replaced by smart require (which transpile the source in runtime before nodejs parse start)
- Parse'n deliver this module and repeat this it for every import/require missing.
- Create a dynamic HTML file based on render result
- When nodejs dispatch
exit
,SIGINT
oruncaughtException
event: delete_.html
If you're using, let me know :)