8000 GitHub - d3dc/swift.macro: A simple babel macro to use swift features in Javascript or Typescript
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

d3dc/swift.macro

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

babel-plugin-macros-example

This is a simple example of a babel-plugin-macros macro.

You'll notice that the code.js file is importing the greeting.macro.js file. Then the imported identifiers are used throughout the code. The macro itself is about as simple as you can get with a babel-plugin-macros macro. It accepts the references to those imports and replaces the references with string literals. Take a look at the output.js file to see what the result is. Now mess around with it a bit to see what you can do with this thing!

Hopefully this helps you get started trying out writing a macro!

Tips

Writing a macro is similar to writing a babel-plugin except you give up a little power in favor of a simpler setup for you and the user of your macro (maybe also you). Because it's so similar to writing a babel plugin, it could be really helpful to learn how to write babel plugins and using ASTs. Here are some resources for that:

From there, you may also want to reference the babel-plugin-macros docs

Good luck!

About

A simple babel macro to use swift features in Javascript or Typescript

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%
0