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

as-loader

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

as-loader

AssemblyScript loader for webpack

  • 0.0.1-canary.2.42069f1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
27
increased by575%
Maintainers
1
Weekly downloads
 
Created
Source

as-loader

AssemblyScript loader for webpack (⚠️ In development ⚠️)

Installation

This loader requires minimum AssemblyScript 0.18, Node.js 8 and webpack 4 (webpack 5 support will be implemented soon)

# with npm
npm install --save-dev as-loader

# with yarn
yarn add --dev as-loader

The minimal webpack config:

// webpack.config.js
module.exports = {
  entry: "src/index.ts",
  resolve: {
    extensions: [".ts", ".js"],
  },
  module: {
    rules: [
      {
        test: /\.ts$/,
        include: path.resolve(__dirname, "src/assembly"),
        loader:  "as-loader",
      },
      {
        test: /\.ts$/,
        exclude: path.resolve(__dirname, "src/assembly"),
        loader: "ts-loader",
      },
    ],
  },
};

Usage

// myModule becomes an URL to the .wasm file
// (TypeScript doesn't know that, so we can still use the import type)
import * as myModule from "./assembly/myModule";
// this example uses @assemblyscript/loader, but you can use
// any loader, like as-bind or WebAssembly API
import { instantiateStreaming } from "@assemblyscript/loader";

async function loadAndRun() {
  // load module using @assemblyscript/loader
  const module = await instantiateStreaming<typeof myModule>(
    // workaround for TypeScript
    fetch((myModule as unknown) as string)
  );
  module.exports.myFunction(100);
}

loadAndRun();

Options

TODO

FAQs

Package last updated on 18 Feb 2021

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