New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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.1.6861157.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
33
increased by230%
Maintainers
1
Weekly downloads
 
Created
Source

as-loader

AssemblyScript loader for webpack

Installation

This loader requires minimum Node.js 8 and webpack 4

# 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"),
        use: [
          // emits WASM Buffer as a .wasm file
          // and returns CJS module with an URL to that file
          {
            loader: "file-loader",
            options: {
              name: "[path][name].wasm",
              esModule: false,
            },
          },
          // converts AssemblyScript to WASM Buffer
          "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";
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();

FAQs

Package last updated on 17 Jan 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