Skip to content

Instantly share code, notes, and snippets.

@pnavarrc
Last active July 2, 2019 15:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pnavarrc/cb12714c95f52ce147b4cf2046e0f38a to your computer and use it in GitHub Desktop.
Save pnavarrc/cb12714c95f52ce147b4cf2046e0f38a to your computer and use it in GitHub Desktop.
Code examples for Writing a Babel Plugin

Writing a Babel Plugin to Refactor Code

Babel is a tool to transform code. It’s most commonly used to transform “modern” JavaScript into code that’s compatible with older browsers. Babel allows us, for example, to use arrow functions (ES2015) during development and have them transformed to anonymous functions at build-time.

// In
[1, 2, 3].map(n => n * n);

// Out
[1, 2, 3].map(function(n) { return n * n; });
// In
[1, 2, 3].map(n => n * n);
// Out
[1, 2, 3].map(function(n) { return n * n; });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment