Skip to content

Latest commit

 

History

History
58 lines (37 loc) · 1.59 KB

README.md

File metadata and controls

58 lines (37 loc) · 1.59 KB

Mayu::SWC

This library transforms/minifies TypeScript and JavaScript.

It uses swc (webpage), which takes JavaScript / TypeScript files using modern JavaScript features and outputs valid code that is supported by all major browsers.

Disclaimer: I do not know Rust. I have no idea what I'm doing.

Installation

TODO: Maybe publish this gem when it's useful enough.

Mayu::SWC is published on rubygems.org and there are pre-built extensions for:

  • aarch64-linux
  • arm64-darwin
  • x86_64-darwin
  • x86_64-linux

gem install mayu-swc

Usage

require "mayu/swc"

code = Mayu::SWC.transform("/app/components/Hello.ts", <<~TypeScript)
  export default function hello(foo: string): string {
    console.log(foo)
    return "bar"
  }
TypeScript

puts code

Output:

export default function hello(foo){console.log(foo);return"bar";}

Development

After checking out the repo, run bin/setup to install dependencies. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/mayu-live/mayu-swc.

License

MIT