Coder Social home page Coder Social logo

enhanced-resolve's Introduction

enhanced-resolve

npm Build Status codecov Install Size GitHub Discussions

Offers an async require.resolve function. It's highly configurable.

Features

  • plugin system
  • provide a custom filesystem
  • sync and async node.js filesystems included

Getting Started

Install

# npm
npm install enhanced-resolve
# or Yarn
yarn add enhanced-resolve

Resolve

There is a Node.js API which allows to resolve requests according to the Node.js resolving rules. Sync and async APIs are offered. A create method allows to create a custom resolve function.

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

resolve("/some/path/to/folder", "module/dir", (err, result) => {
	result; // === "/some/path/node_modules/module/dir/index.js"
});

resolve.sync("/some/path/to/folder", "../../dir");
// === "/some/path/dir/index.js"

const myResolve = resolve.create({
	// or resolve.create.sync
	extensions: [".ts", ".js"]
	// see more options below
});

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

Creating a Resolver

The easiest way to create a resolver is to use the createResolver function on ResolveFactory, along with one of the supplied File System implementations.

const fs = require("fs");
const { CachedInputFileSystem, ResolverFactory } = require("enhanced-resolve");

// create a resolver
const myResolver = ResolverFactory.createResolver({
	// Typical usage will consume the `fs` + `CachedInputFileSystem`, which wraps Node.js `fs` to add caching.
	fileSystem: new CachedInputFileSystem(fs, 4000),
	extensions: [".js", ".json"]
	/* any other resolver options here. Options/defaults can be seen below */
});

// resolve a file with the new resolver
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 /*Error*/,
	filepath /*string*/
) => {
	// Do something with the path
});

Resolver Options

Field Default Description
alias [] A list of module alias configurations or an object which maps key to value
aliasFields [] A list of alias fields in description files
extensionAlias {} An object which maps extension to extension aliases
cachePredicate function() { return true }; A function which decides whether a request should be cached or not. An object is passed to the function with path and request properties.
cacheWithContext true If unsafe cache is enabled, includes request.context in the cache key
conditionNames [] A list of exports field condition names
descriptionFiles ["package.json"] A list of description files to read from
enforceExtension false Enforce that a extension from extensions must be used
exportsFields ["exports"] A list of exports fields in description files
extensions [".js", ".json", ".node"] A list of extensions which should be tried for files
fallback [] Same as alias, but only used if default resolving fails
fileSystem The file system which should be used
fullySpecified false Request passed to resolve is already fully specified and extensions or main files are not resolved for it (they are still resolved for internal requests)
mainFields ["main"] A list of main fields in description files
mainFiles ["index"] A list of main files in directories
modules ["node_modules"] A list of directories to resolve modules from, can be absolute path or folder name
plugins [] A list of additional resolve plugins which should be applied
resolver undefined A prepared Resolver to which the plugins are attached
resolveToContext false Resolve to a context instead of a file
preferRelative false Prefer to resolve module requests as relative request and fallback to resolving as module
preferAbsolute false Prefer to resolve server-relative urls as absolute paths before falling back to resolve in roots
restrictions [] A list of resolve restrictions
roots [] A list of root paths
symlinks true Whether to resolve symlinks to their symlinked location
unsafeCache false Use this cache object to unsafely cache the successful requests

Plugins

Similar to webpack, the core of enhanced-resolve functionality is implemented as individual plugins that are executed using tapable. These plugins can extend the functionality of the library, adding other ways for files/contexts to be resolved.

A plugin should be a class (or its ES5 equivalent) with an apply method. The apply method will receive a resolver instance, that can be used to hook in to the event system.

Plugin Boilerplate

class MyResolverPlugin {
	constructor(source, target) {
		this.source = source;
		this.target = target;
	}

	apply(resolver) {
		const target = resolver.ensureHook(this.target);
		resolver
			.getHook(this.source)
			.tapAsync("MyResolverPlugin", (request, resolveContext, callback) => {
				// Any logic you need to create a new `request` can go here
				resolver.doResolve(target, request, null, resolveContext, callback);
			});
	}
}

Plugins are executed in a pipeline, and register which event they should be executed before/after. In the example above, source is the name of the event that starts the pipeline, and target is what event this plugin should fire, which is what continues the execution of the pipeline. For an example of how these different plugin events create a chain, see lib/ResolverFactory.js, in the //// pipeline //// section.

Escaping

It's allowed to escape # as \0# to avoid parsing it as fragment.

enhanced-resolve will try to resolve requests containing # as path and as fragment, so it will automatically figure out if ./some#thing means .../some.js#thing or .../some#thing.js. When a # is resolved as path it will be escaped in the result. Here: .../some\0#thing.js.

Tests

yarn test

Passing options from webpack

If you are using webpack, and you want to pass custom options to enhanced-resolve, the options are passed from the resolve key of your webpack configuration e.g.:

resolve: {
  extensions: ['.js', '.jsx'],
  modules: [path.resolve(__dirname, 'src'), 'node_modules'],
  plugins: [new DirectoryNamedWebpackPlugin()]
  ...
},

License

Copyright (c) 2012-2019 JS Foundation and other contributors

