From 41b56fa573d1ef0d1718777a8a21ae1b57ebcd83 Mon Sep 17 00:00:00 2001 From: isaacs Date: Sat, 11 Jul 2015 10:27:56 -0700 Subject: [PATCH] Remove all AMD/Browser/minified bits If users want to build things, they should use Webpack, or Browserify, or one of the many other options. There's no way to please everyone, so it seems the best approach is to just be like all the other modules that do not do this stuff. Separation of concerns. Fix #120 --- Makefile | 24 ------------------------ foot.js.txt | 6 ------ head.js.txt | 2 -- package.json | 7 ++----- semver.js | 8 +------- test/amd.js | 15 --------------- test/no-module.js | 19 ------------------- 7 files changed, 3 insertions(+), 78 deletions(-) delete mode 100644 Makefile delete mode 100644 foot.js.txt delete mode 100644 head.js.txt delete mode 100644 test/amd.js delete mode 100644 test/no-module.js diff --git a/Makefile b/Makefile deleted file mode 100644 index 71af0e97..00000000 --- a/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -files = semver.browser.js \ - semver.min.js \ - semver.browser.js.gz \ - semver.min.js.gz - -all: $(files) - -clean: - rm -f $(files) - -semver.browser.js: head.js.txt semver.js foot.js.txt - ( cat head.js.txt; \ - cat semver.js | \ - egrep -v '^ *\/\* nomin \*\/' | \ - perl -pi -e 's/debug\([^\)]+\)//g'; \ - cat foot.js.txt ) > semver.browser.js - -semver.min.js: semver.browser.js - uglifyjs -m semver.min.js - -%.gz: % - gzip --stdout -9 <$< >$@ - -.PHONY: all clean diff --git a/foot.js.txt b/foot.js.txt deleted file mode 100644 index 8f83c20f..00000000 --- a/foot.js.txt +++ /dev/null @@ -1,6 +0,0 @@ - -})( - typeof exports === 'object' ? exports : - typeof define === 'function' && define.amd ? {} : - semver = {} -); diff --git a/head.js.txt b/head.js.txt deleted file mode 100644 index 65368651..00000000 --- a/head.js.txt +++ /dev/null @@ -1,2 +0,0 @@ -;(function(exports) { - diff --git a/package.json b/package.json index fff26bd8..43de64b4 100644 --- a/package.json +++ b/package.json @@ -3,18 +3,15 @@ "version": "4.3.6", "description": "The semantic version parser used by npm.", "main": "semver.js", - "browser": "semver.browser.js", - "min": "semver.min.js", "scripts": { - "test": "tap test/*.js", - "prepublish": "make" + "test": "tap test/*.js" }, "devDependencies": { "tap": "^1.2.0", "uglify-js": "~2.3.6" }, "license": "ISC", - "repository": "git://github.com/npm/node-semver.git", + "repository": "https://github.com/npm/node-semver", "bin": { "semver": "./bin/semver" } diff --git a/semver.js b/semver.js index cafcc006..d4a8dca6 100644 --- a/semver.js +++ b/semver.js @@ -1,6 +1,4 @@ -// export the class if we are in a Node-like system. -if (typeof module === 'object' && module.exports === exports) - exports = module.exports = SemVer; +exports = module.exports = SemVer; // The debug function is excluded entirely from the minified version. /* nomin */ var debug; @@ -1199,7 +1197,3 @@ function outside(version, range, hilo, loose) { } return true; } - -// Use the define() function if we're in AMD land -if (typeof define === 'function' && define.amd) - define(exports); diff --git a/test/amd.js b/test/amd.js deleted file mode 100644 index a6041341..00000000 --- a/test/amd.js +++ /dev/null @@ -1,15 +0,0 @@ -var tap = require('tap'); -var test = tap.test; - -test('amd', function(t) { - global.define = define; - define.amd = true; - var defined = null; - function define(stuff) { - defined = stuff; - } - var fromRequire = require('../'); - t.ok(defined, 'amd function called'); - t.equal(fromRequire, defined, 'amd stuff same as require stuff'); - t.end(); -}); diff --git a/test/no-module.js b/test/no-module.js deleted file mode 100644 index 8b50873f..00000000 --- a/test/no-module.js +++ /dev/null @@ -1,19 +0,0 @@ -var tap = require('tap'); -var test = tap.test; - -test('no module system', function(t) { - var fs = require('fs'); - var vm = require('vm'); - var head = fs.readFileSync(require.resolve('../head.js.txt'), 'utf8'); - var src = fs.readFileSync(require.resolve('../'), 'utf8'); - var foot = fs.readFileSync(require.resolve('../foot.js.txt'), 'utf8'); - vm.runInThisContext(head + src + foot, 'semver.js'); - - // just some basic poking to see if it did some stuff - t.type(global.semver, 'object'); - t.type(global.semver.SemVer, 'function'); - t.type(global.semver.Range, 'function'); - t.ok(global.semver.satisfies('1.2.3', '1.2')); - t.end(); -}); -