Registry / web-framework / uint8array-loader

uint8array-loader

JSON →
library1.0.2jsnpmunverified

Webpack loader that returns file content as a Uint8Array, useful for loading binary files (e.g., FlatBuffers schemas) in webpack bundles. Current stable version is 1.0.2, with no recent releases. It is designed to be used with babel-loader, but actually works as a standalone loader. Unlike raw-loader or file-loader, this loader returns an actual Uint8Array object instead of a string or URL. The package has minimal dependencies and is intended for webpack projects needing binary data in array buffer form.

npm install uint8array-loader
INSTALL
IMPORT
SIG · UINT8ARRAY-LOADER
U
uint8array-loader
web-frameworkjavascriptv1.0.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

default
import data from './file.bfbs';
import { data } from './file.bfbs';
The loader exports the content as a default export; named imports will not work.
require
const data = require('./file.bfbs');
CommonJS require also works, returning the Uint8Array.
Uint8Array (type)
import type { Uint8Array } from './file.bfbs';
TypeScript users may need type assertion; the loader does not ship types, but the result is always Uint8Array.

Shows how to configure webpack to use uint8array-loader for .bfbs files and import the binary content as a Uint8Array.

// webpack.config.js module.exports = { module: { rules: [ { test: /\.bfbs$/, use: 'uint8array-loader' } ] } }; // app.js import binaryData from './schema.bfbs'; console.log(binaryData instanceof Uint8Array); // true console.log(binaryData.byteLength);
Debug
Known issues
gotchaThe package name is misspelled 'unit8array' but the export returns 'Uint8Array' correctly.
fix
Import the loader as 'uint8array-loader' (note the typo).
affects: all
gotchaThis loader does not work with webpack 5 out of the box if babel-loader is not installed, as it lists babel as a dependency but actually not required.
fix
Ensure webpack is installed; remove babel-loader if not used.
affects: >=1.0
breakingLoader returns Uint8Array, which may not be expected if you are used to raw-loader returning a string.
fix
If you need a string, convert using TextDecoder or use raw-loader instead.
affects: all
deprecatedThe package has not been updated since 2018 and may have compatibility issues with modern webpack versions.
fix
Consider using asset modules in webpack 5 to load binary data.
affects: >=1.0
gotchaThe loader's repository URL in npm points to a 404 page; it is unmaintained.
fix
Fork the package or use an alternative loader.
affects: all
Errors
Common errors & fixes
Module not found: Error: Can't resolve 'uint8array-loader'
The loader package is not installed or listed in devDependencies.
fix
Run 'npm install --save-dev uint8array-loader' to install it.
TypeError: (intermediate value).call is not a function
The loader is being used without webpack, or the loader version is incompatible with the webpack version.
fix
Ensure you are using webpack 4 and that the loader is applied as a rule, not as a plugin.
Cannot read property 'getOptions' of undefined
Webpack 5 removed loader options via this.getOptions; this loader expects an older webpack API.
fix
Use webpack 4 or switch to asset modules for binary files.
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies
webpackrequiredPeer dependency; the loader runs as a webpack loader.
Agent activity
5 hits · last 30 days
node
5
Resources
uint8array-loader — npm install uint8array-loader · libregistry