cljsjs / boot-cljsjs

Helper tasks to aid the packaging of JS dependencies for Clojurescript projects
66 stars 22 forks source link

Browserified npm modules #34

Closed Risto-Stevcev closed 6 years ago

Risto-Stevcev commented 8 years ago

There are lot of JS libraries that are written to only work with browserify (such as snabbdom). There is a CDN called wzrd.in for browserify modules, but it's poorly implemented. I've barely used it and I've had multiple issues with it. It doesn't support peer dependencies (which motor/cycle needs) or choosing the entry point (which snabbdom needs). It also doesn't bundle the way browserify does, it just concatenates multiple standalone bundles, which can result in unusual behavior, and the author made it clear that he doesn't want to fix it.

I propose having a browserify boot task that can make the process of including those libraries simpler.

Node, npm and browserify would be installed on the CLJSJS end. Then the task would just install the package and run the globally installed browserify task with the given params, so it shouldn't be too hard to implement.

The task can take in the browserify optional and required parameters: entry points, the UMD module name, and output file (see usage).

For example:

(browserify :package "snabbdom" :entry "modules/class.js" :standalone "snabbdom_class" :out "snabbdom-class.js")

Which would do this under the hood:

$ npm install snabbdom
$ browserify node_modules/snabbdom/modules/class.js --standalone snabbdom_class -o snabbdom-class.js

Then it would be easy to include browserify modules like snabbdom, by just running the browserify task for all of the entry points/submodules it provides (class, props, style, events, and h), concatenating and miniftying it, and the you're done.

Deraen commented 8 years ago

I don't think we will provide specific Browserify task, but I'm thinking about creating general npm task.

burn2delete commented 8 years ago

There is a boot-npm task that could be extended to support these use cases

Deraen commented 8 years ago

npm task is tracked here: https://github.com/cljsjs/boot-cljsjs/issues/39

Deraen commented 6 years ago

New run-commands task can be used to run Npm, node etc.