sindresorhus / import-fresh

Import a module while bypassing the cache
MIT License
283 stars 24 forks source link

Transparent module.parent #5

Closed mightyiam closed 5 years ago

mightyiam commented 7 years ago

Issuehunt badges

module.parent in module required by requireUncached will be the [...]/require-uncached/index.js module.

Can we please fix it to be the parent of that? Meaning, the module.parent.parent? I think it makes sense.


IssueHunt Summary #### [stroncium stroncium](https://issuehunt.io/u/stroncium) has been rewarded. ### Backers (Total: $80.00) - [issuehunt issuehunt](https://issuehunt.io/u/issuehunt) ($80.00) ### Submitted pull Requests - [#13 Make parent transparent](https://issuehunt.io/r/sindresorhus/import-fresh/pull/13) --- ### Tips - Checkout the [Issuehunt explorer](https://issuehunt.io/r/sindresorhus/import-fresh/) to discover more funded issues. - Need some help from other developers? [Add your repositories](https://issuehunt.io/r/new) on IssueHunt to raise funds. --- IssueHunt has been backed by the following sponsors. [Become a sponsor](https://issuehunt.io/membership/members)
sindresorhus commented 7 years ago

👍 Pull request welcome :)


Note: This issue has a bounty, so it's expected that you are an experienced programmer and that you give it your best effort if you intend to tackle this. Don't forget, if applicable, to add tests, docs (double-check for typos), and update TypeScript definitions. And don't be sloppy. Review your own diff multiple times and try to find ways to improve and simplify your code. Instead of asking too many questions, present solutions. The point of an issue bounty is to reduce my workload, not give me more. Include a 🦄 in your PR description to indicate that you've read this. Thanks for helping out 🙌 - @sindresorhus

mightyiam commented 7 years ago

Does anyone have a pointer for me?

sindresorhus commented 7 years ago

I think you could use Module._load (what require() uses) with a custom module entry to be able to set the parent. Another possible solution could be to modify require.cache.

issuehunt-oss[bot] commented 5 years ago

@issuehunt has funded $80.00 to this issue.


issuehunt-oss[bot] commented 5 years ago

@sindresorhus has rewarded $72.00 to @stroncium. See it on IssueHunt