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

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

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