AIR Kit
AIR Kit (1.1.x)
AIR Kit (1.1.x)
  • Introduction
    • Welcome!
    • Quickstart
  • Web SDK
    • Installation
    • Usage
    • Customization
    • Reference
    • Wagmi Connector
    • Release Notes
  • Flutter SDK
    • Installation
    • Usage
    • Reference
  • About
    • Moca Network
Powered by GitBook
On this page
  1. Web SDK

Installation

PreviousQuickstartNextUsage

Installation

The package is currently distributed via internal NPM repository and needs an access token. Please reach out to us. You can use the token by adding following two lines to your project's .npmrc file:

@mocanetwork:registry=https://registry.npmjs.org/
//registry.npmjs.org/:_authToken=THE_TOKEN

The package can now be added to your package.json:

"@mocanetwork/airkit": "^1.0.0"

Bundling

This module is distributed in 3 formats

  • esm build dist/airkit.esm.js is es6 format

  • commonjs build dist/airkit.cjs.js in es5 format

  • umd build dist/airkit.umd.min.js in es5 format without polyfilling corejs minified

By default, the appropriate format is used for your specified use case. A different format can be used (if you know what you're doing) by referencing the correct file.

Dynamic Import

If not already, the node buffer and process libraries need to be polyfilled.

Install :

npm install --save-dev node-polyfill-webpack-plugin

Update your webpack config as follows

const NodePolyfillPlugin = require("node-polyfill-webpack-plugin");

module.exports = {
  webpack: {
    plugins: [
      new NodePolyfillPlugin({
        additionalAliases: [
          "buffer",
          "crypto",
          "assert",
          "http",
          "https",
          "os",
          "url",
          "zlib",
          "stream",
          "_stream_duplex",
          "_stream_passthrough",
          "_stream_readable",
          "_stream_writable",
          "_stream_transform",
          "process",
        ],
      }),
    ],
  },
};
npm install --save-dev vite-plugin-node-polyfills

Update the vite.config.ts file as follows

import react from "@vitejs/plugin-react";
import { defineConfig } from "vite";
import { nodePolyfills } from "vite-plugin-node-polyfills";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    react(),
    nodePolyfills({
      include: [
        "buffer",
        "crypto",
        "assert",
        "http",
        "https",
        "os",
        "url",
        "zlib",
        "stream",
        "_stream_duplex",
        "_stream_passthrough",
        "_stream_readable",
        "_stream_writable",
        "_stream_transform",
      ],
    }),
  ],
});

Install :

node-polyfill-webpack-plugin
vite-plugin-node-polyfills