
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
rollup-plugin-base64
Advanced tools
A Rollup plugin to load any file as a base64 string. This is especially useful for embedding WebAssembly programs into your code so no additional .wasm file needs to be loaded.
Note that with base64 encoding the size of the input file will be increased by around 33%.
A minimum example of code using a WASM function that adds two numbers together.
// rollup.json
const { base64 } = require("rollup-plugin-base64");
export default {
input: "index.js",
output: {
file: "build.js", format: 'iife'
},
plugins: [
base64({ include: "**/*.wasm" })
]
};
// index.js
import wasmB64 from "./add.wasm";
// This works in Node, in the browser you will need to convert from base64 with a different method.
const wasmBytes = Buffer.from(wasmB64, "base64");
// Note: synchronous loading is only recommended for very small binaries, please replace
// this with your favorite (asynchronous) WASM module loader code).
const mod = new WebAssembly.Module(wasmBytes);
const instance = new WebAssembly.Instance(mod, {});
const addResult = instance.exports.add(12, 34);
console.log(addResult); // 46
// build.js
(function () {
'use strict';
var wasmB64 = "AGFzbQEAAAABBwFgAn9/AX8DAgEABwcBA2FkZAAACgkBBwAgACABags=";
// This works in Node, in the browser you will need to convert from base64 with a different method.
const wasmBytes = Buffer.from(wasmB64, "base64");
// Note: synchronous loading is only recommended for very small binaries, please replace
// this with your favorite (asynchronous) WASM module loader code).
const mod = new WebAssembly.Module(wasmBytes);
const instance = new WebAssembly.Instance(mod, {});
const addResult = instance.exports.add(12, 34);
console.log(addResult); // 46
}());
Simples. Let's try it:
$ node build.js
46
This example can be found in the example folder.
You can specify which files to apply base64ing to by specifying the include and exclude field in the config object. include is required, if you leave it out an error will be thrown.
FAQs
Converts files to base64
The npm package rollup-plugin-base64 receives a total of 250 weekly downloads. As such, rollup-plugin-base64 popularity was classified as not popular.
We found that rollup-plugin-base64 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.