moog-require
Advanced tools
Comparing version 1.2.0 to 1.3.0
15
index.js
@@ -44,2 +44,7 @@ var async = require('async'); | ||
var superDefine = self.define; | ||
if (options.nestedModuleSubdirs) { | ||
self._globCache = {}; | ||
} | ||
self.define = function(type, definition, extending) { | ||
@@ -60,3 +65,11 @@ | ||
if (options.nestedModuleSubdirs) { | ||
var matches = glob.sync(self.options.localModules + '/**/' + type + '/index.js'); | ||
if (!self._indexes) { | ||
// Fetching a list of index.js files on the first call and then searching it each time for | ||
// one that refers to the right type name shaves as much as 60 seconds off the startup | ||
// time in a large project, compared to using the glob cache feature | ||
self._indexes = glob.sync(self.options.localModules + '/**/index.js'); | ||
} | ||
var matches = self._indexes.filter(function(index) { | ||
return index.endsWith('/' + type + '/index.js'); | ||
}); | ||
if (matches.length > 1) { | ||
@@ -63,0 +76,0 @@ throw new Error('The module ' + type + ' appears in multiple locations:\n' + matches.join('\n')); |
{ | ||
"name": "moog-require", | ||
"version": "1.2.0", | ||
"description": "moog-require extends moog with support for type definitions in local files and npm modules.", | ||
"main": "index.js", | ||
"author": { | ||
"name": "Apostrophe Technologies" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/apostrophecms/moog-require/issues" | ||
}, | ||
"bundleDependencies": false, | ||
"dependencies": { | ||
@@ -15,12 +18,8 @@ "async": "^1.0.0", | ||
}, | ||
"deprecated": false, | ||
"description": "moog-require extends moog with support for type definitions in local files and npm modules.", | ||
"devDependencies": { | ||
"mocha": "^5.0.0" | ||
}, | ||
"scripts": { | ||
"test": "mocha test/test.js" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/punkave/moog-require" | ||
}, | ||
"homepage": "https://github.com/apostrophecms/moog-require#readme", | ||
"keywords": [ | ||
@@ -33,4 +32,13 @@ "apostrophe", | ||
], | ||
"author": "P'unk Avenue", | ||
"license": "MIT" | ||
"license": "MIT", | ||
"main": "index.js", | ||
"name": "moog-require", | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/apostrophecms/moog-require.git" | ||
}, | ||
"scripts": { | ||
"test": "mocha test/test.js" | ||
}, | ||
"version": "1.3.0" | ||
} |
@@ -351,9 +351,11 @@ [![Build Status](https://travis-ci.org/punkave/moog-require.svg?branch=master)](https://travis-ci.org/punkave/moog-require) | ||
**The 2.x series is deprecated for new work, as its functionality was folded into Apostrophe 3.x. See below for 1.x release notes relevant to maintenance of Apostrophe 2.x.** | ||
1.3.0: achieved an approximately 100x performance improvement when `nestedModuleSubdirs` is in use by fetching | ||
a list of index.js files on the first `define` call and then searching that prefetched list each | ||
time. This solution is much faster than the glob module cache. | ||
1.2.0: use `originalToMy` to handle moog class names with npm namespaces in them. | ||
1.1.1: use `importFresh` to avoid bugs when two instances of `moog-require` are | ||
loading the same module definitions. Previously if modules created by | ||
the two instances later modified sub-properties of `options`, they would | ||
inadvertently share values. This fix is critical for both `apostrophe-monitor` | ||
and `apostrophe-multisite`. | ||
1.1.1: use `importFresh` to avoid bugs when two instances of `moog-require` are loading the same module definitions. Previously if modules created by the two instances later modified sub-properties of `options`, they would inadvertently share values. This fix is critical for both `apostrophe-monitor` and `apostrophe-multisite`. | ||
@@ -360,0 +362,0 @@ 1.1.0: support for the `nestedModuleSubdirs` option. |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
52986
1024
0
0
377