How to use the enhanced-resolve/lib/DescriptionFileUtils.loadDescriptionFile function in enhanced-resolve

To help you get started, we’ve selected a few enhanced-resolve examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TheLarkInn / everything-is-a-plugin / plugin-lessons-plugins / 40ResolverPlugin.js View on Github external
resolver.plugin("described-relative", (request, callback) => {
                const directory = request.path;
                DescriptionFileUtils.loadDescriptionFile(resolver, directory, ["wat.json"], ((err, result) => {
                    console.log(directory);
                    if(err) return callback(err);
                    if(!result) {
                        if(callback.missing) {
                            callback.missing.push(resolver.join(directory, "wat.json"));
                        }
                        if(callback.log) callback.log("No description file found");
                        return callback();
                    }

                const relativePath = "." + request.path.substr(result.directory.length).replace(/\\/g, "/");
                
                // This is the requst that will be passed on to the next resolver plugin.
                const obj = Object.assign({}, request, {
                    descriptionFilePath: result.path,
                    descriptionFileData: result.content,