0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-30 23:43:09 +01:00
Commit Graph

196 Commits

Author SHA1 Message Date
Jan Krems
59e48329d0 module: Set dynamic import callback
This is an initial implementation to support dynamic import in
both scripts and modules. It's off by default since support for
dynamic import is still flagged in V8. Without setting the V8 flag,
this code won't be executed.

This initial version does not support importing into vm contexts.

PR-URL: https://github.com/nodejs/node/pull/15713
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Bradley Farias <bradley.meck@gmail.com>
2017-11-29 14:16:43 -08:00
Ben Noordhuis
597b3d1941 module: print better message on esm syntax error
Include the offending line in the output and underline the bad token.

Before this commit, it printed "SyntaxError: Unexpected reserved word"
without indicating where the syntax error is.

Now it prints the line and underlines the offending token, like it does
for syntax errors in CJS scripts.

Minor changes are made to the test runner in order to support `*.mjs`
files in test/message.

Fixes: https://github.com/nodejs/node/issues/17277
PR-URL: https://github.com/nodejs/node/pull/17281
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
2017-11-29 12:06:09 +01:00
John-David Dalton
fea1e05ba5 module: rename internalModuleReadFile to internalModuleReadJSON
PR-URL: https://github.com/nodejs/node/pull/17084
Fixes: https://github.com/nodejs/node/issues/17076
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2017-11-28 16:21:53 -05:00
Guy Bedford
1f5ee33dcb module: fix for #17130 shared loader cjs dep
PR-URL: https://github.com/nodejs/node/pull/17131
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Bradley Farias <bradley.meck@gmail.com>
2017-11-28 11:47:30 +02:00
Bradley Farias
2219859675
module: be lazy when creating CJS facades
This should remove the penalty for loading CJS that is never imported.

PR-URL: https://github.com/nodejs/node/pull/17153
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2017-11-28 02:52:43 +01:00
Jon Moss
1c1ef3c3b0
module: add builtinModules
Provides list of all builtin modules in Node.

Includes modules of all types:
- prefixed (ex: _tls_common)
- deprecated (ex: sys)
- regular (ex: vm)

PR-URL: https://github.com/nodejs/node/pull/16386
Refs: https://github.com/nodejs/node/issues/3307
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-11-28 02:36:34 +01:00
Ben Noordhuis
6f724e1563 lib,src: remove vm.runInDebugContext()
The V8 API it is based on is deprecated and scheduled for removal later
this year.  Remove it.

PR-URL: https://github.com/nodejs/node/pull/13295
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Robert Jefe Lindstaedt <robert.lindstaedt@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
2017-11-24 00:13:44 +01:00
cjihrig
8578e81b2b
module: replace default paths in require.resolve()
Prior to this commit, the default search paths would be included
in the require.resolve() process, even if user specified paths
were provided. This commit causes the default paths to be
omitted by using a fake parent module.

Refs: https://github.com/nodejs/node/issues/5963
PR-URL: https://github.com/nodejs/node/pull/17113
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2017-11-21 11:38:12 -05:00
Ben Noordhuis
0fdd88a374 module: speed up package.json parsing more
Move the logic from the previous commit to C++ land in order to avoid
creating a new string when we know we won't parse it anyway.

PR-URL: https://github.com/nodejs/node/pull/15767
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2017-11-15 12:01:20 +01:00
Ben Noordhuis
fdbb6dd042 module: speed up package.json parsing
If the package.json does not contain the string '"main"', skip parsing
it to JSON.

Note that this changes the behavior of the module loader in the presence
of package.json files that don't contain legal JSON.  Such files used to
throw an exception but now they are simply ignored unless they contain a
"main" property.

To me, that seems like a good trade-off: I observe a 25% reduction in
start-up time on a medium-sized application[0].

[0] https://github.com/strongloop/sls-sample-app

PR-URL: https://github.com/nodejs/node/pull/15767
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2017-11-15 12:00:25 +01:00
Myles Borins
82790d84f2 module: revert #3384 DEP0019 EOL
The original commit was landed without running CITGM. Unfortunately
this change breaks the module `d` which has over 500k downloads a day.

It is worth mentioning that the compatibility hack can be removed
without breaking anything.

We should definitely revisit for the next Semver-Major but shipping
this today will cause non trivial ecosystem breakages.

Refs: https://github.com/nodejs/node/pull/3384

PR-URL: https://github.com/nodejs/node/pull/16634
Refs: https://github.com/nodejs/node/pull/3384
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-10-31 09:14:19 -07:00
Guy Bedford
cadc47fe07 module: fix extension lookups for top-level main
The reason is that absolute URLs do not go through extension and index
checks. By switching to an absolute path, the resolver still applies
extensions properly to the top-level main.

PR-URL: https://github.com/nodejs/node/pull/16526
Fixes: https://github.com/nodejs/node/issues/16476
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2017-10-28 13:25:40 +02:00
guybedford
d853758a22 module: fix hook module CJS dependency loading
It can be useful to load dependencies as part of the loader hook
definition file. This fixes a bug where `import x from 'x'` would
always return `x` as `undefined` if the import was made in a loader
hooks definition module.

