npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

zig-script

v0.1.0

Published

Convert JavaScript and TypeScript to Zig seamlessly

Downloads

3

Readme

ZigScript (Work in Progress)

Overview

ZigScript is a powerful tool designed to seamlessly transpile TypeScript--and, by extension, JavaScript--code to Zig, allowing developers to take advantage of Zig's cross-compilation and low-level optimization capabilities while preserving access to high-level language constructs afforded by JavaScript and TypeScript. This README file provides essential information on using ZigScript, its features, and design principles.

Table of Contents

Getting Started

To experiment with ZigScript and contribute to its development, follow these steps:

  1. Install Zig on your machine (https://ziglang.org/download/).
  2. Clone this repository: git clone https://github.com/clay-curry/ZigScript.git
  3. Build the script: zig build
  4. Start exploring and enhancing the codebase!

Features

  • JavaScript and TypeScript Support: ZigScript currently supports a variety of JavaScript and TypeScript features, but the project is a work in progress, and not all features may be fully supported.

  • Performance: The script leverages Zig's performance-oriented design, with ongoing efforts to optimize and enhance code generation.

  • Error Reporting: Clear and concise error messages are provided, but improvements are continually being made to enhance error transparency.

  • Maintainability: The generated Zig code aims to be readable and maintainable, but ongoing efforts are in place to improve code quality.

Usage

Whatever your use case, ZigScript requires having Zig installed on your machine. To install Zig, follow the instructions here.

Transpile JavaScript | TypeScript

To transpile a JavaScript or TypeScript file, use the following command:

zig build run -- input.js

Replace input.js with the path to your JavaScript or TypeScript file. The transpiled Zig code will be generated in the same directory with the .zig extension.

Build

Currently this only works on Linux. To build a distributable npm package, we will use the Bun Runtime. First, install Bun:

curl -fsSL https://bun.sh/install | bash

For additional options and advanced Bun usage, refer to Bun documentation. Using the runtime defined by Bun, we will execute the build script defined in our local package.json file as follows,

bun run build

Note that the above command builds the debuggable ZigScript executable within the zig-out directory, which, in addition to Zig output files, produces compiler log messages and additional compilation information such as intermediate AST representations, relocatable object files, resolved paths, and potentially other useful information in the future.

To build an equivalent

Design Principles

  1. Preservation of High-Level Semantics: ZigScript prioritizes maintaining the high-level semantics of JavaScript and TypeScript code, with ongoing enhancements to cover a broader range of language features.

  2. Readability and Understandability: The generated Zig code is designed to be readable and understandable, with continuous efforts to improve code clarity and structure.

  3. Progressive Enhancement: ZigScript supports a progressive enhancement approach, allowing you to incrementally transpile and optimize parts of your codebase as ongoing development progresses.

  4. Error Transparency: Clear error messages are provided during the transpilation process, and ongoing work is being done to improve error reporting for a smoother development experience.

  5. Performance-Oriented: The script aims to generate Zig code that is performant, with ongoing optimizations to harness Zig's low-level capabilities more effectively.

Contributing

Contributions are highly encouraged! See the Contribution Guidelines for details on how to get involved.

License

ZigScript is licensed under the MIT License - see the LICENSE file for details.