GithubHelp home page GithubHelp logo

sebmarkbage / wrapup Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kamicane/wrapup

3.0 3.0 0.0 170 KB

wraps up your node modules into web modules

License: MIT License

JavaScript 100.00%

wrapup's Introduction

wrapup

whatwrup?

WrapUp compiles CommonJS 1.0 modules and / or packages for the browser. It does not try to have a working require implementation for the browser or anything for the sorts. The boilerplate that WrapUp uses is incredibly simple.

installation

npm install wrapup -g

usage

packages

This is how you wrap up the package in the current folder (will look for ./package.json)

wrup --package
wrup --package ./

When requiring a package, node looks inside the node_modules folders. If you have installed moofx in the current directory with npm install moofx, for instance, this will work:

wrup --package moofx

If you also installed emi, this will also work:

wrup --package moofx emi

But this doesn't mean you cant require a package that is installed somewhere else:

wrup --package ~/projects/moofx

modules

This is how you wrapup a random module. window.color (if --globalize is true) will be created, with the namespace retrieved from the file name.

wrup --module ~/projects/moofx/lib/color.js

Like packages, modules are resolved automatically by node, so you can cherry-pick easily:

wrup --module moofx/lib/color

You can also assign a custom namespace, especially useful when requiring modules that are indices or mains:

wrup --module ~/projects/moofx/lib/main.js moofx

...which is equivalent of

wrup --package ~/projects/moofx

Except the namespace is given by you, rather than read from package.json

packages + modules

Packages and modules can be mixed:

wrup --package ./ ~/projects/emi --module ~/projects/moofx/lib/color.js

on the browser

Once built, namespaces will be available on window if you wish so (--globalize defaults to true):

wrup --package moofx --module ... --module ... --globalize yes
moofx(div).animate(...)

If you prefer, namespaces will be retrievable using the wrup client (--wrup defaults to false):

wrup --package moofx --wrup yes --globalize no
wrup('moofx')(div).animate(...)

This is especially useful since modules are only executed when first required. Attaching them to window also means they are immediately required. Using the wrup client might (or might not) save some resources in some situations.

moar help:

wrup --help

wrapup's People

Contributors

kamicane avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.