`pathFilter` (or some new API) should support implementations of `exports`
See original GitHub issueIn lieu of this module supporting exports
out of the box, it would be awesome if consumers could use its existing capabilities (packageFilter
, pathFilter
etc.) to implement support for exports
on the consumer side.
I have experimented a bit with this, and from what I can tell there are 2 issues:
resolve
addsindex
if a directory is specified (https://github.com/browserify/resolve/blob/f1b51848ecb7f56f77bfb823511d032489a13eab/lib/sync.js#L192). This can potentially cause issues in the caseindex
is not specified by the user as changing it to.
(which is what a directory means inexports
) is not necessarily a safe operation. Not sure how to mitigate this in a way that’s backwards compatible.- I tried to use
pathFilter
which works great forrequire('some-module/thing')
, but it doesn’t work forrequire('./some-thing')
from within a module. Relative imports within a module isn’t restricted byexports
, butpathFilter
cannot know if the resolution request is for a relative file or not. A solution here is maybe to include a flag saying if it’s relative within the package or not?
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:11 (11 by maintainers)
Top Results From Across the Web
[Feature]: Support package imports in jest-resolve #12270
Once a module implementing the algorithm exists (e.g. lukeed/resolve.exports#14) we should be good to go for adding support here.
Read more >Using the Incremental Exports API | Zendesk Developer Docs
You can use the Incremental Exports API to get items that changed or were created in Zendesk ... The other endpoints only support...
Read more >Configuring Jest
All modules used in your tests will have a replacement implementation, keeping the API surface. Example: utils.js. export default {
Read more >How can I export to a json file with more then 10000 records?
Solved: I try to use a powershell script to get data from a couple ... You can look at the following link which...
Read more >Export a REST API from API Gateway - AWS Documentation
Export an existing REST API from API Gateway to OpenAPI and other API definition ... Export API, which is part of the Amazon...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Right, it breaks a test, but I think that test is faulty (it imports a “local” module with a package.json with
exports
via a relative path, but that is not innode_modules
). I think that’s just wrong behavior, so it failing now is actually a bug fix and my old test was just bad 😅Might just roll this out behind a config flag and hope people test it and report instances where it behaves wrong (after adding more tests)
Ok, closing again 🙈 My solution is to pop of anything trailing after
pkg/
or@scope/pkg/
, add./package.json
and resolve that usingresolve
, and ifpackage.json
hasexports
resolve those with anything trailing (or.
if nothing), and return the full path. NopackageFilter
orpathFilter
at all. In theory a tiny bit faster as well as we head straight for thepackage.json
file and potentially shortcut instead of traversing and checking for file existence.(code is in above PR if this explanation made no sense, which it probably doesn’t)