Closed digitalsadhu closed 11 months ago
What is the purpose of isFallback
? What's its use case?
What is the purpose of
isFallback
? What's its use case?
There's was no easy way to know when the client "fell back" once outside the content resolver as it transparently replaces the content with the fallback content. I thought initially that the success
property would do that but success
is always true regardless of whether the content ends up being content or fallback.
So once outside the content resolver, in resource.js isFallback
gives us a way to work out how to do the filtering of the assets, either content or fallback.
const { manifest, headers, redirect, isFallback } = await this[_resolver].resolve(outgoing);
return new Response({
...
css: utils.filterAssets(isFallback ? "fallback" : "content", manifest.css),
js: utils.filterAssets(isFallback ? "fallback" : "content", manifest.js),
...
});
The only other options I tried (and don't really like) is to modify the actual manifest object on the outgoing object while still inside the content resolver (before returning the outgoing object to the resolver)
outgoing.manifest.js = utils.filterAssets("content", outgoing.manifest.js);
outgoing.manifest.css = utils.filterAssets("content", outgoing.manifest.css);
This modifies the js and css arrays in place but broke a bunch of tests because in some case the beforeStream events were suddenly wrong, I think because they are events and were happening out of order.
:tada: This PR is included in version 4.6.0 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
:tada: This PR is included in version 5.0.0-next.14 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
This PR implements asset filtering in the Podium client based on the new asset scope field as added in this PR https://github.com/podium-lib/utils/pull/212
TODO:
The details
beforeStream
event was not being emitted when the client falls back. With this change beforeStream is emitted when using the .stream() method but as a side effect, it is also being emitted when .fetch() is being called although it seems unlikely anyone would use this or even notice.