From a30b77ae03ff81ca4a79d29850c9ca17efe84e8c Mon Sep 17 00:00:00 2001 From: Dana Ivan Date: Wed, 10 May 2017 16:36:43 +0200 Subject: [PATCH 1/2] Revert "Revert "use amd-loader from npm"" --- node_modules/amd-loader/.gitignore | 3 - node_modules/amd-loader/.npmignore | 4 - node_modules/amd-loader/.travis.yml | 6 -- node_modules/amd-loader/LICENSE | 21 ----- node_modules/amd-loader/README.md | 73 ---------------- node_modules/amd-loader/amd-loader.js | 85 ------------------- node_modules/amd-loader/package.json | 24 ------ .../amd-loader/test/node_modules/a.js | 8 -- .../amd-loader/test/node_modules/b.js | 3 - .../amd-loader/test/node_modules/c.txt | 1 - .../amd-loader/test/node_modules/d.js | 3 - .../amd-loader/test/node_modules/e.js | 6 -- node_modules/amd-loader/test/test.js | 34 -------- node_modules/amd-loader/test/test2.js | 4 - 14 files changed, 275 deletions(-) delete mode 100644 node_modules/amd-loader/.gitignore delete mode 100644 node_modules/amd-loader/.npmignore delete mode 100644 node_modules/amd-loader/.travis.yml delete mode 100644 node_modules/amd-loader/LICENSE delete mode 100644 node_modules/amd-loader/README.md delete mode 100644 node_modules/amd-loader/amd-loader.js delete mode 100644 node_modules/amd-loader/package.json delete mode 100644 node_modules/amd-loader/test/node_modules/a.js delete mode 100644 node_modules/amd-loader/test/node_modules/b.js delete mode 100644 node_modules/amd-loader/test/node_modules/c.txt delete mode 100644 node_modules/amd-loader/test/node_modules/d.js delete mode 100644 node_modules/amd-loader/test/node_modules/e.js delete mode 100644 node_modules/amd-loader/test/test.js delete mode 100644 node_modules/amd-loader/test/test2.js diff --git a/node_modules/amd-loader/.gitignore b/node_modules/amd-loader/.gitignore deleted file mode 100644 index 69d39625..00000000 --- a/node_modules/amd-loader/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -.c9revisions/ -amd-loader-*.tgz -package/ diff --git a/node_modules/amd-loader/.npmignore b/node_modules/amd-loader/.npmignore deleted file mode 100644 index a8a239c1..00000000 --- a/node_modules/amd-loader/.npmignore +++ /dev/null @@ -1,4 +0,0 @@ -.git/ -.c9revisions/ -package/ -amd-loader-*.tgz diff --git a/node_modules/amd-loader/.travis.yml b/node_modules/amd-loader/.travis.yml deleted file mode 100644 index 1cf67b79..00000000 --- a/node_modules/amd-loader/.travis.yml +++ /dev/null @@ -1,6 +0,0 @@ -language: node_js -node_js: - - 0.4 - - 0.5 - - 0.6 - - 0.10 \ No newline at end of file diff --git a/node_modules/amd-loader/LICENSE b/node_modules/amd-loader/LICENSE deleted file mode 100644 index 8b70a601..00000000 --- a/node_modules/amd-loader/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License - -Copyright (c) 2010 ajax.org B.V (Fabian Jakobs) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. \ No newline at end of file diff --git a/node_modules/amd-loader/README.md b/node_modules/amd-loader/README.md deleted file mode 100644 index 82d7c060..00000000 --- a/node_modules/amd-loader/README.md +++ /dev/null @@ -1,73 +0,0 @@ -AMD loader for node.js -====================== - -node-amd-loader adds the capability to load unmodified AMD (Asynchronous Module DefinitionAsynchronous Module Definition) from node.js applications. - -Installation ------------- - -`node-amd-loader` can be easily installed using [npm](http://npmjs.org). - - npm install amd-loader - -Before being able to load AMD modules the `amd-loader` module has to be required. - - require("amd-loader"); - -This needs to be done only once. - -Features --------- - -### load modules which use AMD define() ### - -Load modules which are written using AMD [define](http://wiki.commonjs.org/wiki/Modules/AsynchronousDefinition#define.28.29_function) from node.js node. - -amd.js - -```javascript - define(function(require, exports, module) { - exports.B = "B"; - }); -``` - -main.js - -``` - require("amd-loader"); - var amd = require("./amd"); -``` - -### support requireJS asyncronous loading syntax ### - -From within an AMD modules the async require syntax introduced by [requireJS](http://requirejs.org) can be used. - -```javascript - require(["fs"], function(fs) { - fs.readFile(...); - }) -``` - -### support requireJS text plugin ### - -From within an AMD module the requireJS text plugin is supported. - -```javascript - var readme = require("text!./readme.md"); -``` - -Continuous Integration status ------------------------------ - -This project is tested with [Travis CI](http://travis-ci.org) -[![Build Status](https://secure.travis-ci.org/ajaxorg/node-amd-loader.png)](http://travis-ci.org/ajaxorg/node-amd-loader) - -Credits -------- - -[Kris Zip](https://github.com/kriszyp) came up the the initial [idea](https://gist.github.com/650000) how to hijack the node module loading. - -License -------- - -MIT license. See the LICENSE file for details. \ No newline at end of file diff --git a/node_modules/amd-loader/amd-loader.js b/node_modules/amd-loader/amd-loader.js deleted file mode 100644 index 6addeeb8..00000000 --- a/node_modules/amd-loader/amd-loader.js +++ /dev/null @@ -1,85 +0,0 @@ -var fs = require("fs"); -var Module = require("module"); - -var moduleStack = []; -var defaultCompile = module.constructor.prototype._compile; - -module.constructor.prototype._compile = function(content, filename){ - moduleStack.push(this); - try { - return defaultCompile.call(this, content, filename); - } - finally { - moduleStack.pop(); - } -}; - -global.define = function (id, injects, factory) { - var DEFAULT_INJECTS = ["require", "exports", "module"]; - - // infer the module - var currentModule = moduleStack[moduleStack.length-1]; - var mod = currentModule || module.parent || require.main; - - // assign arguments - if (arguments.length === 1) { - factory = id; - injects = DEFAULT_INJECTS; - id = null; - } - else if (arguments.length === 2) { - factory = injects; - injects = id; - id = null; - } - - if (typeof id === "string" && id !== mod.id) { - throw new Error("Can not assign module to a different id than the current file"); - } - - var req = function(module, relativeId, callback) { - if (Array.isArray(relativeId)) { - // async require - return callback.apply(this, relativeId.map(req)) - } - - var chunks = relativeId.split("!"); - var prefix; - if (chunks.length >= 2) { - prefix = chunks[0]; - relativeId = chunks.slice(1).join("!"); - } - - var fileName = Module._resolveFilename(relativeId, module); - if (Array.isArray(fileName)) - fileName = fileName[0]; - - if (prefix && prefix.indexOf("text") !== -1) { - return fs.readFileSync(fileName, "utf8"); - } else - return require(fileName); - }.bind(this, mod); - - id = mod.id; - if (typeof factory !== "function") { - // we can just provide a plain object - return mod.exports = factory; - } - - var returned = factory.apply(mod.exports, injects.map(function (injection) { - switch (injection) { - // check for CommonJS injection variables - case "require": return req; - case "exports": return mod.exports; - case "module": return mod; - default: - // a module dependency - return req(injection); - } - })); - - if (returned) { - // since AMD encapsulates a function/callback, it can allow the factory to return the exports. - mod.exports = returned; - } -}; diff --git a/node_modules/amd-loader/package.json b/node_modules/amd-loader/package.json deleted file mode 100644 index e70e29b5..00000000 --- a/node_modules/amd-loader/package.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "name" : "amd-loader", - "version" : "0.0.5", - "description" : "Add the capability to load AMD (Asynchronous Module Definition) modules to node.js", - "author": "ajax.org B.V. ", - "contributors": [ - { "name": "Fabian Jakobs", "email": "fabian@ajax.org" } - ], - "repository" : { - "type" : "git", - "url" : "http://github.com/ajaxorg/node-amd-loader.git" - }, - "main": "./amd-loader.js", - "scripts" : { - "test" : "node test/test.js && node test/test2.js" - }, - "engines" : { - "node" : ">= 0.4.11" - }, - "licenses" : [{ - "type" : "MIT", - "url" : "http://github.com/ajaxorg/node-amd-loader/raw/master/LICENSE" - }] -} \ No newline at end of file diff --git a/node_modules/amd-loader/test/node_modules/a.js b/node_modules/amd-loader/test/node_modules/a.js deleted file mode 100644 index f199de8d..00000000 --- a/node_modules/amd-loader/test/node_modules/a.js +++ /dev/null @@ -1,8 +0,0 @@ -define(function(require, exports, module) { - - exports.B = require("./b").B; - exports.D = require("d").D; - exports.A = "A"; - - exports.text = require("text!./c.txt"); -}); \ No newline at end of file diff --git a/node_modules/amd-loader/test/node_modules/b.js b/node_modules/amd-loader/test/node_modules/b.js deleted file mode 100644 index e2a898ec..00000000 --- a/node_modules/amd-loader/test/node_modules/b.js +++ /dev/null @@ -1,3 +0,0 @@ -define(function(require, exports, module) { - exports.B = "B"; -}); \ No newline at end of file diff --git a/node_modules/amd-loader/test/node_modules/c.txt b/node_modules/amd-loader/test/node_modules/c.txt deleted file mode 100644 index 95d09f2b..00000000 --- a/node_modules/amd-loader/test/node_modules/c.txt +++ /dev/null @@ -1 +0,0 @@ -hello world \ No newline at end of file diff --git a/node_modules/amd-loader/test/node_modules/d.js b/node_modules/amd-loader/test/node_modules/d.js deleted file mode 100644 index 5bc470eb..00000000 --- a/node_modules/amd-loader/test/node_modules/d.js +++ /dev/null @@ -1,3 +0,0 @@ -define(function(require, exports, module) { - exports.D = "D"; -}); \ No newline at end of file diff --git a/node_modules/amd-loader/test/node_modules/e.js b/node_modules/amd-loader/test/node_modules/e.js deleted file mode 100644 index 2fb486ac..00000000 --- a/node_modules/amd-loader/test/node_modules/e.js +++ /dev/null @@ -1,6 +0,0 @@ -require("../.."); - -define(function(require, exports, module) { - exports.A = require("./a").A; - exports.E = "E"; -}); \ No newline at end of file diff --git a/node_modules/amd-loader/test/test.js b/node_modules/amd-loader/test/test.js deleted file mode 100644 index 79d578bf..00000000 --- a/node_modules/amd-loader/test/test.js +++ /dev/null @@ -1,34 +0,0 @@ -require(".."); -var assert = require("assert"); - -console.log("Running amd-loader tests"); -console.log("========================\n"); - -console.log("resolve relative id"); -var a = require("./node_modules/a"); -var b = require("./node_modules/b"); - -assert.equal(a.A, "A"); -assert.equal(a.B, "B"); -assert.equal(a.text, "hello world"); -assert.equal(a.D, "D"); - -assert.equal(b.B, "B"); - -console.log("resolve fully qualified id"); -var a = require("a"); -var b = require("b"); - -assert.equal(a.A, "A"); -assert.equal(a.B, "B"); -assert.equal(a.text, "hello world"); -assert.equal(b.B, "B"); - -console.log("resolve from node_modules"); -var d = require("d"); - -assert.equal(d.D, "D"); - -// TODO -// node_modules + package -// async require diff --git a/node_modules/amd-loader/test/test2.js b/node_modules/amd-loader/test/test2.js deleted file mode 100644 index 92674deb..00000000 --- a/node_modules/amd-loader/test/test2.js +++ /dev/null @@ -1,4 +0,0 @@ -// this tests the case where the AMD-loader is not loaded in the main module and -// the module using amd-loader uses define itself -console.log("require file with amd-loader and define") -require("e"); \ No newline at end of file From 4956a83fbd2dcbcc6dff640b4e965e718d56bb1b Mon Sep 17 00:00:00 2001 From: Fabian Jakobs Date: Mon, 29 May 2017 13:57:51 +0000 Subject: [PATCH 2/2] make sure build tools also have access to amd-loader --- server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server.js b/server.js index 9cf17cb1..73aa6ceb 100755 --- a/server.js +++ b/server.js @@ -4,7 +4,7 @@ require("amd-loader"); try { require("heapdump"); -} catch(e) {} +} catch (e) {} var path = require("path"); var architect = require("architect");