swudo

A Fast LightWeight Parser and Runtime for Typescript

Usage no npm install needed!

<script type="module">
  import swudo from 'https://cdn.skypack.dev/swudo';
</script>

README

Swudo Node.js CI swudo-version npm

A light weight Runtime and Parser Library for Typescript.

Why swudo?

  • Swudo is built-with-almost no Dependency other than typescript
  • Swudo provides a runtime so that you don't have to call typescript to transcompile your code
  • Swudo Compiles and Transpiles your code into Javascript Code at runtime produce the result. It heavily depends on the Typescript Compiler API.
  • Fast and Lightweight ⚡

How it works

Swudo compiles Typescript code into Javascript Code on runtime even if it is a script or a module file. It outputs a Javascript File on runtime if you are using a setTimeOut in your code you can inspect that file.

Installation

Npm

npm i -g swudo

Yarn

yarn add -D swudo

Using Git

git clone https://github.com/swudots/swudo
cd swudo
yarn install
yarn build
yarn cli // specify commands to swudo here

Usage

Via Cli

usage:
       Compiling and Running a Typescript Program - swudo <file> ?--out<file>
       
       info : Getting information about the process,
              eg: swudo info test/main.ts // this is a process to compile the program

       --extract, -e <file> <identifiers[]>, -e <file> <identifiers[]> : Extract parts from code by specifying identifiers.

       --extract-o, -eo : Just like extract command expects and output files as an argument *swudo -eo <ouput> <target> [identifiers]*

       --transpile, -t <file> ?--out <resultFile>?: Transpile Typescript and get the Compiled result in the console

       --docs, -d <file> ?--out <resultFile>?: Returns the documentation of the classes and funcions inside that file

       --bundle-d [...args] Bundle Declaration Files into a single types.d.ts file
                            The ...args expect Declaration files as arguments


       --out?, -o: Filename or path to append the output

       --help, -h: Get All Available Commands

       --version, -v: get version of the package

Execution

npx swudo [..args]

or
// if globally installed
swudo [...args]

Utilities

  • Bundling Declaration : swudo comes with a feature to bundle your typescript declarations. using the flag --bundle-d and specifying your declaration files. By default it outputs a file named types.d.ts in to your current working directory.You can also use the * to read declarations from a directory.But, keep in mind that never specify a non-directory value because it gonna overwrite directory stuff

    • eg: swudo --bundle-d *DirectoryBundl myTypes.d.ts the argument with * at first is a value with dir.
  • Transpilation: swudo can transpile your Typescript code into a Javascript.The moduleType used in the output will be the default module used in your package.json.To use it, you need to specify the flag --transpile or -t.It accepts only one file as the argument.You can output the file using --out or -o and specifying a filename or path to output the result.

    • eg: swudo --transpile main.ts --out main.js
  • Generate Documentation: At the early versions of swudo it only supported exported classes.But, now it support functions too! This feature can generate a simple documentation about your code.The result would in JSON Format.

    • eg: swudo --docs program.ts --out documentation.json or you can specify the shorthand -d
  • Extraction: Extraction is useful to extract Identifiers from your code.You only need to specify the identifiers and swudo will give you the results. You can output the result using --out or -o before using the --extract flag and giving your output file a name.Note that this is experimental

    • eg: swudo --extract main.ts myFunction myClass myInterface myType or you can specify the shorthand -e

TroubleShooting

We reccomend using extract at last while using cli

swudo --transpile main.ts --extract test.ts [identifiers]

But if you specify it like this

swudo --extract test.ts [identifiers] --transpile main.ts

You are gonna get some runtime errors or additonal logs or unwanted bugs

Contributing

Feel free to open a pull request or an issue.

If you just wanna add a new feature just open a issue before you open a PR

Cloning this repo:

git clone https://github.com/swudots/swudo.git
cd swudo
yarn install

Read the contributing guidlines: Read

Haven't read the Code of Conduct. Read

License

swudo is licensed under Apache License 2.0. Open