mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 20:32:10 +00:00
refactor(resolver): clean up some code and tests
This commit is contained in:
parent
f8358a148a
commit
909d037f0d
3 changed files with 25 additions and 6 deletions
|
|
@ -43,21 +43,21 @@ Crossed out test files are irrelevant.
|
|||
|
||||
- [x] ~CachedInputFileSystem.test.js~
|
||||
- [x] ~SyncAsyncFileSystemDecorator.test.js~
|
||||
- [x] alias.test.js (need to fix a todo)
|
||||
- [x] alias.test.js
|
||||
- [x] browserField.test.js (reading the browser field is currently static - not read from the `browserField` option)
|
||||
- [ ] dependencies.test.js
|
||||
- [x] exportsField.test.js
|
||||
- [x] extension-alias.test.js
|
||||
- [x] extensions.test.js
|
||||
- [x] fallback.test.js (need to fix a todo)
|
||||
- [x] fallback.test.js
|
||||
- [x] ~forEachBail.test.js~
|
||||
- [x] fullSpecified.test.js
|
||||
- [ ] getPaths.test.js
|
||||
- [x] ~getPaths.test.js~
|
||||
- [x] identifier.test.js (see unit test in `crates/oxc_resolver/src/request.rs`)
|
||||
- [x] importsField.test.js
|
||||
- [x] incorrect-description-file.test.js (need to add ctx.fileDependencies)
|
||||
- [ ] missing.test.js
|
||||
- [ ] path.test.js
|
||||
- [x] path.test.js (see unit test in `crates/oxc_resolver/src/path.rs`)
|
||||
- [ ] plugins.test.js
|
||||
- [ ] pnp.test.js
|
||||
- [x] ~pr-53.test.js~
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ pub struct PackageJson {
|
|||
///
|
||||
/// <https://nodejs.org/api/packages.html#subpath-imports>
|
||||
#[serde(default)]
|
||||
pub imports: MatchObject,
|
||||
pub imports: Box<MatchObject>,
|
||||
|
||||
/// The "browser" field is provided by a module author as a hint to javascript bundlers or component tools when packaging modules for client side use.
|
||||
///
|
||||
|
|
@ -71,7 +71,6 @@ impl ExportsField {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: use compact string for these String fields
|
||||
#[derive(Debug, PartialEq, Eq, Hash)]
|
||||
pub enum ExportsKey {
|
||||
Main,
|
||||
|
|
|
|||
|
|
@ -89,3 +89,23 @@ impl PathUtil for Path {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
// https://github.com/webpack/enhanced-resolve/blob/main/test/path.test.js
|
||||
#[test]
|
||||
fn is_invalid_exports_target() {
|
||||
let test_cases = [
|
||||
"../a.js",
|
||||
"../",
|
||||
"./a/b/../../../c.js",
|
||||
"./a/b/../../../",
|
||||
"./../../c.js",
|
||||
"./../../",
|
||||
"./a/../b/../../c.js",
|
||||
"./a/../b/../../",
|
||||
"./././../",
|
||||
];
|
||||
|
||||
for case in test_cases {
|
||||
assert!(Path::new(case).is_invalid_exports_target(), "{case}");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue