-
Notifications
You must be signed in to change notification settings - Fork 634
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add warning for invalid "exports" targets and import specifier "expor…
…ts" pattern matches Summary: Implements checks to validate allowed subpath segments during `"exports"` resolution, when `unstable_enablePackageExports` is set. Changelog: [Internal] Reviewed By: motiz88 Differential Revision: D43348624 fbshipit-source-id: a37dc0e182ef4a86fee86ffe5649e9a602e3476d
- Loading branch information
1 parent
0ecd442
commit 4785644
Showing
4 changed files
with
151 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
packages/metro-resolver/src/errors/InvalidModuleSpecifierError.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow strict | ||
* @format | ||
* @oncall react_native | ||
*/ | ||
|
||
export default class InvalidModuleSpecifierError extends Error { | ||
/** | ||
* Either the import specifier read, or the absolute path of the module being | ||
* resolved (used when import specifier is externally remapped). | ||
*/ | ||
importSpecifier: string; | ||
|
||
/** | ||
* The description of the error cause. | ||
*/ | ||
reason: string; | ||
|
||
constructor( | ||
opts: $ReadOnly<{ | ||
importSpecifier: string, | ||
reason: string, | ||
}>, | ||
) { | ||
super( | ||
`Invalid import specifier ${opts.importSpecifier}.\nReason: ` + | ||
opts.reason, | ||
); | ||
Object.assign(this, opts); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters