npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

cpp-portable-loader

v0.5.5

Published

1) Add as your .cpp loader in your webpack.config.js file: ```js module.exports = { resolve: { extensions: [".cpp"] }, module: { rules: [ { test: /\.cpp$/, loader: "cpp-portable-loader?emitMapFile" }, ] }, resolveLoader: { modules: ["node_modules"] }, };

Readme

Usage

  1. Add as your .cpp loader in your webpack.config.js file:
module.exports = {
    resolve: {
        extensions: [".cpp"]
    },
    module: {
        rules: [
            { test: /\.cpp$/, loader: "cpp-portable-loader?emitMapFile" },
        ]
    },
    resolveLoader: {
        modules: ["node_modules"]
    },
};
  1. Write your .cpp file, marking exported values with __attribute__((visibility("default"))), or importing export-helpers from node_modules and using the EXPORT macro.:
/* example.cpp */
#include "../node_modules/cpp-portable-loader/export-helpers.h"
int return5() {
    return 5;
}
  1. Import the .cpp file to trigger .d.ts file generation (make sure not to import anything from it, or else webpack will think you are using the import and .d.ts generation will not occur):
import "./example.cpp";
  1. Remove the earlier import and import from the .cpp file as if it a JS file:
import { return5 } from "./test.cpp"
  1. Either call functions and await the promise result, or get all of the functions in a promise, await that, and then call the functions synchronously:
import { return5, GetSyncFunctions } from "./test.cpp"

async example() {
    assert(await return5() === 5);
    let fncs = await GetSyncFunctions();
    assert(fncs.return5() === 5);
}

Requirements

  • Window 64 bit, OSX 64 bit, or Linux 64 bit

Features

  • No installation required, all requirements (including the clang compiler) are in npm modules, which require no installation (they have no install scripts in their package.json).
  • Automatic sourcemap generate and inlining
  • Automatic .d.ts file generate for .cpp file, based on actual C++ types
    • Structs and classes are supported for types
  • Some (very limited) buffer support, allowing non primitive types to be passed to and from C++ code
  • Some (very limited) function support, allowing functions to be passed to and from C++ code

Options

  • emitMapFile
    • Emits a .wasm.map beside the .wasm output.
  • noInlineSourceMap
    • Prevents inlining of source map with the .wasm file.

Notes

  • .d.ts files are emitted in the source directory, which may cause webpack --watch to infinitely loop. This can be solved by excluding .d.ts files from your typescript loader ({ test: /(([^d])|([^.]d)|(^d))\.tsx?$/, loader: "ts-loader", }), however this will result in compilation not being triggered if you only change .d.ts files. As a result if you save a .cpp file and a .ts file that uses the generated .d.ts file, you may need to force two compilations before the .d.ts changes are picked up.
  • .wasm files are emitted in the output directory, even when running webpack-dev-server.

Caveats

  • Support for exceptions (via throw) is limited and does not work on Linux.