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.
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);
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'`.
fixAdd `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).
fixVerify 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'.
fixUse 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.
fixUse static require or import with the loader: `const wasm = require('./file.wasm')`. Audit
Dependencies
No dependency data recorded yet.