A parallel change to the CJS loading injection process meant that the
CJS module wasn't being injected into the correct loader instance,
which is corrected here with a test.

PR-URL: https://github.com/nodejs/node/pull/16381
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
2017-10-28 13:22:55 +02:00
cjihrig
9c6f6b0633
module: support custom paths to require.resolve()
This commit allows custom lookup paths to be passed to
require.resolve(). It also adds require.resolve.paths()
which retrieves the default resolution paths.

Fixes: https://github.com/nodejs/node/issues/5963
Fixes: https://github.com/nodejs/node/issues/16389
PR-URL: https://github.com/nodejs/node/pull/16397
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Wyatt Preul <wpreul@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
2017-10-25 09:14:14 -04:00
Guy Bedford
fe4675b301 module: fix main resolution and not found updates
This simplifies the top-level load when ES modules are enabled
as we can entirely delegate the module resolver, which will hand
over to CommonJS where appropriate.

All not found errors are made consistent to throw during resolve
and have the MODULE_NOT_FOUND code.

Includes the test case from https://github.com/nodejs/node/pull/15736.

Fixes: https://github.com/nodejs/node/issues/15732
PR-URL: https://github.com/nodejs/node/pull/16147
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-10-21 10:45:40 -07:00
Anatoli Papirovski
10ef56359e
lib: fix extraneous space in module.js
An extra space was not caught by the linter due to what appears
to be a bug in eslint 4.3.0 — remove it.

PR-URL: https://github.com/nodejs/node/pull/16199
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2017-10-19 08:59:45 -04:00
Anna Henningsen
e6dfd59be0
lib: pass internalBinding more implicitly
Modify passing of the `internalBinding` function so that it’s
easier for core modules to adopt, and also not even accessible
through `--expose-internals`.

This also splits the module wrapper into a separate version for
internal bindings and for CJS modules, which seems like a good
idea given the different semantics.

PR-URL: https://github.com/nodejs/node/pull/16218
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-10-18 11:36:28 +02:00
Weijia Wang
212de3c5ec
lib: use destructuring for some constants
This change is to unify the declaration for constants into using
destructuring on the top-level-module scope, reducing some redundant
code.

PR-URL: https://github.com/nodejs/node/pull/16063
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
2017-10-16 23:34:32 +02:00
Orta
520cf1d6de doc: Update a typo in module.js' comments
PR-URL: https://github.com/nodejs/node/pull/16205
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
2017-10-15 10:37:22 +08:00
243083df
695b307cc6
module: minor performance improvement
PR-URL: https://github.com/nodejs/node/pull/16125
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2017-10-14 11:33:41 +02:00
guybedford
d21a11dc23 module: resolve and instantiate loader pipeline hooks
This enables a --loader flag for Node, which can provide custom
"resolve" and "dynamicInstantiate" methods for custom ES module
loading.

In the process, module providers have been converted from classes
into functions and the module APIs have been made to pass URL strings
over objects.

PR-URL: https://github.com/nodejs/node/pull/15445
Reviewed-By: Bradley Farias <bradley.meck@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
2017-10-11 08:47:23 -05:00
James M Snell
1f8d527e94 path: deprecate internal _makeLong, replace
Replace the internal `path._makeLong()` with a public
`path.toLongUNCPath()` method. Add documentation.

PR-URL: https://github.com/nodejs/node/pull/14956
Ref: https://github.com/standard-things/esm/issues/66
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2017-10-02 11:30:19 -07:00
Jackson Tian
9d7574eef5
module: deprecate Module._debug
The _debug of Module is undocumented and it useless here.

PR-URL: https://github.com/nodejs/node/pull/13948
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2017-09-22 21:03:29 -03:00
guybedford
dce72c2335 module: check file url passed to top-level import
Fixes: https://github.com/nodejs/node/issues/15374
PR-URL: https://github.com/nodejs/node/pull/15389
Reviewed-By: Bradley Farias <bradley.meck@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
2017-09-15 12:32:48 -07:00
Bradley Farias
c8a389e19f module: Allow runMain to be ESM
This follows the EPS an allows the node CLI to have ESM as an entry point.
`node ./example.mjs`. A newer V8 is needed for `import()` so that is not
included. `import.meta` is still in specification stage so that also is not
included.

PR-URL: https://github.com/nodejs/node/pull/14369
Author: Bradley Farias <bradley.meck@gmail.com>
Author: Guy Bedford <guybedford@gmail.com>
Author: Jan Krems <jan.krems@groupon.com>
Author: Timothy Gu <timothygu99@gmail.com>
Author: Michaël Zasso <targos@protonmail.com>
Author: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2017-09-07 15:18:32 -05:00
Roman Reiss
a517466aa7
module: mark DEP0019 as EOL and remove compat code
This removes the compatibilty code that was in place to allow an unintended
interaction between `require('.')` and `NODE_PATH`. The compatibility code and
the accompanying deprecation warning has been in place since 2015-04-17.

