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

@n3dst4/browser-bundle

v1.2.0

Published

An opinionated browser code bundler using browserify and babelify

Downloads

8

Readme

@n3dst4/browser-bundle

Travis status

An opinionated browser code bundler using browserify & babelify

Installation

npm install @n3dst4/browser-bundle --save

Usage

import browserBundle from "@n3dst4/browser-bundle"
browserBundleTask(inFilePath, outFilePath [, options] )

where

  • inFilePath is the path to the entry-point script for your build (this is passed to Browserified as entries)
  • outFilePath is the path that the results will be saved under
  • options is an optional object which, if present, may contain the following keys:
    • watch: if true, put the task into watch mode, i.e. become long-running and rebuild when changes occur to the source
    • production: if true, omit source maps and minify the resulting code

Returns an eventEmitter that represents the bundling stream. You can listen to the the "end" event to know when the bundling is completed.

In watch mode, there is also an updated event that is triggered after a rebuild has finished.

Examples

Just build the code once

This module exports a function which takes source and destination filename parameters, and builds and bundles your source.

import browserBundle from "@n3dst4/browser-bundle"

const entryPoint = "src/main.js"
const outFileName = "build/main.js"

browserBundle(entryPoint, outFileName)

In a gulp task

Wrap your call to browserBundle in an arrow function to easily turn it into a gulp-compatible task.

gulp.task("build", () => {
   browserBundle(entryPoint, outFileName)
})

Watch mode

The task can be configured to run in watch mode, i.e. it will become long-running and rebuild your bundle every time a change is detected. Do this by passing in an options object with watch set to true:

browserBundle(entryPoint, outFileName, {watch: true})

or in gulp:

gulp.task("watch", () => {
   browserBundle(entryPoint, outFileName, {watch: true})
})

Production mode

This module makes no assumptions about what you may or may not consider to be "production", e.g. it doesn't interrogate NODE_ENV. If you want to build in "production" mode, which omits source maps and minifies the code, pass the option production:

browserBundle(entryPoint, outFileName,
   {production: process.env.NODE_ENV === "production"})

or in gulp:

gulp.task("build", () => {
   browserBundle(entryPoint, outFileName,
      {production: process.env.NODE_ENV === "production"})
   })

Triggering browser reloads with .on("updated")

You can add an event listener for the "updated" event to trigger any kind of browser reload you might need (this package is not bound to any particular system.)

gulp.task("watch", () => {
   const task = browserBundle(entryPoint, outFileName, {watch: true}))
      .on("updated", browserSync.reload)
})