MXCuBE 3
front-end development toolchain
7th MXCuBE meeting, 1st of December 2015 - ALBA, Barcelona - Spain
Matias Guijarro
Software Engineer @ Beamline Control Unit
European Synchrotron Radiation Facility
Grenoble, France
6 months learning frontend development tools
Front-end development:
no right answer, but tons of wrong ones
Vast ecosystem
Foundational technologies
Front-end development:
no right answer, but tons of wrong ones
Emerging best practices
Professionalisation
Tools selection
#1: npm
npm, Node Package Manager
Originally dedicated to NodeJS packages installation
package.json input file
Simple task runner
not understandable by browsers !
#2: webpack
webpack module bundler
Takes source files with dependencies and produces static assets
.js
.js
.css
.png
.js
Small images are embedded in output file
for faster loading time,
links are preserved for big images
.js
webpack module bundler
Loaders to modify source code during static asset generation
webpack-dev-server (based on Node http server)
#3: Babel
Babel
Syntax transformation
import React from "react"
class Example extends React.Component {
constructor(props) {
super(props)
console.log("Hello world")
}
render() {
return (<div>
This is an example JSX embedded code
</div>)
}
}
"use strict";
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var _react = require("react");
var _react2 = _interopRequireDefault(_react);
var Example = (function (_React$Component) {
_inherits(Example, _React$Component);
function Example(props) {
_classCallCheck(this, Example);
_get(Object.getPrototypeOf(Example.prototype), "constructor", this).call(this, props);
console.log("Hello world");
}
_createClass(Example, [{
key: "render",
value: function render() {
return _react2["default"].createElement(
"div",
null,
"This is an example JSX embedded code"
);
}
}]);
return Example;
})(_react2["default"].Component);
ES6 syntax
#4: ReactJS
+ redux
React
Web components
JSX
react-hot-loader for webpack dev server
demo!
React + Redux
Inspired by Flux architecture, implementation idea from Elm
What is Flux ?
React + Redux
Inspired by Flux architecture, implementation idea from Elm
What is Elm ?
React + Redux
Predictable state container for Javascript apps
Redux
React + Redux
#5: Bootstrap
Front-end library
Responsive features
Browsers compatibility
Saves lot of time
Conclusion
MXCuBE 3 front-end development toolchain
Acknowledgements
Conclusion:
strong foundations
(picture from Max IV construction)
(me building
my patio)
Thanks for your attention
Questions ?