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

prebundle

v1.2.2

Published

Prebundle 3rd party dependencies, output a single js file, a package.json file and the dts files.

Downloads

4,103

Readme

Prebundle

Prebundle 3rd party dependencies, output a single js file, a package.json file and the dts files.

Based on ncc and rollup-plugin-dts.

Motivation

Prebundle is used to:

  • Reduce dependencies of core packages, install faster.
  • Improve stability by locking the sub-dependency version .
  • Fix peer dependency warning of some packages.

Command

Run following command to prebundle all dependencies:

npx prebundle

Run following command to prebundle single dependencies:

npx prebundle <pkgName>

# For example, prebundle commander
npx prebundle commander

Dependency Config

Supported dependency config:

externals

Externals to leave as requires of the build.

// prebundle.config.mjs
export default {
  dependencies: [
    {
      name: 'foo',
      externals: {
        webpack: '../webpack',
      },
    },
  ],
};

You can also configure externals for all packages like this:

// prebundle.config.mjs
export default {
  externals: {
    webpack: '../webpack',
  },
  dependencies: [{ name: 'foo' }, { name: 'foo' }],
};

dtsExternals

Externals for dts.

// prebundle.config.mjs
export default {
  dependencies: [
    {
      name: 'foo',
      dtsExternals: ['webpack'],
    },
  ],
};

minify

Whether to minify the code, default false.

// prebundle.config.mjs
export default {
  dependencies: [
    {
      name: 'foo',
      minify: false,
    },
  ],
};

packageJsonField

Copy extra fields from original package.json to target package.json.

// prebundle.config.mjs
export default {
  dependencies: [
    {
      name: 'foo',
      packageJsonField: ['options'],
    },
  ],
};

Following fields will be copied by default:

  • name
  • author
  • version
  • funding
  • license
  • types
  • typing
  • typings

beforeBundle

Callback before bundle.

// prebundle.config.mjs
export default {
  dependencies: [
    {
      name: 'foo',
      beforeBundle(task) {
        console.log('do something');
      },
    },
  ],
};

emitFiles

Emit extra entry files to map imports.

// prebundle.config.mjs
export default {
  dependencies: [
    {
      name: 'foo',
      emitFiles: [
        {
          path: 'foo.js',
          content: `module.exports = require('./').foo;`,
        },
      ],
    },
  ],
};

ignoreDts

Ignore the original .d.ts declaration file, then generate a fake .d.ts file.

This can be used to reduce file size for the packages that do not require type definitions, such as webpack plugin.

// prebundle.config.mjs
export default {
  dependencies: [
    {
      name: 'foo',
      ignoreDts: true,
    },
  ],
};

target

Target ECMAScript version, default es2021.

// prebundle.config.mjs
export default {
  dependencies: [
    {
      name: 'foo',
      target: 'es2015',
    },
  ],
};

prettier

Whether to prettier the code and strip comments, default false.

// prebundle.config.mjs
export default {
  prettier: true,
};