Commit graph

84 commits

Author SHA1 Message Date
Boshen
4fa6aafa3e
feat(resolver): handle path alias with # (#739)
`#` can be:

* an actual path fragment `path#fragment`
* esm import module specifier `#import-path`
* part of a path `path/to/#/fragment`
* part of path alias `#` -> `./path/alias`

This is driving me crazy.
2023-08-14 15:04:09 +08:00
Boshen
7c3e29d421
feat(resolver): expose raw package_json value; improve print debug (#738) 2023-08-14 11:57:17 +08:00
Boshen
f6e3b654b1
feat(resolver): implement configurable exports_fields option (#733) 2023-08-14 10:18:57 +08:00
Boshen
37efbd7af3
feat(resolver): resolve # as path instead of a fragment (#727) 2023-08-12 23:51:37 +08:00
Boshen
9935eb1259 feat(resolver): pass on query string from alias fields 2023-08-11 19:46:57 +08:00
Boshen
17e525cc0f feat(resolver): complete browser_field implementation 2023-08-11 19:46:57 +08:00
Boshen
fdf288c685
refactor: improve code coverage in various places (#721) 2023-08-11 15:17:49 +08:00
Boshen
8c7109b24e
feat(resolver): check for infinite recursion (#714) 2023-08-11 12:53:42 +08:00
Boshen
17a6f63c31
refactor(resolver): remove the leading dot trim on extensions 2023-08-10 21:05:48 +08:00
Boshen
11954326b3 feat(resolver): implement main_fields 2023-08-10 19:48:30 +08:00
Boshen
f717cb02e3 feat(resolver): add exports_fields and main_fields for logging purposes. 2023-08-10 19:48:30 +08:00
Boshen
caf1dfbfcd fix(resolver): fix a case where package name and specifier is the wrong order 2023-08-10 19:48:30 +08:00
Boshen
66c9d764d1 fix(resolver): add a case with multi-dot filename 2023-08-10 19:48:30 +08:00
Boshen
9714e46a02
feat(resolver): add tracing (#710) 2023-08-10 13:51:28 +08:00
Boshen
909d037f0d
refactor(resolver): clean up some code and tests 2023-08-09 23:21:03 +08:00
Boshen
17acbc4e02
fix(resolver): add derive to serde 2023-08-09 21:53:19 +08:00
Boshen
08a9ba3d5e
refactor(resolver): clean up the tests a little bit 2023-08-09 21:21:56 +08:00
Boshen
fdded5e97c
refactor(resolver): remove the identity-hash crate 2023-08-09 19:01:26 +08:00
Boshen
341c678b2f
fix(resolver): fix a case with multi-dot file extensions (#704) 2023-08-09 18:31:17 +08:00
Boshen
09761b4f8b
refactor(resolver): add a EnforceExtension tri state 2023-08-09 16:49:34 +08:00
Boshen
7c5ff9e27d
refactor(resolver): make Resolution::full_path not owned 2023-08-09 16:03:07 +08:00
Boshen
91fd375a3b
refactor(resolver): return package json error immediately instead of saving it (#702)
The error is propagated so there is no need to save it.
2023-08-09 14:28:44 +08:00
Boshen
f5b8690309
refactor(resolver): improve code by looking at the code coverage (#697) 2023-08-08 15:44:37 +08:00
Boshen
f4ba5d48e6
feat(resolver): implement recursive alias, file as alias and exports field with query / fragment (#695) 2023-08-07 21:10:49 +08:00
Boshen
9b2d3fce6b
feat(resolver): implement resolveToContext (#694) 2023-08-07 14:30:32 +08:00
Boshen
59f5dc1906
feat(resolver): implement restrictions (path only) (#693) 2023-08-07 13:50:42 +08:00
Boshen
3bfa314e95
refactor(resolver): clean some code (#692) 2023-08-06 21:42:54 +08:00
Boshen
658ef676f6
feat(resolver): implement the basics of ESM (#691) 2023-08-05 22:04:57 +08:00
Boshen
d21307827d
feat(resolver): implement fully specified (#687)
This is for turning off ESM's forced extension functionality.
2023-08-04 17:50:43 +08:00
Boshen
702d5b0120
refactor(resolver): change internal funcs to non-pub by moving to unit tests (#682) 2023-08-02 16:24:16 +08:00
Boshen
2e3934db49
feat(resolver): imports field (#681) 2023-08-02 15:54:07 +08:00
Boshen
c4669e1f78
feat(resolver): finish most of exports field (#674)
Found a behaviour mismatch: when an array is provided in exports field,
enhanced-resolve will try to read the file and try the next one if it
fails. But in the spec, the path is not read, it's only tested against
"invalid package target".

```
For each item targetValue in target, do
1. Let resolved be the result of PACKAGE_TARGET_RESOLVE( packageURL, targetValue, patternMatch, isImports, conditions), continuing the loop on any Invalid Package Target error.
2. If resolved is undefined, continue the loop.
3. Return resolved.
```

I tested against node.js and verifies node.js conforms to the spec.
2023-08-01 15:53:31 +08:00
Boshen
3b9cc474e9
feat(resolver): port the rest of the exports field tests (#659) 2023-07-30 01:03:10 +08:00
Boshen
6631336f5c
feat(resolver): implement more of exports field (#648) 2023-07-28 10:19:29 +08:00
Boshen
d587065436
chore(rust): update crate info, add minimal rust-version, add categories 2023-07-27 13:33:18 +08:00
Boshen
b34ef4f07a chore: reformat 2023-07-27 13:11:46 +08:00
Boshen
32b8ad2b57
feat(resolver): initialize implementation of package.json exports field (#630) 2023-07-26 16:54:54 +08:00
Boshen
b78b1ebdca
perf(resolver): reduce memory allocation when resolving node_modules (#608) 2023-07-25 20:06:44 +08:00
Boshen
f094d5881e
perf(resolver): hash once for the get + insert case (#606) 2023-07-25 16:47:17 +08:00
Boshen
1d7f171309
refactor(resolver): use DashSet for the cache (#605) 2023-07-25 15:17:07 +08:00
Boshen
5b23ab30b0
perf(resolver): allocate less when resolving extensions (#603) 2023-07-24 21:04:44 +08:00
Boshen
eafad4dfd1
perf(resolver): reduce the total number of hashes by passing the cached value around (#602) 2023-07-24 20:42:09 +08:00
Boshen
3cda165af7
perf(resolver): do not read package_json of a file (#601) 2023-07-24 15:49:41 +08:00
Boshen
b21b3b8528
chore(resolver): add a alias test and check resolution is the same in benchmark (#600) 2023-07-24 15:35:10 +08:00
Boshen
b3d70c5c7f
refactor(resolver): make the global cache hold less memory (#593) 2023-07-24 00:15:42 +08:00
Boshen
8ab2a7f322
refactor(resolver): improve browser_field lookup (#592)
This makes everything slow because every file read now needs to
check package.json for the browser field, but we'll improve the
package.json look up soon by reusing the values from the cache.
2023-07-23 23:41:27 +08:00
Boshen
65f22f9ba1
refactor(resolver): s/request_str/request 2023-07-23 20:06:17 +08:00
Boshen
cfdeb3416d
chore(resolver): improve documentation (#591) 2023-07-23 18:48:51 +08:00
Boshen
c0d06c5598
feat(resolver): check for directory before loading a directory (#590) 2023-07-23 18:10:06 +08:00
Boshen
53242c0e51
refactor(resolver): improve how browser field is resolved (#589) 2023-07-23 17:57:03 +08:00