Skip to content

Commit

Permalink
module: runtime deprecate createRequireFromPath()
Browse files Browse the repository at this point in the history
This commit moves DEP0130 to a runtime deprecation.

PR-URL: #27951
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
cjihrig committed May 31, 2019
1 parent 3ba6813 commit 14701e5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
5 changes: 4 additions & 1 deletion doc/api/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -2451,12 +2451,15 @@ instead.
### DEP0130: Module.createRequireFromPath()
<!-- YAML
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/27951
description: Runtime deprecation.
- version: v12.2.0
pr-url: https://github.com/nodejs/node/pull/27405
description: Documentation-only.
-->
Type: Documentation-only
Type: Runtime
Module.createRequireFromPath() is deprecated. Please use [`module.createRequire()`][] instead.
Expand Down
7 changes: 6 additions & 1 deletion lib/internal/modules/cjs/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,12 @@ function createRequireFromPath(filename) {
return makeRequireFunction(m);
}

Module.createRequireFromPath = createRequireFromPath;
Module.createRequireFromPath = deprecate(
createRequireFromPath,
'Module.createRequireFromPath() is deprecated. ' +
'Use Module.createRequire() instead.',
'DEP0130'
);

const createRequireError = 'must be a file URL object, file URL string, or ' +
'absolute path string';
Expand Down
1 change: 1 addition & 0 deletions test/message/async_error_sync_esm.out
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ Error: test
at async three (*fixtures*async-error.js:20:3)
at async four (*fixtures*async-error.js:24:3)
at async main (*message*async_error_sync_esm.mjs:7:5)
(node:*) [DEP0130] DeprecationWarning: Module.createRequireFromPath() is deprecated. Use Module.createRequire() instead.

0 comments on commit 14701e5

Please sign in to comment.