Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/pine/arraybuffer-loader

:dvd: ArrayBuffer loader for webpack
https://github.com/pine/arraybuffer-loader

javascript nodejs webpack

Last synced: 10 days ago
JSON representation

:dvd: ArrayBuffer loader for webpack

Awesome Lists containing this project

README

        

# arraybuffer-loader   [![npm](https://img.shields.io/npm/v/arraybuffer-loader.svg?maxAge=2592000)](https://www.npmjs.org/package/arraybuffer-loader) [![build](https://github.com/pine/arraybuffer-loader/actions/workflows/build.yml/badge.svg)](https://github.com/pine/arraybuffer-loader/actions/workflows/build.yml) [![License](https://img.shields.io/github/license/emoji-gen/clone-into.svg)](LICENSE)

:dvd: ArrayBuffer loader for webpack

## Supported Platforms

- Modern Browsers (IE >= 10)
- Node.js

## Getting Started

```
$ yarn add arraybuffer-loader
```

or

```
$ npm install arraybuffer-loader --save-dev
```

## Usage
If you read only the specific extensions (e.g. wasm), please add loader in `webpack.config.js`.

```js
module: {
rules: [
{
test: /\.png$/,
loaders: ['arraybuffer-loader'],
},
],
},
```

Or if reading an arbitrary extension, use `require`.

```js
const buffer = require('arraybuffer!./data.dat')
const array = new Uint8Array(buffer)
```

See also offical document [Loaders](https://webpack.js.org/concepts/loaders/).

### For `.wasm` file
Webpack 4 or later has embedded WASM parser. So, please set `type: 'javascript/auto'` when use `arraybuffer-loader`.

```js
module: {
rules: [
{
test: /\.wasm$/,
type: 'javascript/auto',
loaders: ['arraybuffer-loader'],
},
],
},
```

## License
MIT © [Pine Mizune](https://profile.pine.moe)