core icon indicating copy to clipboard operation
core copied to clipboard

feat(fetch-hook): extending fetch hook usage

Open SapientMatt opened this issue 1 year ago • 5 comments

Description

Update to use the fetch hook, if specified, when fetching remoteEntries and chunks on node, in order to achieve similar effect to what was possible with webpackChunkLoad before.

Types of changes

  • [ ] Docs change / refactoring / dependency upgrade
  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [x] New feature (non-breaking change which adds functionality)

Checklist

  • [ ] I have added tests to cover my changes.
  • [x] All new and existing tests passed.
  • [ ] I have updated the documentation.

SapientMatt avatar Jan 29 '24 14:01 SapientMatt

This is a rather rough bare minimum proposal, that resolved the specifc issues I was having. Namely needing to switch out fetch for Axios, or just to extend fetch, when doing any ssr network calls. Updating to make the new strategies work with webpackChunkLoad would also work for me, but I thought extending the new hook was likely better.

SapientMatt avatar Jan 29 '24 14:01 SapientMatt

can you not use createScript hook?

ScriptedAlchemy avatar Jan 31 '24 23:01 ScriptedAlchemy

@zhoushaw any comments here?

ScriptedAlchemy avatar Jan 31 '24 23:01 ScriptedAlchemy

@ScriptedAlchemy I tried using createScriptHook initially, but it doesn't actually seem to be used on the node side of things. createScriptNode calls createScriptHook, but then only uses the result to reassign the url value, and then uses fetch to fetch that url. On the node generation side, httpVmStrategy uses the node http library with no apparent way to override either.

SapientMatt avatar Feb 01 '24 13:02 SapientMatt

If create script hook isnt working on node side then we should just need to ammend the source code so it does call the hook, dont think we need to add another api for this if we can make the existing one work node side

ScriptedAlchemy avatar Mar 27 '24 03:03 ScriptedAlchemy

Stale pull request message

github-actions[bot] avatar May 26 '24 15:05 github-actions[bot]