summaryrefslogtreecommitdiff
path: root/lib/module.js
AgeCommit message (Collapse)Author
2017-03-10lib: simplify Module._resolveLookupPathsBrian White
This commit consists of two changes: * Avoids returning request/id *just* for the debug() output * Returns `null` instead of an empty array for the list of paths PR-URL: https://github.com/nodejs/node/pull/10789 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2017-03-10module: avoid JSON.stringify() for cache keyBrian White
By avoiding JSON.stringify() and simply joining the strings with a delimiter that does not appear in paths, we can improve cached require() performance by at least 50%. Additionally, this commit removes the last source of permanent function deoptimization (const) for _findPath(). PR-URL: https://github.com/nodejs/node/pull/10789 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2017-03-10lib: improve method of function callingBrian White
Using a more "direct" method of function calling yields better performance. PR-URL: https://github.com/nodejs/node/pull/10789 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2017-03-10module: avoid hasOwnProperty()Brian White
hasOwnProperty() is known to be slow, do a direct lookup on a "clean" object instead. PR-URL: https://github.com/nodejs/node/pull/10789 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2017-03-10module: use "clean" objectsBrian White
PR-URL: https://github.com/nodejs/node/pull/10789 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2017-03-10lib: remove sources of permanent deoptsBrian White
PR-URL: https://github.com/nodejs/node/pull/10789 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2017-03-10meta: restore original copyright headerJames M Snell
A prior io.js era commit inappropriately removed the original copyright statements from the source. This restores those in any files still remaining from that edit. Ref: https://github.com/nodejs/TSC/issues/174 Ref: https://github.com/nodejs/node/pull/10599 PR-URL: https://github.com/nodejs/node/pull/10155 Note: This PR was required, reviewed-by and approved by the Node.js Foundation Legal Committee and the TSC. There is no `Approved-By:` meta data.
2017-01-30lib: add static identifier codes for all deprecationsJames M Snell
Assigns a static identifier code to all runtime and documentation only deprecations. The identifier code is included in the emitted DeprecationWarning. Also adds a deprecations.md to the API docs to provide a central location where deprecation codes can be referenced and explained. PR-URL: https://github.com/nodejs/node/pull/10116 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Michal Zasso <targos@protonmail.com> Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
2016-11-16fs: export `realpathCacheKey` from `internal/fs`Anna Henningsen
Move the internally defined symbol `fs.realpathCacheKey` to the internal fs module, where it’s more appropriate. The symbol was recently added in c084287a608ef, but since `internal/fs` is only available in the v7.x branch, this needs to be a separate follow-up change. PR-URL: https://github.com/nodejs/node/pull/8862 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2016-11-15module: check -e flag in debug break setupKelvin Jin
When both --debug-brk and --eval are set, and a filename is specified, its full path is not set correctly, causing an error for relative filenames with './' omitted. For example, 'node --debug-brk -e 0 hello.js' throws an error. Since the script referenced by the filename is never run anyway, this change skips resolving its full path if both --debug-brk and --eval are set. PR-URL: https://github.com/nodejs/node/pull/8876 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com>
2016-10-24module: skip directories known not to existBen Noordhuis
There is no point in trying to search for files in a directory that we know does not exist, so stop doing that. Reduces the total number of stat(2) calls and the number of stat(2) misses on a medium-sized application by about 21% and 29% respectively. Reduces the total number of package.json open(2) calls and the number of open(2) misses by about 21% and 93% (!) respectively. Before: % time seconds usecs/call calls errors syscall ------ ----------- ----------- --------- --------- ---------------- 50.93 0.178419 38 4702 lstat 29.08 0.101875 36 2800 2010 stat 11.36 0.039796 43 932 215 open 5.39 0.018897 34 550 fstat 3.24 0.011337 34 336 pread ------ ----------- ----------- --------- --------- ---------------- 100.00 0.350324 9320 2225 total After: % time seconds usecs/call calls errors syscall ------ ----------- ----------- --------- --------- ---------------- 55.49 0.176638 38 4702 lstat 24.76 0.078826 35 2225 1435 stat 10.19 0.032434 44 733 16 open 6.19 0.019719 36 550 fstat 3.37 0.010723 32 336 pread ------ ----------- ----------- --------- --------- ---------------- 100.00 0.318340 8546 1451 total PR-URL: https://github.com/nodejs/node/pull/9196 Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2016-10-07module: Remove deprecated function requireRepl.Adri Van Houdt
Refs: https://github.com/nodejs/node/issues/4642 PR-URL: https://github.com/nodejs/node/pull/8575 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2016-10-03module: fix comment from "read-only" to "shallow"Bryan English
The comment here was misleading, implying that the property was being copied as a read-only, when in fact it's just a shallow copy. This serves the purpose of providing the array for introspection, but it isn't read-only. PR-URL: https://github.com/nodejs/node/pull/8887 Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
2016-09-30fs,module: add module-loader-only realpath cacheAnna Henningsen
Reintroduce a realpath cache with the same mechanisms which existed before b488b19eaf2b2e7a3ca5eccd2445e245847a5f76 (`fs: optimize realpath using uv_fs_realpath()`), but only for the synchronous version and with the cache being passed as a hidden option to make sure it is only used internally. The cache is hidden from userland applications because it has been decided that fully reintroducing as part of the public API might stand in the way of future optimizations. PR-URL: https://github.com/nodejs/node/pull/8100 Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2016-09-02lib: use emitWarning instead of printDeprecationMessageJames M Snell
The process.emitWarning() API should be used for printing deprecation warning messages rather than directly using the internal/util#printDeprecationMessage PR-URL: https://github.com/nodejs/node/pull/8166 Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com>
2016-08-09module: fix node_modules search path in edge casehefangshi
The `p < nmLen` condition will fail when a module's name is end with `node_modules` like `foo_node_modules`. The old logic will miss the `foo_node_modules/node_modules` in node_modules paths. TL;TR, a module named like `foo_node_modules` can't require any module in the node_modules folder. Fixes: https://github.com/nodejs/node/issues/6679 PR-URL: https://github.com/nodejs/node/pull/6670 Reviewed-By: Evan Lucas <evanlucas@me.com>
2016-07-12lib,benchmark,test: implement consistent bracesRich Trott
This change is in preparation for lint-enforced brace style. PR-URL: https://github.com/nodejs/node/pull/7630 Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: Michaël Zasso <mic.besace@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: Rod Vagg <rod@vagg.org>
2016-05-13src,module: add --preserve-symlinks command line flagJames M Snell
Add the `--preserve-symlinks` flag. This makes the changes added in #5950 conditional. By default the old behavior is used. With the flag set, symlinks are preserved, switching to the new behavior. This should be considered to be a temporary solution until we figure out how to solve the symlinked peer dependency problem in a more general way that does not break everything else. Additional test cases are included. PR-URL: https://github.com/nodejs/node/pull/6537 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-05-07src,lib: minor --debug-brk cleanupAli Ijaz Sheikh
Minor cleanup of how --debug-brk works: * We no longer need to use command line flags to expose the debug object. * Do not depend on the existence of global.v8debug as a mechanism to determine if --debug-brk was specified. * We no longer need to set a dummy listener with --debug-brk. PR-URL: https://github.com/nodejs/node/pull/6599 Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: cjihrig - Colin Ihrig <cjihrig@gmail.com>
2016-04-25module: preserve symlinks when requiringAlex Lamar
Currently, required modules use the real location of the package/file as their __filename and __dirname, instead of the symlinked path if it exists. This behaviour is undocumented (it even goes against documentation in certain scenarios), creating hard-to-debug problems for developers who wish to leverage filesystem abstractions to lay out their application. This patch resolves all required modules to their canonical path while still preserving any symlinks within the path, instead of resolving to their canonical realpath. The one special case observed is when the main module is loaded -- in this case, the realpath does need to be used in order for the main module to load properly. PR-URL: https://github.com/nodejs/node/pull/5950 Reviewed-By: James M Snell <jasnell@gmail.com>
2016-04-20module: fix resolution of filename with trailing slashMichaël Zasso
A recent optimization of module loading performance [1] forgot to check that extensions were set in a certain code path. [1] https://github.com/nodejs/node/pull/5172/commits/ae18bbef48d87d9c641df85369f62cfd5ed8c250 Fixes: https://github.com/nodejs/node/issues/6214 PR-URL: https://github.com/nodejs/node/pull/6215 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Brian White <mscdex@mscdex.net>
2016-04-15fs: optimize realpath using uv_fs_realpath()Yuval Brik
Remove realpath() and realpathSync() cache. Use the native uv_fs_realpath() which is faster then the JS implementation by a few orders of magnitude. PR-URL: https://github.com/nodejs/node/pull/3594 Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
2016-04-14lib: improve module loading performanceBrian White
This commit improves module loading performance by at least ~25-35% in the module-loader benchmarks. Some optimization strategies include: * Try-finally/try-catch isolation * Replacing regular expressions with manual parsing * Avoiding unnecessary string and array creation * Avoiding constant recompilation of anonymous functions and function definitions within functions PR-URL: https://github.com/nodejs/node/pull/5172 Reviewed-By: James M Snell <jasnell@gmail.com>
2016-03-29module: prioritize current dir for local lookupsPhillip Johnsen
This fixes a bug where a 3rd party module found in node_modules, would be preferred over a ./local module with the same name. Fixes: https://github.com/nodejs/node/issues/5684 PR-URL: https://github.com/nodejs/node/pull/5689 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2016-01-31module: refactor redeclared variableRich Trott
`homedir` was declared with `var` twice in the same scope in `lib/module.js`. This change makes it a single declaration. PR-URL: https://github.com/nodejs/node/pull/4962 Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: Minwoo Jung <jmwsoft@gmail.com> Reviewed-By: Roman Klauke <romaaan.git@gmail.com>
2016-01-26src: attach error to stack on displayErrorscjihrig
The vm module's displayErrors option attaches error arrow messages as a hidden property. Later, core JavaScript code can optionally decorate the error stack with the arrow message. However, when user code catches an error, it has no way to access the arrow message. This commit changes the behavior of displayErrors to mean "decorate the error stack if an error occurs." Fixes: https://github.com/nodejs/node/issues/4835 PR-URL: https://github.com/nodejs/node/pull/4874 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-01-15module: revert "optimize js and json file i/o"Rich Trott
This reverts commit 7c603280024de60329d5da283fb8433420bc6716. It is causing CI failures on Windows. Ref: https://github.com/nodejs/node/pull/4575 PR-URL: https://github.com/nodejs/node/pull/4679 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-01-12module: optimize js and json file i/oBen Noordhuis
Use internalModuleReadFile() to read the file from disk to avoid the fs.fstatSync() call that fs.readFileSync() makes. It does so to know the file size in advance so it doesn't have to allocate O(n) buffers when reading the file from disk. internalModuleReadFile() is plenty efficient though, even more so because we want a string and not a buffer. This way we also don't allocate a buffer that immediately gets thrown away again. This commit reduces the number of fstat() system calls in a benchmark application[0] from 549 to 29, all made by the application itself. [0] https://github.com/strongloop/loopback-sample-app PR-URL: https://github.com/nodejs/node/pull/4575 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2016-01-12module: avoid ArgumentsAdaptorTrampoline frameBen Noordhuis
Avoid an unneeded ArgumentsAdaptorTrampoline stack frame by passing the the right number of arguments to Module._load() in Module.require(). Shortens the following stack trace with one frame: LazyCompile:~Module.load module.js:345 LazyCompile:Module._load module.js:282 Builtin:ArgumentsAdaptorTrampoline LazyCompile:*Module.require module.js:361 LazyCompile:*require internal/module.js:11 PR-URL: https://github.com/nodejs/node/pull/4575 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2016-01-12module: cache stat() results more aggressivelyBen Noordhuis
Reduce the number of stat() system calls that require() makes by caching the results more aggressively. To avoid unbounded growth without implementing a LRU cache, scope the cache to the lifetime of the first call to require(). Recursive calls (i.e. require() calls in the included code) transparently profit from the cache. The benchmarked application is the loopback-sample-app[0] and it sees the number of stat calls at start-up go down by 40%, from 4736 to 2810. [0] https://github.com/strongloop/loopback-sample-app PR-URL: https://github.com/nodejs/node/pull/4575 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2016-01-11module: move unnecessary work for early returnAndres Suarez
The exts and trailingSlash variables are only used if the path isn't cached. This commit moves them further down in the code, and changes from var to const. PR-URL: https://github.com/nodejs/node/pull/3579 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
2015-12-19module: always decorate thrown errorsBrian White
This provides more information when encountering a syntax or similar error when executing a file with require(). Fixes: https://github.com/nodejs/node/issues/4286 PR-URL: https://github.com/nodejs/node/pull/4287 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2015-12-16module,src: do not wrap modules with -1 lineOffsetcjihrig
In b799a74709af69daf13901390df9428c4c38adfc and dfee4e3712ac4673b5fc472a8f77ac65bdc65f87 the module wrapping mechanism was changed for better error reporting. However, the changes causes issues with debuggers and profilers. This commit reverts the wrapping changes. Fixes: https://github.com/nodejs/node/issues/4297 PR-URL: https://github.com/nodejs/node/pull/4298 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
2015-11-30module,repl: remove repl require() hackBen Noordhuis
Remove a hack that was introduced in commit bb6d468d from November 2010. This is groundwork for a follow-up commit that makes it possible to use internal modules in lib/repl.js. PR-URL: https://github.com/nodejs/node/pull/4026 Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2015-11-20module: fix column offsets in errorsTristian Flanagan
Because Node modules are wrapped, errors on the first line of a file leak the wrapper to the user and report the wrong column number. This commit adds a line break to the module wrapper so that the first line is treated the same as all other lines. To compensate for the additional line, a line offset of -1 is also applied to errors. Fixes: https://github.com/nodejs/node/issues/2860 PR-URL: https://github.com/nodejs/node/pull/2867 Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2015-11-16module: cache regular expressionsEvan Lucas
None of these regular expressions will change, so there is no need to generate them every time in hot code paths. Provides a small performance improvement in module loading. (5-10%) PR-URL: https://github.com/nodejs/node/pull/3869 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2015-11-05module: remove unnecessary JSON.stringifyAndres Suarez
`debuglog` uses `%j` as a placeholder for replacement with `JSON.stringify`. So that `JSON.stringify` is only called when the appropriate debug flag is on. The other `%s` changes are for style consistency. PR-URL: https://github.com/nodejs/node/pull/3578 Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2015-10-06module: remove unnecessary property and methodSakthipriyan Vairamani
`require.paths` property and `require.registerExtension` function have been throwing errors when used. They both are like this for years now. This patch removes them from the system. PR-URL: https://github.com/nodejs/node/pull/2922 Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-10-05module: use UNC paths when loading native addonsJustin Chase
When using require to load a native addon the path must be converted into a long path, otherwise the addon will fail to be loaded on windows if the path is longer than 260 characters. PR-URL: https://github.com/nodejs/node/pull/2965 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Benjamin Gruenbaum <inglor@gmail.com>
2015-10-03node: add -c|--check CLI arg to syntax check scriptDave Eddy
PR-URL: https://github.com/nodejs/node/pull/2411 Reviewed-By: Rod Vagg <rod@vagg.org> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Evan Lucas <evanlucas@me.com>
2015-09-06src: apply debug force load fixups from 41e63fbAli Ijaz Sheikh
Apply the src/node_contextify.cc and lib/module.js fixups from @bnoordhuis https://github.com/nodejs/node/commit/41e63fb088a29fa05e16fb0d997255678134c043 PR-URL: https://github.com/nodejs/node/pull/2509 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-08-24module: fix module preloading when cwd is ENOENTBradley Meck
Fixes a regression from 5759722cfacf17cc79651c81801a5e03521db053 that prevented modules from being preloaded if the cwd does not exist. Absolute and builtin modules now preload correctly again. Refs: https://github.com/nodejs/node/issues/1803 PR-URL: https://github.com/nodejs/node/pull/2353 Reviewed-By: Jeremiah Senkpiel <fishrock123@rockemail.com>
2015-07-03util: prepend '(node) ' to deprecation messagesSakthipriyan Vairamani
Changes included in this commit are 1. Making the deprecation messages consistent. The messages will be in the following format x is deprecated. Use y instead. If there is no alternative for `x`, then the ` Use y instead.` part will not be there in the message. 2. All the internal deprecation messages are printed with the prefix `(node) `, except when the `--trace-deprecation` flag is set. Fixes: https://github.com/nodejs/io.js/issues/1883 PR-URL: https://github.com/nodejs/io.js/pull/1892 Reviewed-By: Roman Reiss <me@silverwind.io>
2015-06-22module: fix stat with long paths on WindowsMichaël Zasso
PR-URL: https://github.com/nodejs/io.js/pull/2013 Reviewed-By: Rod Vagg <rod@vagg.org> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-06-17module: reduce syscalls during require searchPierre Inglebert
require() now checks that the path exists before searching further in it. PR-URL: https://github.com/nodejs/io.js/pull/1920 Reviewed-By: Isaac Z. Schlueter <i@izs.me> Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2015-06-16module: allow long paths for require on WindowsMichaël Zasso
https://github.com/nodejs/io.js/pull/1801 introduced internal fs methods to speed up require. The methods do not call path._makeLong like their counterpart from the fs module. This brings back the old behaviour. Fixes: https://github.com/nodejs/io.js/issues/1990 Fixes: https://github.com/nodejs/io.js/issues/1980 Fixes: https://github.com/nodejs/io.js/issues/1849 PR-URL: https://github.com/nodejs/io.js/pull/1991/files Reviewed-By: Bert Belder <bertbelder@gmail.com>
2015-05-30src: fix module search path for preload modulesAli Ijaz Sheikh
When the preload module is not a abs/relative path, we should use the standard search mechanism of looking into the node_modules folders outwards. The current working directory is deemed to be the 'requiring module', i.e. parent. The search path starts from cwd outwards. Fixes: https://github.com/nodejs/io.js/issues/1803 PR-URL: https://github.com/nodejs/io.js/pull/1812 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2015-05-27lib: speed up require(), phase 2Ben Noordhuis
Replace calls to fs.readFileSync() with an internal variant that does not create Error objects on failure and is a bit speedier in general. A secondary benefit is that it improves start-up times in the debugger because it no longer emits thousands of exception debug events. On a medium-sized application[0], this commit and its predecessor reduce start-up times from about 1.5s to 0.5s and reduce the number of start-up exceptions from ~6100 to 32, half of them internal to the application. [0] https://github.com/strongloop/loopback-sample-app PR-URL: https://github.com/nodejs/io.js/pull/1801 Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-05-27lib: speed up require(), phase 1Ben Noordhuis
Replace calls to fs.statSync() with an internal variant that does not create Error or Stat objects that put strain on the garbage collector. A secondary benefit is that it improves start-up times in the debugger because it no longer emits thousands of exception debug events. PR-URL: https://github.com/nodejs/io.js/pull/1801 Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-04-30repl: add mode detection, cli persistent historyChris Dickinson
this creates a new internal module responsible for providing the repl created via "iojs" or "iojs -i," and adds the following options to the readline and repl subsystems: * "repl mode" - determine whether a repl is strict mode, sloppy mode, or auto-detect mode. * historySize - determine the maximum number of lines a repl will store as history. The built-in repl gains persistent history support when the NODE_REPL_HISTORY_FILE environment variable is set. This functionality is not exposed to userland repl instances. PR-URL: https://github.com/iojs/io.js/pull/1513 Reviewed-By: Fedor Indutny <fedor@indutny.com>