Blog / Rust support and improved code splitting in 0.0.17

The release of @codemovie/code-movie 0.0.17 adds support for Rust and comes with improved code splitting. Neither change should break existing code so you can update to the latest version right away.

Rust support

Support for Rust has landed and works exactly as you would expect: import and instantiate the language module, feed it some code, enjoy the resulting animation:

import {
  fromStringsToScene,
  toAnimationHTML
} from "@codemovie/code-movie";
import rust from "@codemovie/code-movie/languages/rust";

let scene = fromStringsToScene(
  [
    { code: "fn main() {\\n}" },
    { code: 'fn main() {\\n    println!("Hello")\\n}' },
    { code: 'fn main() {\\n    println!("Hello Rust!")\\n}' },
  ],
  {
    tabSize: 4,
    language: rust(),
  },
);

document.body.innerHTML = toAnimationHTML(scene);
12345678910111213141516171819
import {
  fromStringsToScene,
  toAnimationHTML
} from "@codemovie/code-movie";
import rust from "@codemovie/code-movie/languages/rust";

let scene = fromStringsToScene(
  [
    { code: "fn main() {\\n}" },
    { code: 'fn main() {\\n    println!("Hello")\\n}' },
    { code: 'fn main() {\\n    println!("Hello Rust!")\\n}' },
  ],
  {
    tabSize: 4,
    language: rust(),
  },
);

document.body.innerHTML = toAnimationHTML(scene);

Rust is a complex language that I personally know next to nothing about, so you can expect this first version to probably miss some syntax and to definitely have some sub-par animation heuristics. You can also expect this to improve over time. If you see something, say something!

Code Splitting

Languages modules now benefit from code splitting, which removes a lot of previously duplicated code. Most language modules leverage a common parsing infrastructure and some languages can even contain other languages (like JS and CSS being used in HTML to support <style> and <script>). If your project uses more than one language module and you use a competent module bundler with ESM modules, you should see smaller bundle sizes immediately.

Other changes and bugfixes

  • ECMAScript now supports the ancient and deprecated with statement
  • The animation heuristics for Elixir got some improvements
  • The playground now allows custom tab sizes and obviously gained support for Rust

What's next?

The next feature I would like to work on is either code decorations (underlines, highlighted lines, gutter icons and the like) and a way to override the animation heuristics. If you have other requests for languages or features, open an issue or contact me via email or Mastodon.