Git Product home page Git Product logo

Comments (9)

MohammadYounes avatar MohammadYounes commented on May 20, 2024

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)!

from alertifyjs.

dantman avatar dantman commented on May 20, 2024

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').

from alertifyjs.

dantman avatar dantman commented on May 20, 2024

Also, https://www.npmjs.com/package/alertify

from alertifyjs.

dantman avatar dantman commented on May 20, 2024

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

from alertifyjs.

MohammadYounes avatar MohammadYounes commented on May 20, 2024

Done.

from alertifyjs.

dantman avatar dantman commented on May 20, 2024

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;
    }

from alertifyjs.

dantman avatar dantman commented on May 20, 2024

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

from alertifyjs.

MohammadYounes avatar MohammadYounes commented on May 20, 2024

That would be great!

from alertifyjs.

MohammadYounes avatar MohammadYounes commented on May 20, 2024

Published in 1.2.0

Thanks!

from alertifyjs.

Related Issues (20)

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.