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

third-party

v0.0.5

Published

Third party for HB

Downloads

52

Readme

babel-webpack-package-boilerplate

Now updated for webpack 2!

This project is meant to show how easy and useful it can be to use webpack as a tool-chain for npm packages.

Fun things in this project:

  • Source code and tests for the package are written with es2015+ and stage-0 features (specifically the features supported by the [env] and stage-0 presets for babel). See any *.js files in src for examples. See .babelrc for the babel configuration, and config/rules.js to see how babel was integrated into webpack.
  • Platform-specific polyfills and transpilation. Use of the [env] preset for babel allows webpack to avoid unused polyfills and source code transforms if the target platform supports them. See .babelrc to see how the preset was configured to support this.
  • Tree-shaking transpilation through webpack 2 and es2015+ modules. Due to the statically-analyzable module system provided by next-generation JavaScript, webpack can remove unused code and dependencies at transpiletime, resulting in smaller built artifacts.
  • Modules in lib directories can be loaded universally, like modules found in node_modules. See src/main.js and src/test/index.js for examples. See modules in config/resolve.js to see how this was configured.
  • Modules in src that end with *test.js and modules that are direct children of test directories can be run as mocha test modules, which will automatically be processed using webpack.

Getting Started

Clone the repository and install dependencies with npm.

$ git clone https://github.com/resisttheurge/babel-webpack-package-boilerplate.git
$ cd babel-webpack-package-boilerplate
$ npm install

Building

The build script defined in the package.json file uses webpack to transpile sources in the src directory. The successfully transpiled sources are placed in the dist folder. This folder is preserved by npm, but ignored by git.

$ npm run build

Watch-style building is supported by the build:watch script.

$ npm run build:watch

The prestart, and prepublish scripts defined in the package.json file reference the build script, so there's no need to run the build script manually in those situations.

Running

Run the project with npm start.

$ npm start

  hello, world!

As said before, this will automatically run the build script first.

Testing

Test the project with npm test.

$ npm test

Watch-style testing is supported by the test:watch script.

$ npm run test:watch

Publishing

Publish the project on the local machine (for testing) with npm install.

$ npm install . -g
$ babel-webpack-package-boilerplate

  hello, world!

Publish the package globally with npm publish.

$ npm publish
$ npm install -g babel-webpack-package-boilerplate
$ babel-webpack-package-boilerplate

  hello, world!

In both cases, again, this will automatically run the build script after installation.