Socket
Socket
Sign inDemoInstall

vite-wasm-zig

Package Overview
Dependencies
162
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    vite-wasm-zig

## Install


Version published
Weekly downloads
1
Maintainers
1
Created
Weekly downloads
 

Readme

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

Last updated on 13 Dec 2022

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc