Registry / web-framework / arraybuffer-loader

arraybuffer-loader

JSON →
library1.0.8jsnpmunverified

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.

npm install arraybuffer-loader
INSTALL
IMPORT
SIG · ARRAYBUFFER-LOADER
A
arraybuffer-loader
web-frameworkjavascriptv1.0.8
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
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
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

none (loader usage in webpack config)
// In webpack.config.js module: { rules: [{ test: /\.wasm$/, type: 'javascript/auto', use: ['arraybuffer-loader'] }] }
module: { rules: [{ test: /\.wasm$/, use: ['arraybuffer-loader'] }] }
For .wasm files, webpack 4+ requires `type: 'javascript/auto'` to avoid parsing issues.
inline require
const buffer = require('arraybuffer!./file.dat')
const buffer = require('./file.dat')
Inline loader syntax 'arraybuffer!./file.dat' tells webpack to use arraybuffer-loader.
ESM import (not directly supported)
import buffer from 'arraybuffer!./file.dat'
import buffer from './file.dat'
No default named export; use inline loader syntax in import statement.

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);
Debug
Known issues
gotchaWebpack 4+ fails to compile .wasm files with arraybuffer-loader unless type: 'javascript/auto' is set
fix
Add `type: 'javascript/auto'` to the rule for .wasm files.
affects: >=1.0.0
deprecatedArrayBuffer is not directly usable in Webpack 5 without additional configuration due to asset modules
fix
Consider using webpack 5's asset/resource module type with raw-loader or custom loader for ArrayBuffer.
affects: >=1.0.0
breakingBuffer.from replaces new Buffer in v1.0.6 security fix; old code using new Buffer may break
fix
Update to v1.0.6 or later; no code change needed as API is compatible.
affects: <1.0.6
Errors
Common errors & fixes
Module parse failed: Unexpected token (1:0) / You may need an appropriate loader to handle this file type.
Webpack 4+ tries to parse .wasm as JavaScript; missing `type: 'javascript/auto'`.
fix
Add `type: 'javascript/auto'` to the rule for .wasm files in webpack config.
TypeError: Cannot use 'in' operator to search for 'length' in undefined
Output buffer is undefined because loader wasn't applied (wrong extension or missing rule).
fix
Verify the file extension matches `test` regex in webpack rule, or use inline syntax: `require('arraybuffer!./file.dat')`.
Error: Module not found: Error: Can't resolve 'arraybuffer' in '...'
Inline loader syntax missing underscore before arraybuffer; should be 'arraybuffer!./file.dat'.
fix
Use correct inline syntax: `const buffer = require('arraybuffer!./file.dat')`.
WARNING in ./file.wasm / Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
Using dynamic require with .wasm file; webpack cannot statically analyze it.
fix
Use static require or import with the loader: `const wasm = require('./file.wasm')`.
Upgrade
Version history
1.0.8latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
27 hits · last 30 days
node
22
OpenAI (training)
2
Amazon
1
Resources
arraybuffer-loader — npm install arraybuffer-loader · libregistry