-
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.
feat(gatsby): add pnp resolving by passing rootdir in pkg resolving (#…
…12163) ## Description The current resolution algorithm takes loads the plugins using `require.resolve` via `gatsby`, meaning that PnP will block them unless they're listed in `gatsby`'s dependencies. This diff ensures that the plugins are loaded from the package that contains the configuration. ## Related Issues #10245
- Loading branch information
Showing
4 changed files
with
31 additions
and
9 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 | ||
} |