PR-URL: https://github.com/nodejs/node/pull/3384
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2017-08-31 21:11:49 +02:00
Ben Noordhuis
c83d9bbffb lib: include cached modules in module.children
`module.children` is supposed to be the list of modules included by this
module but lib/module.js failed to update the list when the included
module was retrieved from `Module._cache`.

Fixes: https://github.com/nodejs/node/issues/7131
PR-URL: https://github.com/nodejs/node/pull/14132
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2017-07-24 16:56:31 +02:00
Refael Ackermann
16689e30ae inspector: --debug* deprecation and invalidation
PR-URL: https://github.com/nodejs/node/pull/12949
Fixes: https://github.com/nodejs/node/issues/12364
Fixes: https://github.com/nodejs/node/issues/12630
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jan Krems <jan.krems@gmail.com>
2017-05-29 11:33:59 -04:00
Eugene Ostroukhov
3f48ab3042 inspector: do not add 'inspector' property
'inspector' property is not an official API and should not be published
on process object, where the user may discover it.

This change was extracted from https://github.com/nodejs/node/pull/12263
that will be focused on creating JS bindings.

PR-URL: https://github.com/nodejs/node/pull/12656
Reviewed-By: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
2017-05-04 10:40:24 -07:00
WORMSS
26047c39c8 lib: fix typo in comments in module.js
A minor typo in comments, no logic changes.

PR-URL: https://github.com/nodejs/node/pull/12528
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: David Cai <davidcai1993@yahoo.com>
Reviewed-By: Jeremy Whitlock <jwhitlock@apache.org>
2017-04-24 14:01:07 -07:00
Ben Noordhuis
e0b076a949 lib,src,test: update --debug/debug-brk comments
Overlooked in commit 47f8f74 ("src: remove support for --debug") from
earlier this month.

PR-URL: https://github.com/nodejs/node/pull/12495
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2017-04-21 10:35:06 +02:00
Sebastian Van Sande
f97156623a
module: standardize strip shebang behaviour
When loading a module, Node needs to finds the end
of a shebang comment by searching for a \r or \n character.
This behaviour is now standardized into a dedicated
internal module function

Refs: https://github.com/nodejs/node/issues/12180
PR-URL: https://github.com/nodejs/node/pull/12202
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2017-04-19 19:56:18 +02:00
Eugene Ostroukhov
7954d2a4c7 inspector: use inspector API for "break on start"
This change removes a need for using deprecated debug context for
breaking at the start of the main module.

PR-URL: https://github.com/nodejs/node/pull/12076
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2017-03-30 13:25:05 -07:00
James M Snell
2d230faa56 module: avoid using forEach
PR-URL: https://github.com/nodejs/node/pull/11582
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-03-17 11:09:45 -07:00
Richard Lau
055482c21e
module: fix loading from global folders on Windows
Code was calculating $PREFIX/lib/node relative to process.execPath, but
on Windows process.execPath is $PREFIX\node.exe whereas everywhere else
process.execPath is $PREFIX/bin/node (where $PREFIX is the root of the
installed Node.js).

PR-URL: https://github.com/nodejs/node/pull/9283
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: João Reis <reis@janeasystems.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2017-03-11 22:08:19 +00:00
Brian White
c67207731f
lib: simplify Module._resolveLookupPaths
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-10 23:48:59 -05:00
Brian White
e32425bfcd
module: avoid JSON.stringify() for cache key
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-10 23:48:53 -05:00
Brian White
28dc848e70
lib: improve method of function calling
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-10 23:48:46 -05:00
Brian White
403b89e72b
module: avoid hasOwnProperty()
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-10 23:48:41 -05:00
Brian White
298a40e04e
module: use "clean" objects
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-10 23:48:38 -05:00
Brian White
a851b868c0
lib: remove sources of permanent deopts
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-10 23:48:35 -05:00
James M Snell
98e54b0bd4 meta: restore original copyright header
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-03-10 11:23:48 -08:00
James M Snell
5de3cf099c lib: add static identifier codes for all deprecations
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>
2017-01-30 11:11:57 -08:00
Anna Henningsen
5dea1e2a5d
fs: export realpathCacheKey from internal/fs
Move the internally defined symbol `fs.realpathCacheKey` to
the internal fs module, where it’s more appropriate.

The symbol was recently added in c084287a60, 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-16 20:22:18 +01:00
Kelvin Jin
ebff29f2fe module: check -e flag in debug break setup
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-11-15 13:54:53 -08:00
Ben Noordhuis
678c094357 module: skip directories known not to exist
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-24 22:50:44 +02:00
Adri Van Houdt
4d6297fef0 module: Remove deprecated function requireRepl.
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-07 12:51:52 -07:00
Bryan English
4c619ec421 module: fix comment from "read-only" to "shallow"
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-10-03 12:48:21 +02:00
Anna Henningsen
c084287a60
fs,module: add module-loader-only realpath cache
Reintroduce a realpath cache with the same mechanisms which existed
before b488b19eaf
(`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-30 16:01:59 +02:00
James M Snell
15eaba98a1 lib: use emitWarning instead of printDeprecationMessage
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-09-02 13:15:22 -07:00