Repository: webpack/enhanced-resolve (js)

Issue:
`exports` and `node_modules` inside package resolving broken
@alexander-akait I think you closed my issue prematurely, though granted it was a bit inaccurate.

I've done a bit more digging - the key difference between the `node_modules` folders that npm and yarn generate is that yarn creates `node_module` folders in each dep where their deps have cli tools with a nested `.bin` folder and npm does not.

So from the above, `ipfs-unixfs-importer` depends on `rabin-wasm` which has a [cli tool](https://github.com/hugomrdias/rabin-wasm/blob/master/package.json#L11).

With npm I get:

```
my-project/
├── node_modules/
│   ├── .bin/
│   │   └── rabin-wasm
.. other files
│   ├── ipfs-unixfs-importer/
|   |   └── package.json // etc
```

With yarn I get:

```
my-project/
├── node_modules/
│   ├── .bin/
│   │   └── rabin-wasm
.. other files
│   ├── ipfs-unixfs-importer/
│   │   ├── node_modules/
│   │   │   └── .bin/
│   │   │       └── rabin-wasm
|   |   └── package.json // etc
```

If I remove (or rename) the nested `my-project/node_modules/ipfs-unixfs-importer/node_modules` folder everything works, if I leave it, webpack does not resolve the `rabin-wasm` dependency.  I guess it doesn't walk back up the tree to find the next `node_modules` folder if the first one doesn't have the dep it's looking for like node does?

You can see this yourself with the [repro repo](https://github.com/achingbrain/webpack-cjs-esm-yarn-npm).

_Originally posted by @achingbrain in https://github.com/webpack/webpack/discussions/14268#discussioncomment-1345976_

Pull request description:
fix bug when aliasing `.`
fixes #304 

Patch:
diff --git a/lib/getInnerRequest.js b/lib/getInnerRequest.js
index b9a4de2..0475814 100644
--- a/lib/getInnerRequest.js
+++ b/lib/getInnerRequest.js
@@ -15,7 +15,7 @@ module.exports = function getInnerRequest(resolver, request) {
 	let innerRequest;
 	if (request.request) {
 		innerRequest = request.request;
-		if (/^\.\.?\//.test(innerRequest) && request.relativePath) {
+		if (/^\.\.?(?:\/|$)/.test(innerRequest) && request.relativePath) {
 			innerRequest = resolver.join(request.relativePath, innerRequest);
 		}
 	} else {


Test patch:
diff --git a/test/fixtures/browser-module/package.json b/test/fixtures/browser-module/package.json
index c1595c6..8e4cbc7 100644
--- a/test/fixtures/browser-module/package.json
+++ b/test/fixtures/browser-module/package.json
@@ -3,7 +3,8 @@
     "./lib/ignore.js": false,
     "./lib/replaced.js": "./lib/browser",
     "module-a": "./browser/module-a.js",
-    "module-b": "module-c"
+    "module-b": "module-c",
+    ".": false
   },
   "innerBrowser1": {
     "field": {