A webpack loader that returns file contents as an ArrayBuffer, useful for binary file types like WebAssembly (.wasm), images, or data files. Current stable version is 1.0.8. The package has low release cadence, primarily dependency updates. Key differentiator: provides raw ArrayBuffer output, whereas similar loaders may return different buffer types. Supports modern browsers (IE>=10) and Node.js. Security fix in v1.0.6 replaced deprecated Buffer API. Works with webpack 4+ but requires special configuration for .wasm files due to built-in webpack WebAssembly support.
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
For .wasm files, webpack 4+ requires `type: 'javascript/auto'` to avoid parsing issues.
// In webpack.config.js
module: { rules: [{ test: /\.wasm$/, type: 'javascript/auto', use: ['arraybuffer-loader'] }] }
Inline loader syntax 'arraybuffer!./file.dat' tells webpack to use arraybuffer-loader.
const buffer = require('arraybuffer!./file.dat')
No default named export; use inline loader syntax in import statement.
import buffer from 'arraybuffer!./file.dat'
Shows webpack configuration for .wasm and .dat files, with inline require usage to get ArrayBuffer, then convert to Uint8Array.
// Install: npm install --save-dev arraybuffer-loader
// webpack.config.js
module.exports = {
entry: './src/index.js',
output: {
filename: 'bundle.js',
path: __dirname + '/dist'
},
module: {
rules: [
{
test: /\.wasm$/,
type: 'javascript/auto',
use: ['arraybuffer-loader']
},
{
test: /\.dat$/,
use: ['arraybuffer-loader']
}
]
}
};
// src/index.js
const wasmBuffer = require('./module.wasm');
WebAssembly.instantiate(wasmBuffer).then(result => {
console.log('WASM loaded');
});
const datArray = new Uint8Array(require('./data.dat'));
console.log('Data length:', datArray.length);
Upgrade
Version history
Breaking-change detection hasn't run for this library yet.
Audit
Security & dependencies
CVE tracking and dependency tree are planned for a later release.