Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
module: runtime deprecate createRequireFromPath()
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
commit 14701e539c190563cc5b041d101682129f4f5770
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.