SwiftyBabel is a Swift wrapper for Babel.js. It provides an easy-to-use interface for running Babel.js on Swift projects.
SwiftyBabel allows you to use Babel.js with your Swift projects without having to worry about the complexities of setting up and configuring Babel.js. With SwiftyBabel, you can simply write your code in Swift, and SwiftyBabel will take care of the rest.
SwiftyBabel is also available through Swift Package Manager. To install it, simply add the dependency to your Package.Swift file:
...
dependencies: [
.package(url: "https://github.com/Azzam-dev/SwiftyBabel.git", from: "1.0.0"),
],
targets: [
.target( name: "YourTarget", dependencies: ["SwiftyBabel"]),
]
...
To use SwiftyBabel, simply import the SwiftyBabel module and use the compile function to compile your JavaScript code. For example:
import SwiftyBabel
let input = "const square = n => n * n;"
let options = BabelOptions(presets: ["env"])
let output = try Babel.compile(input, options: options)
print(output.code) // Output: "var square = function square(n) { return n * n; };"
If you'd like to contribute to SwiftyBabel, please feel free to submit a pull request! We welcome contributions from the community.
SwiftyBabel was created by Azzam R ALrashed 🇸🇦.
If you have any questions or feedback, feel free to reach out to me on Twitter.
SwiftyBabel is available under the MIT license. See the LICENSE file for more info.