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

werkzeug-packer

v0.0.7

Published

packs commonjs modules to browser ready bundles

Downloads

3

Readme

werkzeug-packer

Packs commonjs modules to browser ready bundles.
It is limited in its skills but easy to use and fast.

What werkzeug-packer does:

  • packs your commonjs style modules to bundles for use in browsers

  • supports asynchronous chunks (webpack style promisses)

  • watches for changes and packs incremental

  • merges source maps for all files into one for each bundle (with the ability to inline sources for use in firefox)

  • you can require json, css, html and txt files in your code, which will be inlined as strings (except json, which exports an object)

  • has little support for es6 node modules (es6 will be transpiled using babel)

  • experimental uglifying (leads to incorrect source mappings)

  • node core modules will be ignored

Usage


    # for global commandline use:
    npm install -g werkzeug-packer
    
    # or local to your project:
    npm install werkzeug-packer --save-dev
    
    # if you have a file main.js, type:
    wzp -p main.js
    
    # this will create a bundle main.pack.js which includes all required files
    
    # you also can specify the name and location for the resulting bundle
    wzp -p main.js ./dist/main.bundle.js
    
    # you can pack any number of modules:
    wzp -p main.js -p vendor.js -p polyfills.js
    
    # you have to add script tags for all packs 
    # to your index.html in the same order as specified  
    
    # add a -w flag to watch
    wzp -p main.js -w
    

Flags

werkzeug-packer can be configured with the following flags:

    
-p  --pack          [file] [file?]  Specify the input file and optional an output file.
                                    If the output file is omitted, the input file's name is used.
                                    with a 'pack' inserted before the extension:
                                    e.g.: main.js -> main.pack.js
                                    Can be used multiple times for each module to bundle.
-w  --watch                         Start watching and repack on changes.
-bp --base-path     [file]          Specify a base path to resolve relative files used with -p flag.
-ub --use-babel                     Enable babel for es6 code.
-uu --use-uglify                    Enable experimantal uglify usage. 
-im --inline-maps                   Include source code in source maps. 
-em --external-maps                 Include soyrce maps from node modules.
-cp --chunk-prefix  [path]          Enter a path and/or a file prefix for all packed chunks.
                                    The default is './js/chunk_'.
-lp --loader-prefix [string]        Enter a string to prifix required path's for chunk loading.
                                    The default is 'es6-promise!'.
-ne --node-env      [string]        Enter a value to set in window.process.env.NODE_ENV.
                                    The default is 'development'.
-v  --version                       Prints the version.
-h  --help                          Prints this help.  
            
            
If you specify more than the entry bundle, you have to require all other bundles from your main file (or from subsequent required files).
Otherwise they won't be activated.
Remember to place script tags for each bundle in your index.html.   
           

Chunks


    # consider a file test.js
    module.exports = Hello: 'World'
    
    # then you can do the following in another file:
    test = require 'es6-promise!./test'
    test('Hello').then (result) ->
        console.log 'Hello ' + result # prints 'Hello World' ;-)
              
    # if the name is omitted the whole exports object is passed to result              
    

License

werkzeug-packer is free and unencumbered public domain software. For more information, see http://unlicense.org/ or the accompanying UNLICENSE file.