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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@centrid/native-modules-prebuilds-creator

v1.5.10

Published

Main package for creating prebuilds for multiple native modules.

Downloads

1

Readme

Native Module Prebuilds Creator

Main package for creating prebuilds for multiple native modules.

Please Note: This project is maintained on gitlab.com

Please see home to get a fuller picture of this package.

Installation

npm i @centrid/native-modules-prebuilds-creator
yarn add @centrid/native-modules-prebuilds-creator

Usage

This package can be used through its CLI interface or through its programmatic API.

Please Note:

  • This package utilizes prebuildify to create the packages (acts like a prebuildify wrapper). This means you can pass any build options that prebuildify accepts programmatically, and it will pass them on. However, only the below options have been tested, and using any other ones might result in unexpected results.
  • When you specify the same output, the prebuilds content is merged, not overridden. This means you can run the prebuild creator on Linux, then on Windows, and then on macOS to get prebuilds that cater to all those platforms.

CLI Usage

npx prebuilds-creator <options>

| CLI | Default | Description | Example | | | --- | --- | --- | --- | --- | | --packages | - | Native node packages you want to create prebuilds for | --packages "[email protected],[email protected],[email protected]" | | | --arch | - | Target Architecture | --arch "x64" | | | --platform | - | Target Platform | --platform "win32" | | | --targets | - | One or more targets | --targets "[email protected],[email protected]" | | | --out | path.join(process.cwd(), './NMPrebuilds') | Output path for the generated prebuilds folder | | | | --onUnsupportedTargets | error | What to do when a target does not seem to be supported. For example, when a package specifies it only works with Node.js versions 19 and above, and you select Node.js 10.0.0 as your target. Options: 'error' or 'skip' or 'force' | | |

Programmatic Usage

import { PrebuildsCreator } from "@centrid/native-modules-prebuilds-creator";

const prebuilder = new PrebuildsCreator(
  /* globalPrebuildifyOpts: IPreBuildifyOptions */
  {
    arch: "x64",
    platform: "win32",
    targets: [
      {
        runtime: "node",
        target: "25.0.0"
      },
      {
        runtime: "electron",
        target: "20.0.0"
      },
      {
        // Note: You can specify a particular ABI version as well
        abiVersion: "108"
      }
    ]
  },
  /* packageToProcess: IPackagesToProcess */
  [
    {
      packageName: "drivelist",
      version: "9.2.4"
    },
    {
      packageName: "msgpackr-extract",
      version: "3.0.2",
      // Package-specific prebuildify props
      prebuildifyProps: {
        targets: [
          {
            runtime: "node",
            target: "25.0.0"
          }
        ]
      }
    }
  ],
  /* dist: string */
  path.join(__dirname, "myGeneratedPrebuilds")
);

prebuilder.Create().then(() => {
    console.log("done");
  })
  .catch((err) => {
    console.error(err);
  });

Prebuilds Patcher

When the prebuilds folder is created, it has a compiled version of the prebuilds patcher (See Native Module Prebuild Patcher). This version also wraps the appropriate prebuild-manifest.json and returns an instantiated version of the PrebuildsPatcher when imported. Additionally, it has a CLI interface that you can use to patch. Options are highlighted below:

Commands:

| CLI | Description | | | --- | --- | --- | | patchAll | Patch all native modules in your current project using the generated prebuilds. This will look for all the native modules in your current project, check if applicable prebuilds are available, and patch as appropriate | | | patchSpecific | Similar to patchAll, but allows you to specify which package you want to patch |
| revertPatches | Revert patched native modules | |

Options:

| Option | Default | Description | Example | Applicable Command | | --- | --- | --- | --- | --- | | --arch | - | Target Architecture | --arch "x64" | patchAll, patchSpecific | | --platform | - | Target Platform | --platform "win32" | patchAll, patchSpecific | | --target | - | Target to use | --target "[email protected]" | patchAll, patchSpecific | | --packages | - | Packages to patch when patch specific is selected | --packages "[email protected]" | patchSpecific | | --forceRebuildOnNoBindings | true | To patch the correct prebuild-patcher at times, it needs to determine the correct binding file. If the native module has not been built, it cannot figure this out. This rebuilds the project so as to be able to obtain the correct binding file to patch | | patchAll, patchSpecific | | --shouldBackup | true | Should back up native package before patching. Allows you to revert patches after building. (see --revertPatches below) | | patchAll, patchSpecific | | --onPatchFail | error | What to do when a patch fails. Options: 'error' or 'skip'. Note: On error, all patches are reverted (i.e., revertPatches is called) | | patchAll, patchSpecific | | --onNoPrebuildsFound | skip | When no prebuilds are found for a native module currently installed in your project. Options: 'error' or 'skip' | | patchAll, patchSpecific | | --projectPath | Determines from process.cwd() | Project path to which the patch will be applied | | patchAll, patchSpecific, revertPatches |

To use the patcher programmatically, please see Native Module Prebuild Patcher

Future Improvements and Other Notes

  • Most of the operations in these packages are run synchronously, and performance gains can be made by running most of these operations asynchronously. This will be considered for future releases.

Contributing

Native Module Prebuilds Creator is an open-source project, and contributions are welcome. If you have a bug fix, please create a pull request explaining what the bug is, how you fixed it, and how you tested it.

If it's a new feature, please add it as an issue with the "enhancement" label, providing details about the new feature and why you think it's needed. We will discuss it there, and once it's agreed upon, you can create a pull request with the highlighted details.

Authors

License

This project is licensed under the MIT License - see the LICENSE file for details.