Maquette 2.2 now supports JSX

Johan Gorter
Feb 8, 2016 · 2 min read

A lot of code has changed in maquette 2.2, but there are almost no API changes since version 2.1. This is because maquette is now converted to Typescript and all of the functionality is now covered by unit tests. It does now meet the same quality standards that we use for the rest of our code at AFAS Software.

The only thing that is really new in this version, is that maquette now supports JSX. Most of the work for supporting JSX has already been done by the Babel project. This is because its ‘react jsx transform’ plugin can be configured to use a custom ‘pragma’ and can thus be configured to use maquette’s h method.

In order to use JSX, you have to install Babel with the following dependencies:

npm install babel-core babel-plugin-transform-react-jsx 

You also need the following .babelrc file

"presets": ["es2015"],
"plugins": [
["transform-react-jsx", {"pragma": "h"}]

Babel can now compile your code and the JSX will get converted into working hyperscript.

This also works with Typescript, because the Typescript compiler can be configured to preserve theJSX and you can then run Babel on the Typescript output. We created a starter application on github where we configured webpack to run both Typescript and Babel.

The only modification that we had to make in order to support JSX was to allow the class attribute for providing a static list of CSS classes. CSS classes that can be added and removed dynamically should still be specified using the classes attribute.

Ok, let me show you what JSX looks like in maquette.

So now we are facing a dilemma. Should we convert the code samples on the maquette homepage to use JSX or not? Will that attract a larger audience, or will the extra complexity scare people off? If you have an opinion, don’t hesitate to leave a comment.

Maquette news

News from

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store