Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish to npm #22

Closed
dantman opened this issue Feb 17, 2015 · 9 comments
Closed

Publish to npm #22

dantman opened this issue Feb 17, 2015 · 9 comments

Comments

@dantman
Copy link
Contributor

dantman commented Feb 17, 2015

This library has a packages.json but doesn't appear to be published on npm.

browserify is easiest to use with npm modules so it would be nice to have it published.

@MohammadYounes
Copy link
Owner

I'm not sure if its useful to publish to npm, as this is not a node module. It has pacakage.json mainly for installing dev. dependencies.

Don't know how Browserify fits here, its supposed to work the other way around (making node modules work in the browser)!

@dantman
Copy link
Contributor Author

dantman commented Feb 17, 2015

velocity-animate and cropper are similarly dedicated to browsers but are in npm.
Libraries like jQuery, moment, lodash, postal, q, and string that work on both client and server explicitly support using the npm installed package in the browser.

Browserify doesn't simply make node modules work in the browser. It lets you write your code in CommonJS/Node.js style using require() and local module scope. Then when built wraps it up and automatically wraps up and bundles the code for any modules that it depends on via require().

If I were to npm install someclientlib --save and then add var SomeClientLib = require('someclientlib'); and rebuild my client code, browserify would include the library and my module could just start using it.

The standard source for these browserify looks for in is npm (or rather node_modules/) where package.json can have an optional tiny bit extra if the package should use a different set of modules on the client.

To include something not in npm I have to mess around, either doing an ugly relative require or adding a hack to my package.json to tell it to load a certain file when I write require('foobar').

@dantman
Copy link
Contributor Author

dantman commented Feb 17, 2015

@dantman
Copy link
Contributor Author

dantman commented Feb 17, 2015

Though I do admit the "AMD and window support" section also needs an update to support browserify.

@MohammadYounes
Copy link
Owner

Done.

@dantman
Copy link
Contributor Author

dantman commented Feb 17, 2015

Something like:

    // AMD and window support
    if ( typeof module === 'object' && typeof module.exports === 'object' ) {
        module.exports = alertify;
    } else if ( typeof define === 'function' ) {
        define( [], function () {
            return alertify;
        } );
    } else if ( !window.alertify ) {
        window.alertify = alertify;
    }

@dantman
Copy link
Contributor Author

dantman commented Feb 17, 2015

I'll make a pull request for the other tweaks for full npm/browserify support.

@MohammadYounes
Copy link
Owner

That would be great!

@MohammadYounes
Copy link
Owner

Published in 1.2.0

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants