node icon indicating copy to clipboard operation
node copied to clipboard

module: expose `resolveLoadAndCache` API

Open aduh95 opened this issue 1 year ago β€’ 2 comments

Opening as draft as I'd like to get some feedback on the API design first. /cc @nodejs/loaders

Use case for this is to get "final" format of the module that would result from importing a specific specifier. The cache part is primordial as otherwise you'd have no guarantee that the result would be accurate (if there's a user loader involved, we have no reason to believe it would be stable over time). However, caching a call that's sometimes async, sometimes sync is more or less impossible in JS, and on top of that there are loaders out there that rely on resolve NOT being cached (e.g the test runner .mock util), so instead I decided it'd be more useful to provide a way to skip the resolve call.

aduh95 avatar Nov 06 '24 19:11 aduh95

Review requested:

  • [ ] @nodejs/loaders

nodejs-github-bot avatar Nov 06 '24 19:11 nodejs-github-bot

Codecov Report

:x: Patch coverage is 89.58333% with 5 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 90.21%. Comparing base (c712dd2) to head (434cbf2). :warning: Report is 1622 commits behind head on main.

Files with missing lines Patch % Lines
lib/internal/modules/helpers.js 87.17% 5 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #55756      +/-   ##
==========================================
+ Coverage   89.66%   90.21%   +0.55%     
==========================================
  Files         630      630              
  Lines      186389   186437      +48     
  Branches    36286    36612     +326     
==========================================
+ Hits       167124   168198    +1074     
+ Misses      12049    11060     -989     
+ Partials     7216     7179      -37     
Files with missing lines Coverage Ξ”
lib/module.js 100.00% <100.00%> (ΓΈ)
lib/internal/modules/helpers.js 97.87% <87.17%> (-0.05%) :arrow_down:

... and 100 files with indirect coverage changes

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar Apr 11 '25 18:04 codecov[bot]