carrot / roots-browserify Goto Github PK
View Code? Open in Web Editor NEWRoots v3 extension that uses browserify as a javascript pipeline
License: Other
Roots v3 extension that uses browserify as a javascript pipeline
License: Other
Since roots-browserify only works with version 3 it would be helpful if there was a more prominent notice in this repository. I fumbled around with this extension and the latest NPM version for a while before noticing the v3 requirement since it looks like it only appears on the repo description. Just a thought.
But also if you guys will be releasing v3 on NPM soon then this will no longer be an issue.
Looking at the docs they have moved .deps
into .pipline
which is controlled by module-deps, with this you can use methods like .get
, .push
, .unshift
, & .splice
receiving the following error when running npm install roots-browserify --save
ERR! registry error parsing json
info retry will retry, error on last attempt: SyntaxError: Unexpected token <
and procedes to install v 0.0.1 of the module, but was that ever a version (2e7f65b) ?
here is the output of ./node_modules/roots-browserify/package.json
{
"name": "roots-browserify",
"version": "0.0.1",
"description": "browserify plugin for roots v3",
"main": "index.js",
"keywords": [
"roots-plugin",
"browserify"
],
"scripts": {
"test": "mocha"
},
"repository": {
"type": "git",
"url": "https://github.com/jenius/roots-browserify.git"
},
"dependencies": {
"browserify": "3.x.x"
},
"devDependencies": {
"mocha": "*",
"should": "*",
"roots": "3.x.x",
"rimraf": "2.x.x"
},
"author": {
"name": "Jeff Escalante",
"email": "[email protected]"
},
"license": "MIT",
"readme": "# roots-browserify [![npm](https://badge.fury.io/js/roots-browserify.png)](http://badge.fury.io/js/roots-browserify) [![tests](https://travis-ci.org/jenius/roots-browserify.png?branch=master)](https://travis-ci.org/jenius/roots-browserify) [![dependencies](https://david-dm.org/jenius/roots-browserify.png)](https://david-dm.org/jenius/roots-browserify)\n\nbrowserify plugin for roots\n\n> **Note:** This project is in early development, and versioning is a little different. [Read this](http://markup.im/#q4_cRZ1Q) for more details.\n\n### Installation\n\nIn your roots project, `npm install roots-browserify --save`\n\n### Usage\n\nIntended for use in the \"after\" hook. Execute the function with an object with `in` and `out` keys pointing to the input and output paths. For example:\n\n```coffee\nbrowserify = require('roots-browserify')\n\nafter: browserify(in: 'js/main.js', out: 'js/dist.js')\n```\n\nThis would parse the `js/main.js` file's require tree and output everything as `js/dist.js`. Since this runs after compile, even if your main file is coffee, it can run on the js version.\n\n### License & Contributing\n\n- Details on the license [can be found here](LICENSE.md)\n- Details on running tests and contributing [can be found here](contributing.md)\n",
"readmeFilename": "README.md",
"bugs": {
"url": "https://github.com/jenius/roots-browserify/issues"
},
"homepage": "https://github.com/jenius/roots-browserify",
"_id": "[email protected]",
"_from": "roots-browserify@"
}
I can PR this if you want...
Would it be within the scope of this extension to do something similar to what js_pipeline
does and provide a js
function, which will produce the code required to display the script in the browser?
Something similar to this perhaps: https://github.com/carrot/roots-js-pipeline/blob/master/lib/index.coffee#L47
If you have some nifty browserify transforms you're into, you should be able to pass them in to this extension and have them used.
I try to use roots-browserify
with jQuery
, but doesn't work!!
browserify is a costly operation, it seems like we are calling the after hook on file change twice.
any thoughts @Jenius ?
Browserify sure moves fast. It's already on v11. Time to see what breaks!
This is my app.coffee, I've tried every change I could think of, but public/js/build.js or any other build.js is not built:
axis = require 'axis'
rupture = require 'rupture'
autoprefixer = require 'autoprefixer-stylus'
css_pipeline = require 'css-pipeline'
browserify = require 'roots-browserify' //replaces: js_pipeline = require 'js-pipeline'
module.exports =
ignores: ['assets/css/.master.styl.swp', '.app.coffee.swp', '**/.*.swp', 'readme.md', '**/layout.*', '**/_*', '.gitignore', 'ship.*conf']
extensions: [
browserify(files: 'assets/js/**', out: 'js/build.js'),
css_pipeline(files: ['assets/css/*.styl', 'assets/css/*.css'])
]
stylus:
use: [axis(), rupture(), autoprefixer()]
sourcemap: true
'coffee-script':
sourcemap: true
I use npms.io a lot and noticed some warnings:
These related to "insecure" include simple updates in package.json here and in roots-utils as displayed on nodesecurity.io
Definitely low priority and maybe it make more sense to handle all projects in Roots ecosystem...
Hello !
In index.coffee, I read :
@b = browserify
entries: @files
extensions: ['.js', '.json', '.coffee']
debug: opts.sourceMap
cache: @cache
packageCache: @pkg_cache
shouldn't it use opts.opts.extensions ?
See you. Mat
Edit : I will add it in my PR !
events.js:72
throw er; // Unhandled 'error' event
^
Error: Cannot find module 'bower_components/jquery/dist/jquery.min.js' from '/Users/sam/Desktop/repos/ss15-goat/webapp/assets/js'
at /Users/sam/Desktop/repos/ss15-goat/webapp/node_modules/roots-browserify/node_modules/browserify/node_modules/browser-resolve/node_modules/resolve/lib/async.js:50:17
at process (/Users/sam/Desktop/repos/ss15-goat/webapp/node_modules/roots-browserify/node_modules/browserify/node_modules/browser-resolve/node_modules/resolve/lib/async.js:119:43)
at /Users/sam/Desktop/repos/ss15-goat/webapp/node_modules/roots-browserify/node_modules/browserify/node_modules/browser-resolve/node_modules/resolve/lib/async.js:128:21
at load (/Users/sam/Desktop/repos/ss15-goat/webapp/node_modules/roots-browserify/node_modules/browserify/node_modules/browser-resolve/node_modules/resolve/lib/async.js:60:43)
at /Users/sam/Desktop/repos/ss15-goat/webapp/node_modules/roots-browserify/node_modules/browserify/node_modules/browser-resolve/node_modules/resolve/lib/async.js:66:22
at /Users/sam/Desktop/repos/ss15-goat/webapp/node_modules/roots-browserify/node_modules/browserify/node_modules/browser-resolve/node_modules/resolve/lib/async.js:21:47
at Object.oncomplete (fs.js:108:15)
just wanted to throw this in the log...
leverage roots-browserify + roots-client-templates as a singlular compiled js file would be awesome
not sure the best API for such a declaration, maybe a flag when defining the browserify extension would work? ๐ญ
I've just switched from js-pipline (great stuff) as a js build tool to this extension. I wanted more flexibility with modules that browserify offers. The only issue I've been having is ~25 second compilation times which are significantly slower than with js-pipeline's 1 - 3 second compilations. I understand there's a bit of work going on behind the scenes with compiling the coffeescript, transforming browserify to use bower modules and the actual compilation browserify does to concat the modules. But I question if this is expected with the two extra transformers? Any insight will be much appreciated ๐
aside from requireing this module, this is my pertinent app.coffee:
browserify(
files: "assets/js/main.coffee"
out: 'js/main.js'
transforms: [
'coffeeify'
'debowerify'
]
)
We came from here: jescalan/roots#674
It's an issue pretty specific and small but it's really annoying.
When compiling the roots project sometimes it stuck forever and never finish to compile.
So, I investigated (with a loved help from the Gitter) and I realised that the problem is when browserify throw any error. Then, the compile never ends and roots doesn't show the error trace. It's like one of the most difficult problems to debug!
So, I understand that the problem is that roots doesn't output the browserify errors.
P.S.: Sorry for misspells and this bad report I'm tired and I don't know how to express myself better.
When using the following app.coffee, babelify is ignored and doesn't transform the es6 code to es5.
axis = require 'axis'
rupture = require 'rupture'
autoprefixer = require 'autoprefixer-stylus'
browserify = require 'roots-browserify'
css_pipeline = require 'css-pipeline'
module.exports =
ignores: ['readme.md', '**/layout.*', '**/_*', '.gitignore', 'ship.*conf']
extensions: [
browserify(
files: "assets/js/main.js"
out: 'js/main.js'
transforms: ['babelify']
)
css_pipeline(files: 'assets/css/*.styl')
]
stylus:
use: [axis(), rupture(), autoprefixer()]
sourcemap: true
jade:
pretty: true
It transforms this
(() => {
console.log('welcome');
})();
to this
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
(() => {
console.log('welcome');
})();
},{}]},{},[1]);
Easier than doing the whole thing manually. https://github.com/lukehorvat/rememberify
running roots watch
in version 3.0.0-rc.6
produces the following error:
events.js:72
throw er; // Unhandled 'error' event
^
Error: Parsing file ...application.coffee: Line 1: Unexpected string
at parseDeps (/Users/kevin/Code/crosscourt-ui/node_modules/roots-browserify/node_modules/browserify/node_modules/module-deps/index.js:249:45)
at done (/Users/kevin/Code/crosscourt-ui/node_modules/roots-browserify/node_modules/browserify/node_modules/module-deps/index.js:229:13)
at applyTransforms (/Users/kevin/Code/crosscourt-ui/node_modules/roots-browserify/node_modules/browserify/node_modules/module-deps/index.js:199:41)
at /Users/kevin/Code/crosscourt-ui/node_modules/roots-browserify/node_modules/browserify/node_modules/module-deps/index.js:172:17
at fs.js:266:14
at /usr/local/lib/node_modules/roots/node_modules/graceful-fs/graceful-fs.js:104:5
at Object.oncomplete (fs.js:107:15)
Just to note, that v 3.0.0-rc.5
works without issue.
From playing around with it, it appears that this error occurs when using roots-browserify
while compiling .coffee
files, here's a snippet of the setup in my app.coffee
:
...
extensions: [
browserify(files: glob.sync("**/assets/js/**/*.coffee"), out: '/js/build.js')
...
and the contents of my application.coffee
file:
$ = require 'jquery'
Backbone = require 'backbone'
Backbone.$ = $
Marionette = require 'backbone.marionette'
Marionette.$ = $
App = new Marionette.Application()
App.on 'initialize:before', (opts) ->
...
App.addRegions
...
App.on 'initialize:after', (opts) ->
if Backbone.history then Backbone.history.start({ pushState: true })
module.exports = App
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.