From 56d69ab68ab18cc920e8682a993b4e05c387dd06 Mon Sep 17 00:00:00 2001 From: javi Date: Wed, 17 Dec 2014 14:35:42 +0100 Subject: [PATCH] browserify fixes --- Makefile | 7 ++++++- lib/carto/parser.js | 2 +- lib/carto/renderer.js | 2 +- lib/carto/renderer_js.js | 2 +- lib/carto/tree/call.js | 2 +- lib/carto/tree/definition.js | 2 +- lib/carto/tree/dimension.js | 2 +- lib/carto/tree/filterset.js | 2 +- lib/carto/tree/reference.js | 2 +- lib/carto/tree/style.js | 2 +- package.json | 9 +++++---- 11 files changed, 20 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index 0d93ed4..81cb453 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,7 @@ # expresso = ./node_modules/.bin/mocha +UGLIFYJS=./node_modules/.bin/uglifyjs BROWSERIFY = ./node_modules/.bin/browserify lint: @@ -22,6 +23,10 @@ dist: mkdir -p dist dist/carto.uncompressed.js: dist $(shell $(BROWSERIFY) --list lib/carto/index.js) - $(BROWSERIFY) --debug lib/carto/index.js --standalone carto > $@ + $(BROWSERIFY) lib/carto/index.js --exclude node_modules/underscore/underscore.js --standalone carto > $@ + +dist/carto.js: dist/carto.uncompressed.js $(shell $(BROWSERIFY) --list lib/carto/index.js) + $(UGLIFYJS) dist/carto.uncompressed.js > $@ + .PHONY: test diff --git a/lib/carto/parser.js b/lib/carto/parser.js index c023a3c..158e04a 100644 --- a/lib/carto/parser.js +++ b/lib/carto/parser.js @@ -1,6 +1,6 @@ var carto = exports, tree = require('./tree'), - _ = require('underscore'); + _ = global._ || require('underscore'); // Token matching is done with the `$` function, which either takes // a terminal string or regexp, or a non-terminal function to call. diff --git a/lib/carto/renderer.js b/lib/carto/renderer.js index 31c5678..cdc48b9 100644 --- a/lib/carto/renderer.js +++ b/lib/carto/renderer.js @@ -1,4 +1,4 @@ -var _ = require('underscore'); +var _ = global._ || require('underscore'); var carto = require('./index'); carto.Renderer = function Renderer(env, options) { diff --git a/lib/carto/renderer_js.js b/lib/carto/renderer_js.js index 498e9e2..716ed29 100644 --- a/lib/carto/renderer_js.js +++ b/lib/carto/renderer_js.js @@ -1,6 +1,6 @@ (function(carto) { var tree = require('./tree'); -var _ = require('underscore'); +var _ = global._ || require('underscore'); function CartoCSS(style, options) { diff --git a/lib/carto/tree/call.js b/lib/carto/tree/call.js index 50b0fbd..b618a96 100644 --- a/lib/carto/tree/call.js +++ b/lib/carto/tree/call.js @@ -1,5 +1,5 @@ (function(tree) { -var _ = require('underscore'); +var _ = global._ || require('underscore'); tree.Call = function Call(name, args, index) { this.name = name; this.args = args; diff --git a/lib/carto/tree/definition.js b/lib/carto/tree/definition.js index 8e4ee0b..2ba7fc7 100644 --- a/lib/carto/tree/definition.js +++ b/lib/carto/tree/definition.js @@ -1,6 +1,6 @@ (function(tree) { var assert = require('assert'), - _ = require('underscore'); + _ = global._ || require('underscore'); // A definition is the combination of a selector and rules, like // #foo { diff --git a/lib/carto/tree/dimension.js b/lib/carto/tree/dimension.js index 584e946..1277664 100644 --- a/lib/carto/tree/dimension.js +++ b/lib/carto/tree/dimension.js @@ -1,5 +1,5 @@ (function(tree) { -var _ = require('underscore'); +var _ = global._ || require('underscore'); // // A number with a unit // diff --git a/lib/carto/tree/filterset.js b/lib/carto/tree/filterset.js index 97caeac..882cf7d 100644 --- a/lib/carto/tree/filterset.js +++ b/lib/carto/tree/filterset.js @@ -1,5 +1,5 @@ var tree = require('../tree'); -var _ = require('underscore'); +var _ = global._ || require('underscore'); tree.Filterset = function Filterset() { this.filters = {}; diff --git a/lib/carto/tree/reference.js b/lib/carto/tree/reference.js index 64fe76f..9519d0a 100644 --- a/lib/carto/tree/reference.js +++ b/lib/carto/tree/reference.js @@ -4,7 +4,7 @@ // combinations. (function(tree) { -var _ = require('underscore'), +var _ = global._ || require('underscore'), ref = {}; ref.setData = function(data) { diff --git a/lib/carto/tree/style.js b/lib/carto/tree/style.js index 3e96593..9c5a827 100644 --- a/lib/carto/tree/style.js +++ b/lib/carto/tree/style.js @@ -1,5 +1,5 @@ (function(tree) { -var _ = require('underscore'); +var _ = global._ || require('underscore'); // Given a style's name, attachment, definitions, and an environment object, // return a stringified style for Mapnik diff --git a/package.json b/package.json index f631be0..bcc4c97 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ }, "author": { "name": "CartoDB", - "url": "http://cartodb.com/", + "url": "http://cartodb.com/" }, "keywords": [ "maps", @@ -19,9 +19,9 @@ "contributors": [ "Tom MacWright ", "Konstantin Käfer", - "Alexis Sellier " + "Alexis Sellier ", "Raul Ochoa ", - "Javi Santana ", + "Javi Santana " ], "licenses": [ { @@ -47,7 +47,8 @@ "sax": "0.1.x", "istanbul": "~0.2.14", "coveralls": "~2.10.1", - "browserify": "~7.0.0" + "browserify": "~7.0.0", + "uglify-js": "1.3.3" }, "scripts": { "pretest": "npm install",