-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds a rootDir config option used to resolve plugins
- Loading branch information
Maël Nison
committed
Feb 28, 2019
1 parent
383ad49
commit fc855d6
Showing
4 changed files
with
26 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
const Module = require(`module`) | ||
const path = require(`path`) | ||
|
||
// Polyfill Node's `Module.createRequireFromPath` if not present (added in Node v10.12.0) | ||
module.exports = | ||
Module.createRequireFromPath || | ||
function(filename) { | ||
const mod = new Module(filename, null) | ||
|
||
mod.filename = filename | ||
mod.paths = Module._nodeModulePaths(path.dirname(filename)) | ||
mod._compile(`module.exports = require;`, filename) | ||
|
||
return mod.exports | ||
} |