Skip to content

Commit

Permalink
proposal for #3: build different patterns independently
Browse files Browse the repository at this point in the history
  • Loading branch information
jneen committed Jan 5, 2012
1 parent f71b4de commit 839eb41
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 6 deletions.
31 changes: 28 additions & 3 deletions Makefile
@@ -1,5 +1,7 @@
SRC = src/p.js
UGLY = build/p.min.js
SRC_DIR = src
BUILD_DIR = build
SRC = $(SRC_DIR)/p.js
UGLY = $(BUILD_DIR)/p.min.js
UGLIFYJS ?= uglifyjs
CLEAN += $(UGLY)

Expand All @@ -13,6 +15,29 @@ $(UGLY): $(SRC)
$(PRETTY): $(SRC)
$(UGLIFYJS) -b $(SRC) > $(UGLY)

# special builds
COMMONJS = $(BUILD_DIR)/p.commonjs.js
COMMONJS_POST = src/p.commonjs_post.js
CLEAN += $(COMMONJS)
$(COMMONJS): $(SRC) $(COMMONJS_POST)
cat $(SRC) $(COMMONJS_POST) > $(COMMONJS)

AMD = $(BUILD_DIR)/p.amd.js
AMD_MIN = $(BUILD_DIR)/p.amd.min.js
CLEAN += $(AMD) $(AMD_MIN)
AMD_POST = src/p.amd_post.js
$(AMD): $(SRC) $(AMD_POST)
cat $(SRC) $(AMD_POST) > $(AMD)

$(AMD_MIN): $(AMD)
$(UGLIFYJS) $(AMD) > $(AMD_MIN)

.PHONY: commonjs
commonjs: $(COMMONJS)

.PHONY: amd
amd: $(AMD) $(AMD_MIN)

.PHONY: report
report: $(UGLY)
wc -c $(UGLY)
Expand All @@ -21,7 +46,7 @@ report: $(UGLY)
MOCHA ?= mocha
TESTS = ./test/*.test.js
.PHONY: test
test: $(UGLY)
test: $(COMMONJS)
$(MOCHA) $(TESTS)

# -*- packaging -*- #
Expand Down
2 changes: 1 addition & 1 deletion index.js
@@ -1,2 +1,2 @@
exports.P = require('./src/p').P;
exports.P = require('./build/p.commonjs').P;
exports.version = JSON.parse(require('fs').readFileSync(__dirname + '/package.json')).version;
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -12,6 +12,7 @@
"mocha": "0.8.1"
},
"scripts": {
"install": "make commonjs",
"test": "make test"
}
}
1 change: 1 addition & 0 deletions src/amd_post.js
@@ -0,0 +1 @@
define({P: P});
1 change: 1 addition & 0 deletions src/p.amd_post.js
@@ -0,0 +1 @@
define(P);
1 change: 1 addition & 0 deletions src/p.commonjs_post.js
@@ -0,0 +1 @@
exports.P = P;
2 changes: 0 additions & 2 deletions src/p.js
Expand Up @@ -44,5 +44,3 @@ var P = (function(slice, prototype, hasOwnProperty, undefined) {

return P;
})([].slice, 'prototype', ({}).hasOwnProperty);

if (typeof exports !== 'undefined') exports.P = P

0 comments on commit 839eb41

Please sign in to comment.