MIT (http://www.opensource.org/licenses/mit-license.php)

enhanced-resolve's People

Contributors

43081j avatar aaronmallen avatar alexander-akait avatar avivahl avatar barak007 avatar bvanjoi avatar chandlerprall avatar dependabot[bot] avatar doodadjs avatar e-cloud avatar fu1996 avatar gcaufy avatar matthewwithanm avatar merceyz avatar mightyiam avatar mikesherov avatar ndelangen avatar nschonni avatar ooflorent avatar realityking avatar rishabh3112 avatar roblg avatar samolabams avatar sheerun avatar snitin315 avatar sokra avatar thelarkinn avatar vankop avatar wcjordan avatar wtlin1228 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

enhanced-resolve's Issues

Bug: TypeError: Cannot read property 'startsWith' of undefined

I've been seeing this a lot this morning (full trace):

/Users/robcresswell/icing/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:145
			if(key.startsWith(what))
			      ^

TypeError: Cannot read property 'startsWith' of undefined
    at Storage.purge (/Users/robcresswell/icing/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:145:10)
    at Storage.purge (/Users/robcresswell/icing/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:150:9)
    at CachedInputFileSystem.purge (/Users/robcresswell/icing/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:259:20)
    at Watchpack.watcher.once (/Users/robcresswell/icing/node_modules/webpack/lib/node/NodeWatchFileSystem.js:42:26)
    at Object.onceWrapper (events.js:318:30)
    at emitTwo (events.js:125:13)
    at Watchpack.emit (events.js:213:7)
    at Watchpack._onTimeout (/Users/robcresswell/icing/node_modules/watchpack/lib/watchpack.js:142:7)
    at ontimeout (timers.js:469:11)
    at tryOnTimeout (timers.js:304:5)

It occurs any time a reload is prompted when using webpack-dev-server w/ hot-reload & Vue.

Error when using webpack in watch mode

I have updated to the latest release of this library (3.4.0), and that caused the watch script I've added to package.json (actually it is just webpack -d -w) to break. It breaks with this error message:

/Users/daniel.rotter/Development/massiveart/sulu-minimal/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:145
			if(key.startsWith(what))
			      ^

TypeError: Cannot read property 'startsWith' of undefined
    at Storage.purge (/Users/daniel.rotter/Development/massiveart/sulu-minimal/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:145:10)
    at Storage.purge (/Users/daniel.rotter/Development/massiveart/sulu-minimal/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:150:9)
    at CachedInputFileSystem.purge (/Users/daniel.rotter/Development/massiveart/sulu-minimal/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:259:20)
    at Watchpack.watcher.once (/Users/daniel.rotter/Development/massiveart/sulu-minimal/node_modules/webpack/lib/node/NodeWatchFileSystem.js:42:26)
    at Object.onceWrapper (events.js:318:30)
    at emitTwo (events.js:125:13)
    at Watchpack.emit (events.js:213:7)
    at Watchpack._onTimeout (/Users/daniel.rotter/Development/massiveart/sulu-minimal/node_modules/watchpack/lib/watchpack.js:142:7)
    at ontimeout (timers.js:488:11)
    at tryOnTimeout (timers.js:323:5)
    at Timer.listOnTimeout (timers.js:283:5)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ watch: `webpack -d -w`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ watch script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

The initial build works, but this error occurs after I save a file being watched. Is there some compatability issue with this release?

If I downgrade to version 3.3.0 of this library the watch task is working again.

AliasFieldPlugin.apply + lodash: resolving the wrong toString

When resolving "./toString" from lodash, data2 on AliasFieldPlugin.js is removing the ./ from "./toString" of lodash, causing fieldData to get the default function toString() of every object.

Resulting in:

       var idxQuery = identifier.indexOf("?");
                                  ^

TypeError: identifier.indexOf is not a function
    at Resolver.parse (/Users/fcconstantino/Projects/@products/@crefisa/NetBankApp/node_modules/enhanced-resolve/lib/Resolver.js:181:28)
    at Resolver.<anonymous> (/Users/fcconstantino/Projects/@products/@crefisa/NetBankApp/node_modules/enhanced-resolve/lib/ParsePlugin.js:17:25)
    at Resolver.applyPluginsAsyncSeriesBailResult1 (/Users/fcconstantino/Projects/@products/@crefisa/NetBankApp/node_modules/tapable/lib/Tapable.js:256:13)
    at runNormal (/Users/fcconstantino/Projects/@products/@crefisa/NetBankApp/node_modules/enhanced-resolve/lib/Resolver.js:130:20)
    at Resolver.doResolve (/Users/fcconstantino/Projects/@products/@crefisa/NetBankApp/node_modules/enhanced-resolve/lib/Resolver.js:116:3)
    at Resolver.<anonymous> (/Users/fcconstantino/Projects/@products/@crefisa/NetBankApp/node_modules/enhanced-resolve/lib/UnsafeCachePlugin.js:37:12)
    at Resolver.applyPluginsAsyncSeriesBailResult1 (/Users/fcconstantino/Projects/@products/@crefisa/NetBankApp/node_modules/tapable/lib/Tapable.js:256:13)
    at runNormal (/Users/fcconstantino/Projects/@products/@crefisa/NetBankApp/node_modules/enhanced-resolve/lib/Resolver.js:130:20)
    at Resolver.doResolve (/Users/fcconstantino/Projects/@products/@crefisa/NetBankApp/node_modules/enhanced-resolve/lib/Resolver.js:116:3)
    at Resolver.<anonymous> (/Users/fcconstantino/Projects/@products/@crefisa/NetBankApp/node_modules/enhanced-resolve/lib/AliasFieldPlugin.js:49:12)

Something I couldn't find is: Who is calling the AliasFieldPlugin?

A simple and easy fix was to do something like this:

if (typeof data === 'function') {
    return callback();
}

OBS: I'm also using Haul, which uses an older version of webpack, but still the latest version of enhanced-resolve

Using Version
npm 5.4.2
webpack 2.7.0
enhanced-resolve 3.4.1
lodash 4.17.4
haul 1.0.0-beta.5

Incompatibility with node fs api.

I'm not sure this is bugs or expected behavior.
Example: fileSystem.readFileSync(filename, "utf8"), not respect utf8 and always return Buffer.

Cannot read property 'lastIndexOf' of undefined

Sorry for the crappy title, hard to figure out something descriptive for this.

I'm trying to create a webpack resolver/plugin where something arbitrary (foo:bar:baz) is resolved to a filesystem location (after some async work figuring out which file).

This is kind of hard, as I can't seem to hook in to the resolve infrastructure "early enough". I've added a regular resolver plugin, but the apply() method isn't called before webpack fails with an error that it can't resolve the module I'm trying to find.

In webpack 1, I made this work by adding a plugin that set up a hook on compiler.resolvers.normal.plugin('module', () => {}), resolved the request asyncronously and called this.doResolve() with a new request, pointing to a concrete file.

In webpack 2, I managed to do mostly the same (I have to wait for the compilation event being emitted before the resolvers are initialized), but when I pass the modified request to the doResolve() method, it ends up crashing inside of enhanced-resolve (TypeError: Cannot read property 'lastIndexOf' of undefined). It looks like it's trying to find a package.json file. Not sure why this is needed, or how I can tell it to search a specific location for the file.

Any ideas? Suggestions? Are there any guides on how to make a totally custom resolver?

Stack trace:

/home/espenh/webdev/san/node_modules/webpack/node_modules/enhanced-resolve/lib/DescriptionFileUtils.js:84
  var i = directory.lastIndexOf("/"),
                   ^

TypeError: Cannot read property 'lastIndexOf' of undefined
    at cdUp (/home/espenh/webdev/san/node_modules/webpack/node_modules/enhanced-resolve/lib/DescriptionFileUtils.js:84:19)
    at /home/espenh/webdev/san/node_modules/webpack/node_modules/enhanced-resolve/lib/DescriptionFileUtils.js:50:17
    at /home/espenh/webdev/san/node_modules/webpack/node_modules/enhanced-resolve/lib/forEachBail.js:29:14
    at Array.<anonymous> (/home/espenh/webdev/san/node_modules/webpack/node_modules/enhanced-resolve/lib/DescriptionFileUtils.js:14:50)
    at Storage.finished (/home/espenh/webdev/san/node_modules/webpack/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:38:15)
    at /home/espenh/webdev/san/node_modules/webpack/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:69:9
    at Array.<anonymous> (/home/espenh/webdev/san/node_modules/webpack/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:182:20)
    at Storage.finished (/home/espenh/webdev/san/node_modules/webpack/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:38:15)
    at ReadFileContext.<anonymous> (/home/espenh/webdev/san/node_modules/webpack/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:69:9)
    at ReadFileContext.callback (/home/espenh/webdev/san/node_modules/graceful-fs/graceful-fs.js:78:16)

Added node 4.x dependency in 3.1

Some people are still using an old version of node with webpack 1.13.0 and ts-loader 1.3.3, but ts-loader 1.3.3 references enhanced-resolve ^3.0.0, which now breaks with 3.1 requiring a newer version of node.

Shouldn't the added dependency make this 4.0?

Failed to rebuild with [email protected],throw exceptions that enhanced-resolve/lib/CachedInputFileSystem.js:145 if(key.startsWith(what))

/home/qd/project_1/fin-front/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:145
                        if(key.startsWith(what))
                              ^

TypeError: Cannot read property 'startsWith' of undefined
    at Storage.purge (/home/qd/project_1/fin-front/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:145:10)
    at Storage.purge (/home/qd/project_1/fin-front/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:150:9)
    at CachedInputFileSystem.purge (/home/qd/project_1/fin-front/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:259:20)
    at EventEmitter.<anonymous> (/home/qd/project_1/fin-front/node_modules/webpack/lib/node/NodeWatchFileSystem.js:42:26)
    at EventEmitter.g (events.js:260:16)
    at emitTwo (events.js:87:13)
    at EventEmitter.emit (events.js:172:7)
    at EventEmitter._onTimeout (/home/qd/project_1/fin-front/node_modules/watchpack/lib/watchpack.js:142:7)
    at Timer.listOnTimeout (timers.js:92:15)

I start up is ok but I edit the file failed,I use ubuntu 16.10

Memoize calls to memory-fs join for performance

Calls to Resolver normalize can take up 5% to 8% of the build time. If we memoize these calls we can improve webpack build performance. Memoizing the join call seems to be the best place to intercept calls to memory-fs. I'll put up a PR if this sounds reasonable.

Before
before
After
after

Can't find any documenatation

The documentation link points to the front page of the Webpack wiki, which then links to the Webpack website. I can't find any documentation about what this module does or how to use it (although it looks very useful from looking at the code).

I want to know:

  • Does this implement defunctzombie's browser field spec?
  • If so, am I correct in understanding that enhanced-resolve is basically similar to browser-resolve, but with the added ability to provide your own filesystem to mediate/handle disk access?

It would be good to see at least one usage example in the readme.

RangeError: Maximum call stack size exceeded

I am getting this error while trying to run webpack (2) command on Azure:

\\100.78.172.13\volume-7-default\8f5ecde749dace2bb57a\4e07195f015b45ce8e9ba255dc901988\site\repository\Source\Website\Content\app\node_modules\webpack\node_modules\memory-fs\lib\normalize.js:19
    while(currentDirectoryWinMiddleRegExp.test(path))
                                          ^

RangeError: Maximum call stack size exceeded
    at RegExp.test (native)
    at normalize (\\100.78.172.13\volume-7-default\8f5ecde749dace2bb57a\4e07195f015b45ce8e9ba255dc901988\site\repository\Source\Website\Content\app\node_modules\webpack\node_modules\memory-fs\lib\normalize.js:19:40)
    at Tapable.join (\\100.78.172.13\volume-7-default\8f5ecde749dace2bb57a\4e07195f015b45ce8e9ba255dc901988\site\repository\Source\Website\Content\app\node_modules\webpack\node_modules\memory-fs\lib\join.js:13:9)
    at \\100.78.172.13\volume-7-default\8f5ecde749dace2bb57a\4e07195f015b45ce8e9ba255dc901988\site\repository\Source\Website\Content\app\node_modules\webpack\node_modules\enhanced-resolve\lib\DescriptionFileUtils.js:11:39

    at forEachBail (\\100.78.172.13\volume-7-default\8f5ecde749dace2bb57a\4e07195f015b45ce8e9ba255dc901988\site\repository\Source\Website\Content\app\node_modules\webpack\node_modules\enhanced-resolve\lib\forEachBail.js:12:3)
    at findDescriptionFile (\\100.78.172.13\volume-7-default\8f5ecde749dace2bb57a\4e07195f015b45ce8e9ba255dc901988\site\repository\Source\Website\Content\app\node_modules\webpack\node_modules\enhanced-resolve\lib\DescriptionFileUtils.js:10:3)

    at \\100.78.172.13\volume-7-default\8f5ecde749dace2bb57a\4e07195f015b45ce8e9ba255dc901988\site\repository\Source\Website\Content\app\node_modules\webpack\node_modules\enhanced-resolve\lib\DescriptionFileUtils.js:55:13
    at \\100.78.172.13\volume-7-default\8f5ecde749dace2bb57a\4e07195f015b45ce8e9ba255dc901988\site\repository\Source\Website\Content\app\node_modules\webpack\node_modules\enhanced-resolve\lib\forEachBail.js:29:14
    at \\100.78.172.13\volume-7-default\8f5ecde749dace2bb57a\4e07195f015b45ce8e9ba255dc901988\site\repository\Source\Website\Content\app\node_modules\webpack\node_modules\enhanced-resolve\lib\DescriptionFileUtils.js:15:50
    at Storage.provide (\\100.78.172.13\volume-7-default\8f5ecde749dace2bb57a\4e07195f015b45ce8e9ba255dc901988\site\repository\Source\Website\Content\app\node_modules\webpack\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:53:20)
    at CachedInputFileSystem.readJson (\\100.78.172.13\volume-7-default\8f5ecde749dace2bb57a\4e07195f015b45ce8e9ba255dc901988\site\repository\Source\Website\Content\app\node_modules\webpack\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:164:24)
    at \\100.78.172.13\volume-7-default\8f5ecde749dace2bb57a\4e07195f015b45ce8e9ba255dc901988\site\repository\Source\Website\Content\app\node_modules\webpack\node_modules\enhanced-resolve\lib\DescriptionFileUtils.js:13:25
    at forEachBail (\\100.78.172.13\volume-7-default\8f5ecde749dace2bb57a\4e07195f015b45ce8e9ba255dc901988\site\repository\Source\Website\Content\app\node_modules\webpack\node_modules\enhanced-resolve\lib\forEachBail.js:12:3)
    at findDescriptionFile (\\100.78.172.13\volume-7-default\8f5ecde749dace2bb57a\4e07195f015b45ce8e9ba255dc901988\site\repository\Source\Website\Content\app\node_modules\webpack\node_modules\enhanced-resolve\lib\DescriptionFileUtils.js:10:3)

    at \\100.78.172.13\volume-7-default\8f5ecde749dace2bb57a\4e07195f015b45ce8e9ba255dc901988\site\repository\Source\Website\Content\app\node_modules\webpack\node_modules\enhanced-resolve\lib\DescriptionFileUtils.js:55:13
    at \\100.78.172.13\volume-7-default\8f5ecde749dace2bb57a\4e07195f015b45ce8e9ba255dc901988\site\repository\Source\Website\Content\app\node_modules\webpack\node_modules\enhanced-resolve\lib\forEachBail.js:29:14
    at \\100.78.172.13\volume-7-default\8f5ecde749dace2bb57a\4e07195f015b45ce8e9ba255dc901988\site\repository\Source\Website\Content\app\node_modules\webpack\node_modules\enhanced-resolve\lib\DescriptionFileUtils.js:15:50
    at Storage.provide (\\100.78.172.13\volume-7-default\8f5ecde749dace2bb57a\4e07195f015b45ce8e9ba255dc901988\site\repository\Source\Website\Content\app\node_modules\webpack\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:53:20)
    at CachedInputFileSystem.readJson (\\100.78.172.13\volume-7-default\8f5ecde749dace2bb57a\4e07195f015b45ce8e9ba255dc901988\site\repository\Source\Website\Content\app\node_modules\webpack\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:164:24)
    at \\100.78.172.13\volume-7-default\8f5ecde749dace2bb57a\4e07195f015b45ce8e9ba255dc901988\site\repository\Source\Website\Content\app\node_modules\webpack\node_modules\enhanced-resolve\lib\DescriptionFileUtils.js:13:25
    at forEachBail (\\100.78.172.13\volume-7-default\8f5ecde749dace2bb57a\4e07195f015b45ce8e9ba255dc901988\site\repository\Source\Website\Content\app\node_modules\webpack\node_modules\enhanced-resolve\lib\forEachBail.js:12:3)
    at findDescriptionFile (\\100.78.172.13\volume-7-default\8f5ecde749dace2bb57a\4e07195f015b45ce8e9ba255dc901988\site\repository\Source\Website\Content\app\node_modules\webpack\node_modules\enhanced-resolve\lib\DescriptionFileUtils.js:10:3)

    at \\100.78.172.13\volume-7-default\8f5ecde749dace2bb57a\4e07195f015b45ce8e9ba255dc901988\site\repository\Source\Website\Content\app\node_modules\webpack\node_modules\enhanced-resolve\lib\DescriptionFileUtils.js:55:13
    at \\100.78.172.13\volume-7-default\8f5ecde749dace2bb57a\4e07195f015b45ce8e9ba255dc901988\site\repository\Source\Website\Content\app\node_modules\webpack\node_modules\enhanced-resolve\lib\forEachBail.js:29:14
    at \\100.78.172.13\volume-7-default\8f5ecde749dace2bb57a\4e07195f015b45ce8e9ba255dc901988\site\repository\Source\Website\Content\app\node_modules\webpack\node_modules\enhanced-resolve\lib\DescriptionFileUtils.js:15:50
    at Storage.provide (\\100.78.172.13\volume-7-default\8f5ecde749dace2bb57a\4e07195f015b45ce8e9ba255dc901988\site\repository\Source\Website\Content\app\node_modules\webpack\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:53:20)
    at CachedInputFileSystem.readJson (\\100.78.172.13\volume-7-default\8f5ecde749dace2bb57a\4e07195f015b45ce8e9ba255dc901988\site\repository\Source\Website\Content\app\node_modules\webpack\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:164:24)
    at \\100.78.172.13\volume-7-default\8f5ecde749dace2bb57a\4e07195f015b45ce8e9ba255dc901988\site\repository\Source\Website\Content\app\node_modules\webpack\node_modules\enhanced-resolve\lib\DescriptionFileUtils.js:13:25
    at forEachBail (\\100.78.172.13\volume-7-default\8f5ecde749dace2bb57a\4e07195f015b45ce8e9ba255dc901988\site\repository\Source\Website\Content\app\node_modules\webpack\node_modules\enhanced-resolve\lib\forEachBail.js:12:3)
    at findDescriptionFile (\\100.78.172.13\volume-7-default\8f5ecde749dace2bb57a\4e07195f015b45ce8e9ba255dc901988\site\repository\Source\Website\Content\app\node_modules\webpack\node_modules\enhanced-resolve\lib\DescriptionFileUtils.js:10:3)

Is this caused by my configuration or it's a bug in enhanced-resolve?

Resolve multiple files with a single require

I am working on a bower support plugin where I would like to resolve multiple files once a single require being called.

Lets say I do require('bootstrap') and this should include multiple files:

var mainModules = [
    'dist/js/bootstrap.js',
    'less/bootstrap.less'
];

Here is my test code:

    resolver.plugin('existing-directory', function (request, callback) {
        var mainModules = [];

        try {
            var source = require(path.resolve(request.path, 'bower.json'));
            mainModules = typeof source['main'] == 'string'
                ? [source['main']]
                : source['main'];
        } catch (e) {}

        if (mainModules.length == 0) {
            return callback();
        }

        mainModules.forEach(function (module) {
            var obj = Object.assign({}, request, {
                path: request.path + '/' + module
            });

            resolver.doResolve('file', obj, "file used: " + module, callback);
        });
    });

The problem is that only the first file is being included and others ignored. Is this behaviour possible with enhanced-resolver plugin? Any ideas or example would be welcome. @sokra

Multiple modules support for alias

Hi, currently I have the following alias configuration, which then I need to remember to include both files whenever I want to use the component:

alias: {
  'ng-file-upload-shim5': 'ng-file-upload/angular-file-upload-html5-shim',
  'ng-file-upload-main': 'ng-file-upload/angular-file-upload'
}

But would like to have only one entry for both files, like this:

alias: {
  'ng-file-upload': [
    'ng-file-upload/angular-file-upload-html5-shim',
    'ng-file-upload/angular-file-upload'
  ]
}

What do you think?

Should purge() clear _readJsonStorage?

By trying to solve this problem I realized that invoking purge()

CachedInputFileSystem.prototype.purge = function(what) {
    this._statStorage.purge(what);
    this._readdirStorage.purge(what);
    this._readFileStorage.purge(what);
    this._readlinkStorage.purge(what);
}

does not clear _readJsonStorage and just wanted to confirm if this is intended or not.

RFC: Performance Proposal

I've been running lots of profiles to find the bottlenecks in our webpack build. Probably the biggest bottleneck right now is resolving requests.

To highlight this, I've created a simple test case for our build. Basically I intercepted all calls to Resolver.resolve during a build, and wrote the parameters passed to disk. Then I created a script that loaded the list of requests and used enhanced-resolve to resolve each of the requests, and also used resolve-from.

The results are pretty crazy, for 14850 requests:

  • enhanced-resolve: 11601 ms
  • resolve-from: 484 ms

Note that I didn't do much investigation into where this time is going, but I think that this project (and webpack) would benefit greatly from simplifying the architecture.

I'd prefer to see this library only respect an extensions option, and then stuff like custom description files (like bower.json or component.json) could be added via a loader (whose results could be cached). We could add support for browser fields and aliases the same way (cacheable loader).

package.json with utf-8 bom fails

Steps to reproduce:

  1. npm and yarn install packages
  2. the installed package has a package.json with utf-8 and bom (byte order marker)
  3. webpack build fails with the following error
Module build failed: ModuleNotFoundError: Module not found: SyntaxError: <project>\node_modules\@nice\nice-fluorine-icons\pack
age.json (directory description file): SyntaxError: <project>\node_modules\@nice\nice-fluorine-icons\package.json (directory d
escription file): SyntaxError: Unexpected token ๏ปฟ in JSON at position 0
    at factoryCallback (<project>\node_modules\@angular\cli\node_modules\webpack\lib\Compilation.js:260:39)
    at factory (<project>\node_modules\@angular\cli\node_modules\webpack\lib\NormalModuleFactory.js:247:20)
    at resolver (<project>\node_modules\@angular\cli\node_modules\webpack\lib\NormalModuleFactory.js:65:21)
    at asyncLib.parallel.e (<project>\node_modules\@angular\cli\node_modules\webpack\lib\NormalModuleFactory.js:138:21)
    at <project>\node_modules\async\dist\async.js:3838:9
    at <project>\node_modules\async\dist\async.js:421:16
    at iteratorCallback (<project>\node_modules\async\dist\async.js:996:13)
    at <project>\node_modules\async\dist\async.js:906:16
    at <project>\node_modules\async\dist\async.js:3835:13
    at resolvers.normal.resolve (<project>\node_modules\@angular\cli\node_modules\webpack\lib\NormalModuleFactory.js:130:23)
    at onResolved (<project>\node_modules\enhanced-resolve\lib\Resolver.js:64:18)
    at loggingCallbackWrapper (<project>\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19)
    at innerCallback (<project>\node_modules\enhanced-resolve\lib\Resolver.js:121:19)
    at loggingCallbackWrapper (<project>\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19)
    at <project>\node_modules\tapable\lib\Tapable.js:283:15
    at <project>\node_modules\enhanced-resolve\lib\UnsafeCachePlugin.js:36:19

Background:
we found a lenghty discussion on the npm repo. finally, npm implemented utf-8 bom handling since npm 3.x

At eslint, they also support utf-8 bom since eslint/eslint#6556

Shouldn't it be implemented in webpack then, too?

ES6 Translations

Tried to update some of the files to ES6 and encountered some linting errors while doing so. Is this happening because this project supports an older version of node or is it due to the configuration for eslint? @sokra would you mind clarifying this issue or pointing me towards the correct direction.

RFC Performance Improvement Opportunity

TLDR: Removing createInnerCallback sees a 2x performance boost.

I've been doing a lot of profiling of our webpack builds to see if there are any savings to be had. While doing this I noticed that there is a ton of garbage collection happening, and through that I found my way to this repository.

It seems that createInnerCallback creates many large arrays (full of strings) that go unused unless you're passing the --verbose flag, and your build has errors. There may be other use cases, but that's all I've been able to find.

How can we limit the impact here? I'd love to remove this log entirely as I don't see the value of it as an end user of webpack (webpack 3? ๐Ÿคž ), especially since disabling nets a huge performance win. If that's not possible can we expose an option to disable?

Charts!

  • It's a little bit difficult to highlight, but notice in this call stack that after each loggingCallbackWrapper there is a garbage collection event.

image

  • Here the calls to createInnerCallback have been removed (no more garbage collection).

image

Bottom up profile of our build before any changes:
image

After removing all the createInnerCallback calls:
image

Removing createInnerCallback calls + running with --max-semi-space-size=1000:
image

resolve.mainFields doesn't support objects in package.json

Do you want to request a feature or report a bug?
This is a bug, though possibly an intentional omission.

What is the current behavior?
Sub-arrays in resolve.mainFields are completely ignored during module resolution.

Minimum and contrived working example with repro steps: https://github.com/sjbarag/webpack-mwe

What is the expected behavior?
A sub-array in resolve.mainFields can be used to access properties from an object in a module's package.json, as it was in webpack 1.x.

Please mention other relevant information such as the browser version, Node.js version, webpack version and Operating System.

  • Operating System: Mac OS 10.12.6 "Sierra"
  • Shell: Bash 4.4.12
  • Node: 6.11.2
  • npm: 5.3.0
  • Webpack: 3.5.6 (though I've tested 2.0 and every minor version since)

This issue was moved from webpack/webpack#5638 by @sokra. Orginal issue was by @sjbarag.

for Scripted

Issues from https://issuetracker.springsource.com/browse/SCRIPTED-117 @kdvolder

It doesn't do any caching (our current implementation builds an index of all the node_modules known to a given context. The index is thrown away if there are changes to any node_modules dirs. We will loose the benefit of this index if we switch to using the library. It may be this is ok, if the resolution is still fast enough. I may need to do a bit of performance testing to figure this out.

It does a bit of caching. It caches every io call for a short amount of time (currently fixed to 4 seconds), because webpack does many calls to resolve in parallel and that results in many similar io calls. It also combine parallel equal io calls to one. This libary is build for performance because resolving is a performance critical part of webpack.

For webpack we can assume that no revelant change will be made in these 4 seconds. For Scripted fast moves/renames may cause incorrect results. Not super critical, but Scripted may want to lower the timeout, or clear cache as it have already FileWatchers.

  • make cache time configurable.
  • make cache or parts clearable

It uses the node 'fs' functions directly. All our other code uses the filesystem only via a configurable api. This is now used mainly for testing purposes, but could also be important if we, want to use another filesystem implementation, e.g. to provide a sandboxed filesystem, or something that works completely client side, etc.

  • offer config options for own io calls. This are stat and readFile each sync and async.

We were thinking of using a JSON5 parser instead of a straight JSON parser to improve error tolerance. Doing this (or making it an option) would require a patch to the enhanced-resolve library.

  • offer a config option for the parse function.

code completion

enhanced-resolve can handle a part of that with require.context, but not code completion for module names. A part is already in a method but this is not availible on the interface.

  • add methods to support this. Maybe something like a resolve method with wildcards...

Is Bower supported?

I'm trying to mix npm and bower components in webpack2.

I have:

  • lib/entry_point.js with require('bowerlib') intended for bower, and other npm requires
  • bower_components/bowerlib/main.js with require('raven-js')
  • bower_components/raven-js that specifies dist/raven.js as main.
  • node_modules with lots of npm modules installed

I've tried:

  • out of the box webpack2: can't find bowerlib
  • config with resolve: {modules: [ __dirname + '/bower_components', 'node_modules']} - still can't find bowerlib
  • config with resolve: {modules: [ __dirname + '/bower_components', 'node_modules'],mainFiles: ['index', 'main']} โ€” it can find bowerlib, but can't find raven-js.
  • resolve: {modules: [ __dirname + '/bower_components', 'node_modules'],mainFiles: ['index', 'main'],descriptionFiles: ["bower.json", "package.json"]} โ€” hundreds of errors caused by failure to load npm modules from node_modules that worked otherwise.

Is it possible to use bower components? Is it possible with configuration, or do I have to write a custom plugin?

feature request: could `resolve.alias` be greedy?

It seems that enhanced-resolve cannot handle different modules which have the same prefix.

resolve.alias = {
  antd: 'index',
  'antd/lib': 'components',
};

require('antd') => require('index');

// Now
require('antd/lib') => require('index/lib');

// If `resolve.alias` is greedy, and it is also what I want.
require('antd/lib') => require('components');

Or could you provide other solution which can do what I want? THX :-)

webpack-dev-server fails to rebuild on watch

enhanced-resolve/lib/CachedInputFileSystem.js:145
			if(key.startsWith(what))
			      ^

TypeError: Cannot read property 'startsWith' of undefined
    at Storage.purge (enhanced-resolve/lib/CachedInputFileSystem.js:145:10)
    at Storage.purge (enhanced-resolve/lib/CachedInputFileSystem.js:150:9)
    at CachedInputFileSystem.purge (enhanced-resolve/lib/CachedInputFileSystem.js:259:20)
    at Watchpack.watcher.once (webpack/lib/node/NodeWatchFileSystem.js:42:26)
    at Object.onceWrapper (events.js:318:30)
    at emitTwo (events.js:125:13)
    at Watchpack.emit (events.js:213:7)
    at Watchpack._onTimeout (watchpack/lib/watchpack.js:142:7)
    at ontimeout (timers.js:469:11)
    at tryOnTimeout (timers.js:304:5)
    at Timer.listOnTimeout (timers.js:264:5)

Angular 2 app doesn't build with last version (v3.4.0)

Since last release I can't build my Angular4 app anymore, following error occurs:

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory'
 @ ./src/main.ts 5:0-74
 @ multi ./src/main.ts

Had to revert to v3.3.0.

Nb: I use angular/cli v1.0.0-rc.2

3.4.0 breaks Angular CLI

Hi there,

It seems the recent 3.4.0 breaks @ngtools/webpack, which is at the core @angular/cli (angular/angular-cli#7113).

In the https://github.com/webpack/enhanced-resolve/releases/tag/v3.4.0 release I only see performance changes so am not too sure what changed that breaks our stuff.

Our direct usage of enhanced-resolve is contained in https://github.com/angular/angular-cli/blob/master/packages/@ngtools/webpack/src/paths-plugin.ts.

Is there anything that comes to mind we need to change to support ^3.4.0?

Thanks for your time.

CachedInputFileSystem - TypeError: Cannot read property 'startsWith' of undefined

Environment: Webpack 3.2.0, 3.3.0.

When it is used with babel-loader, webpack-dev-middleware (watch mode is on), sometime when a JS file changed, webpack is triggered to re-compile:

TypeError: Cannot read property 'startsWith' of undefined
    at Storage.purge (/Users/liujing/dianrong/dr-frontend/drcp-workspace/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:145:10)
    at Storage.purge (/Users/liujing/dianrong/dr-frontend/drcp-workspace/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:150:9)
    at CachedInputFileSystem.purge (/Users/liujing/dianrong/dr-frontend/drcp-workspace/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:259:20)
    at EventEmitter.watcher.once (/Users/liujing/dianrong/dr-frontend/drcp-workspace/node_modules/webpack/lib/node/NodeWatchFileSystem.js:42:26)
    at EventEmitter.g (events.js:291:16)
    at emitTwo (events.js:106:13)
    at EventEmitter.emit (events.js:191:7)
    at EventEmitter._onTimeout (/Users/liujing/dianrong/dr-frontend/drcp-workspace/node_modules/watchpack/lib/watchpack.js:142:7)
    at ontimeout (timers.js:365:14)
    at tryOnTimeout (timers.js:237:5)
    at Timer.listOnTimeout (timers.js:207:5) TypeError: Cannot read property 'startsWith' of undefined
    at Storage.purge (/Users/liujing/dianrong/dr-frontend/drcp-workspace/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:145:10)
    at Storage.purge (/Users/liujing/dianrong/dr-frontend/drcp-workspace/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:150:9)
    at CachedInputFileSystem.purge (/Users/liujing/dianrong/dr-frontend/drcp-workspace/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:259:20)
    at EventEmitter.watcher.once (/Users/liujing/dianrong/dr-frontend/drcp-workspace/node_modules/webpack/lib/node/NodeWatchFileSystem.js:42:26)
    at EventEmitter.g (events.js:291:16)
    at emitTwo (events.js:106:13)
    at EventEmitter.emit (events.js:191:7)
    at EventEmitter._onTimeout (/Users/liujing/dianrong/dr-frontend/drcp-workspace/node_modules/watchpack/lib/watchpack.js:142:7)
    at ontimeout (timers.js:365:14)
    at tryOnTimeout (timers.js:237:5)
    at Timer.listOnTimeout (timers.js:207:5)

I drilled down a little bit, found out, it was because babel-loader doing with loaderOptions.babelrc

var babelrcPath = null;
if (loaderOptions.babelrc !== false) {
babelrcPath = exists(fileSystem, loaderOptions.babelrc) ? loaderOptions.babelrc : resolveRc(fileSystem, path.dirname(filename));
}

So if I don't set an option babelrc for babel-loader, it might cache a undefined file name to CachedInputFileSystem via exist(), which is the target that.startsWith calls to later on.

I don't know why I can't reproduce in all Webpack projects, but I think calling .startsWith to a string without checking it with != null is problematic.

Why process commented line?

On Build, Why processing commented line?

ERROR in ./src/app/app.routes.ts 
Module build failed: Error: Can't resolve './+barrel' in
at onResolved (../node_modules/enhanced-resolve/lib/Resolver.js:66:16)
// app.routes.ts  
// Comments
//  { path: 'barrel', loadChildren: './+barrel#BarrelModule'},

ps - Using latest version3+.

Similar issue in angular aot build: Cannot determine the module for class
angular/angular#13590

Potentially on ng-router-loader:
shlomiassaf/ng-router-loader#3

Resolve main entry for bower and component

Hi!

I would like to see support out of the box in webpack for not only npm, but also the other very popular package managers, bower and component.

I'm guessing it should be a matter of adding this:

new DirectoryDescriptionFilePlugin("package.json", ["main"]),
new DirectoryDescriptionFilePlugin("bower.json", ["main"]),
new DirectoryDescriptionFilePlugin("component.json", ["main"]),

Thank you!

How do you create a Noop resolve plugin?

Hello! I'm trying webpack 2 and found the need to make a plugin. I would like to listen into when a module tries to resolve without actually attempting to resolve the file myself. I tried using done() in a similar manner to some of the other plugins like so:

    compiler.resolvers.normal.plugin('module', function (data, done) {
      console.log(data)
      done(null, data)
    })

But that gives several errors like the following (own custom log output):

ERROR (webpack)-hot-middleware/client-overlay
Module build failed: Error: ENOENT: no such file or directory, open '/Users/mcmullins/dev/apps/config-frontend/node_modules/webpack-hot-middleware/client-overlay'
    at Error (native)
 @ (webpack)-hot-middleware/client.js?path=__webpack_hmr&quiet=true 99:14-41
 @ multi main

I also looked into using this.doResolve() but I was entirely clear on how it should be used. Also it seems the signature for this.doResolve() has changed compared to the webpack 1.0 docs? Any help is appreciated, thank you.

Edit: After explaining this and playing with somethings in my code, I think I might be following a red herring? I'll update in a few.

Resolver for external filesystem

Hi, wondering whether this is a best fit for such use-case.
We have files in mongodb gridfs and would like to use webpack to process files within the gridfs.

Is writing a custom-resolver the right approach?

Flow complainis on `invalidPackageJson/package.json`

Hi, I'am truing out Flow, and have a problem with this module. Here what it is outputting:

$ flow 
Flow server launched for /Users/anon/projects/my/fluce
Spawned flow server (child pid=87549)
Logs will go to /var/folders/wt/s831gr6j4r38ffydyq0r2ft80000gn/T/flow/zSUserszSanonzSprojectszSmyzSfluce.log
The flow server will be ready in a moment.
Error: flow server is busyzing. If it was just started this can take some time. Retrying... |
Error: flow server is busyzing. If it was just started this can take some time. Retrying... -

/Users/anon/projects/my/fluce/node_modules/karma-webpack/node_modules/webpack/node_modules/enhanced-resolve/test/fixtures/node_modules/invalidPackageJson/package.json:1:3,2: Unexpected end of input

/Users/anon/projects/my/fluce/node_modules/webpack/node_modules/enhanced-resolve/test/fixtures/node_modules/invalidPackageJson/package.json:1:3,2: Unexpected end of input

Found 2 errors

As far as I understand, it scanning /node_modules/ for some reason, and fails on your broken fixture module. Could you, perhaps, exclude tests from npm package, by adding them in .npmignore? If you could do that, that would be great!

`lib/Resolve.js` has thrown an error under [email protected] and [email protected]

Recently I have upgraded node to version 7.4.0 and npm to 5.1.0 and failed to build my project with Webpack. In the gulp file, I have the following snippet:

webpack(require('./build/webpack/config-prod'), function(err, stats) {
    if (err) throw new gutil.PluginError('webpack', err);
});

But when I run it, I failed to build with following error logged out:

[gulp] /home/gitlab-runner/builds/4fb49748/0/coremail/cmj/template.NG/gulpfile.js:131
[gulp]         if (err) throw new gutil.PluginError('webpack', err);
[gulp]                  ^
[gulp] Error
[gulp]     at /home/gitlab-runner/builds/4fb49748/0/coremail/cmj/template.NG/node_modules/webpack/lib/Compilation.js:229:38
[gulp]     at onDoneResolving (/home/gitlab-runner/builds/4fb49748/0/coremail/cmj/template.NG/node_modules/webpack/lib/NormalModuleFactory.js:29:20)
[gulp]     at /home/gitlab-runner/builds/4fb49748/0/coremail/cmj/template.NG/node_modules/webpack/lib/NormalModuleFactory.js:85:20
[gulp]     at /home/gitlab-runner/builds/4fb49748/0/coremail/cmj/template.NG/node_modules/webpack/node_modules/async/lib/async.js:726:13
[gulp]     at /home/gitlab-runner/builds/4fb49748/0/coremail/cmj/template.NG/node_modules/webpack/node_modules/async/lib/async.js:52:16
[gulp]     at done (/home/gitlab-runner/builds/4fb49748/0/coremail/cmj/template.NG/node_modules/webpack/node_modules/async/lib/async.js:241:17)
[gulp]     at /home/gitlab-runner/builds/4fb49748/0/coremail/cmj/template.NG/node_modules/webpack/node_modules/async/lib/async.js:44:16
[gulp]     at /home/gitlab-runner/builds/4fb49748/0/coremail/cmj/template.NG/node_modules/webpack/node_modules/async/lib/async.js:723:17
[gulp]     at /home/gitlab-runner/builds/4fb49748/0/coremail/cmj/template.NG/node_modules/webpack/node_modules/async/lib/async.js:167:37
[gulp]     at /home/gitlab-runner/builds/4fb49748/0/coremail/cmj/template.NG/node_modules/enhanced-resolve/lib/UnsafeCachePlugin.js:24:19
[gulp]     at onResolved (/home/gitlab-runner/builds/4fb49748/0/coremail/cmj/template.NG/node_modules/enhanced-resolve/lib/Resolver.js:38:18)
[gulp]     at innerCallback (/home/gitlab-runner/builds/4fb49748/0/coremail/cmj/template.NG/node_modules/enhanced-resolve/lib/Resolver.js:88:19)
[gulp]     at loggingCallbackWrapper (/home/gitlab-runner/builds/4fb49748/0/coremail/cmj/template.NG/node_modules/enhanced-resolve/lib/createInnerCallback.js:21:19)
[gulp]     at /home/gitlab-runner/builds/4fb49748/0/coremail/cmj/template.NG/node_modules/tapable/lib/Tapable.js:134:6
[gulp]     at loggingCallbackWrapper (/home/gitlab-runner/builds/4fb49748/0/coremail/cmj/template.NG/node_modules/enhanced-resolve/lib/createInnerCallback.js:21:19)
[gulp]     at innerCallback (/home/gitlab-runner/builds/4fb49748/0/coremail/cmj/template.NG/node_modules/enhanced-resolve/lib/Resolver.js:94:11)

And my version of Webpack is 1.13.2

Is there any working around for solving the problem without upgrading Webpack?

Concord modules?

We've got a rather large build, and after grep'ing through our codebase, it seems that none of our dependencies are using the concord field in package.json. Is this something that is still being pursued or could it be removed from enhanced-resolve?

Webpack Watcher crashes when editing a file since last version

Version 3.4.0. The issue was not there in 3.3.0.
The following errors happens (+ stops the npm process), after saving a file, and the watcher refreshes.

`node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:145
if(key.startsWith(what))
^

TypeError: Cannot read property 'startsWith' of undefined`

New resolve mechanism breaks directory named plugin

I'm trying to use the directory-named-webpack-plugin with webpack 2.1.0-beta.20, but unfortunately it breaks. It seems that some internals have changed: request.request and this.forEachBail are both undefined. I've gotten pretty far by adapting the CloneBasenamePlugin.

I've created an issue to document my findings.

Questions:

  1. Is the plugin needed or can I do everything using CloneBasenamePlugin?
  2. Is there any documentation how to create a directory resolver like this?

Slow module resolution with several `modules` folders

Hi @sokra,

I faced with strange issue with very slow build and debugging showed that if I add several folder to modules, webpack will search in every additional folder several times even when target module can be found in the first folder. Is this behavior desired?

How to debug:

resolve: {
    modules: ['node_modules', '/folder1', '/folder2']
}

then add console.log here: https://github.com/webpack/enhanced-resolve/blob/master/lib/ModulesInRootPlugin.js#L23

do resolve /folder1 revjet-csp-data/src/Ontology.js
do resolve /folder2 revjet-csp-data/src/Ontology.js
do resolve /folder1 revjet-csp-data/src/Ontology.js
do resolve /folder2 revjet-csp-data/src/Ontology.js

And it seems like it grows in n^2 manner. For one folder there are two resolves, for two folders - 4 resolves.

Query not passed in aliased loader

I'm getting the same unexpected behavior as in webpack/webpack#1289. Aliased loaders do not receive query parameters. I checked the code and it seems the fix that was used before wasn't migrated with the new versions.

Node: v5.12.0
webpack: 1.13.2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.