You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. Perform the algorithm for resolving a path (step 2 above). Throw an error if this resolution fails.
77
77
For example, if the Haste package path for `'a/b'` is `foo/package.json`, perform step 2 as if _moduleName_ was `foo/c`.
78
-
6. If [`context.disableHierarchicalLookup`](#disableHierarchicalLookup-boolean) is not `true`, then
78
+
6. If [`context.enablePackageExports`](#enablepackageexports-boolean) is enabled, then
79
+
1. Get the result of [**PACKAGE_SELF_RESOLVE**](#package_self_resolve)(*context*, *moduleName*, *platform*).
80
+
2. If resolved, return result.
81
+
7. If [`context.disableHierarchicalLookup`](#disableHierarchicalLookup-boolean) is not `true`, then
79
82
1. Try resolving _moduleName_ under `node_modules` from the current directory (i.e. parent of [`context.originModulePath`](#originmodulepath-string)) up to the root directory.
80
83
2. Perform [**RESOLVE_PACKAGE**](#resolve_package)(*context*, *modulePath*, *platform*) for each candidate path.
81
-
7. For each element _nodeModulesPath_ of [`context.nodeModulesPaths`](#nodemodulespaths-readonlyarraystring):
84
+
8. For each element _nodeModulesPath_ of [`context.nodeModulesPaths`](#nodemodulespaths-readonlyarraystring):
82
85
1. Try resolving _moduleName_ under _nodeModulesPath_ as if the latter was another `node_modules` directory (similar to step 5 above).
83
86
2. Perform [**RESOLVE_PACKAGE**](#resolve_package)(*context*, *modulePath*, *platform*) for each candidate path.
84
-
8. If [`context.extraNodeModules`](#extranodemodules-string-string) is set:
87
+
9. If [`context.extraNodeModules`](#extranodemodules-string-string) is set:
85
88
1. Split _moduleName_ into a package name (including an optional [scope](https://docs.npmjs.com/cli/v8/using-npm/scope)) and relative path.
86
89
2. Look up the package name in [`context.extraNodeModules`](#extranodemodules-string-string). If found, then
87
90
1. Construct a path _modulePath_ by replacing the package name part of _moduleName_ with the value found in [`context.extraNodeModules`](#extranodemodules-string-string)
88
91
2. Return the result of [**RESOLVE_PACKAGE**](#resolve_package)(*context*, *modulePath*, *platform*).
89
-
9. If no valid resolution has been found, throw a resolution failure error.
92
+
10. If no valid resolution has been found, throw a resolution failure error.
2. Else, log either a package configuration or package encapsulation warning.
111
114
2. Return the result of [**RESOLVE_MODULE**](#resolve_module)(*context*, *filePath*, *platform*).
112
115
116
+
#### PACKAGE_SELF_RESOLVE
117
+
118
+
Parameters: (*context*, *moduleName*, *platform*)
119
+
120
+
1. Find the closest package to [`context.originModulePath`](#originmodulepath-string). If no package is found, return no resolution.
121
+
2. If the package does not declare both a `"name"` field and an `"exports"` field, return no resolution.
122
+
3. Split _moduleName_ into a package name (including an optional [scope](https://docs.npmjs.com/cli/v8/using-npm/scope)) and relative path.
123
+
4. If the package name does not match the current package's `"name"` field, return no resolution.
124
+
5. Get the result of [**RESOLVE_PACKAGE_EXPORTS**](#resolve_package-exports)(*context*, *packagePath*, *filePath*, *exportsField*, *platform*) against the current package's `"exports"` field.
125
+
1. If resolved path exists, return result.
126
+
2. Else, log either a package configuration or package encapsulation warning, then continue with normal resolution.
0 commit comments