Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Generated on Apr 16, 2024 via pnpm

enhanced-resolve 5.12.0

Offers a async require.resolve function. It's highly configurable.
Package summary
Share
0
issues
2
licenses
2
MIT
1
ISC
Package created
13 Aug 2012
Version published
23 Nov 2022
Maintainers
4
Total deps
3
Direct deps
2
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
2 Packages, Including:
enhanced-resolve@5.12.0
tapable@2.2.1

ISC License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
graceful-fs@4.2.11
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

2
All Dependencies CSV
β“˜ This is a list of enhanced-resolve 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities
graceful-fs4.2.119.57 kBISC
prod
tapable2.2.110.64 kBMIT
prod

Visualizations

Frequently Asked Questions

What does enhanced-resolve do?

Enhanced-resolve is a powerful npm package designed to extend Node.js' default module resolving capabilities. It serves as an asynchronous alternative to the inbuilt require.resolve function, adding numerous practical features such as plugin support and the option to provide a custom filesystem. Enhanced-resolve is very configurable, allowing developers to have granular control over the resolving process.

How do you use enhanced-resolve?

To utilize enhanced-resolve, start by installing the package using npm or yarn as shown in the following command: npm install enhanced-resolve or yarn add enhanced-resolve. After installation, you can require the package in your code and utilize it as demonstrated in the below examples:

const resolve = require("enhanced-resolve");

// Asynchronous resolving
resolve("/some/path/to/folder", "module/dir", (err, result) => {
    console.log(result); // Expected output: "/some/path/node_modules/module/dir/index.js"
});

// Synchronous resolving
let result = resolve.sync("/some/path/to/folder", "../../dir");
console.log(result); // Expected output: "/some/path/dir/index.js"

// Creating a custom resolve function
const myResolve = resolve.create({
    extensions: [".ts", ".js"]
});

myResolve("/some/path/to/folder", "ts-module", (err, result) => {
    console.log(result); // Expected output: "/some/node_modules/ts-module/index.ts"
});

// Creating a resolver using ResolverFactory
const fs = require("fs");
const { CachedInputFileSystem, ResolverFactory } = require("enhanced-resolve");

const myResolver = ResolverFactory.createResolver({
    fileSystem: new CachedInputFileSystem(fs, 4000),
    extensions: [".js", ".json"]
});

const context = {};
const lookupStartPath = "/Users/webpack/some/root/dir";
const request = "./path/to-look-up.js";
const resolveContext = {};
myResolver.resolve(context, lookupStartPath, request, resolveContext, (
    err, filepath) => {
    console.log(filepath); // Outputs the resolved path
});

In the above examples, we initially resolve a module asynchronously, follow up with a synchronous operation, create a custom resolver function, and then make use of the ResolverFactory to create a new resolver.

Where are the enhanced-resolve docs?

The enhanced-resolve documentation is located in the same GitHub repository as the source code. You can access it by navigating to https://github.com/webpack/enhanced-resolve. The README file contains comprehensive information on the features, usage instructions, and configurable options, as well as details on how to create and implement plugins.