Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vite-wasm-zig

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vite-wasm-zig

## Install

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

npm package zig language zig language

vite-wasm-zig

Install

yarn add -D vite-wasm-zig

Usage

// vite.config.{js, ts}
import zig from 'vite-wasm-zig';

export default defineConfig(({ mode }) => {
    return {
        plugins: {
            zig({
                // Enable this option require `wasm-opt` installed on your $PATH.
                optimize: mode === 'production',
                // Other options goes here
            })
        }
    }
}
// main.zig

export fn add(a: i32, b: i32) i32 {
    return a + b;
}
// index.{js,ts}
import init from "./main.zig?init";

function someFunc() {
  const importObject = {
    /* ... */
  };

  init(importObject).then((instance) => {
    console.log(instance.exports.add(1, 10));
  });
}
// OR
// This plugin support SSR, so top level await is OK
const instance = await init(importObject)
console.log(instance.exports.add(1, 10));
export default instance.exports;

With Typescript

Add to tsconfig.json:

{
  "types": ["vite/client", "vite-wasm-zig/client"]
}

Semver

Until 1.0 release, this package don't follow Semver for versioning

Lisence

MIT

Keywords

FAQs

Package last updated on 13 Dec 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc