Skip to content

Commit

Permalink
update readme links
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickkettner committed Nov 7, 2024
1 parent bbc95aa commit 62b1105
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion functional-samples/libraries-xhr-in-sw/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This sample demonstrates how to use code that relies on XHR within a extension's

The default background environment for extensions is the service worker. As a result, it only has direct access to [Fetch](https://developer.mozilla.org/docs/Web/API/Fetch_API/Using_Fetch). If you want to use a library that is built with XHR, this will not work by default. However, you can usually monkeypatch the expected behavior by polyfilling XHR. This sample shows an example of how you can use build tools to automatically inject a polyfill for XHR that covers most common XHR use cases, allowing for seamless integration into your extension.

In this sample, we are using a "library" that exports a function called [`fetchTitle`](./src/lib/fetchTitle.js). For the fiction of this sample, this is a dependency we _must_ use, but we are unable to change ourselves. Unfortunately, it uses XHR. In order to make this work, we [import](./src/index.js#L1) a [shim](./src/lib/xhr-shim.js), and then [set the global `XMLHttpRequest` to it](./src/index.js#L4).
In this sample, we are using a "library" that exports a function called [`fetchTitle`](./third_party/fetchTitle.js). For the fiction of this sample, this is a dependency we _must_ use, but we are unable to change ourselves. Unfortunately, it uses XHR. In order to make this work, we [import](./background.js#L1) a [shim](./third_party/xhr-shim/xhr-shim.js), and then [set the global `XMLHttpRequest` to it](./background.js#L4).

This is all packaged by a build system, in this case [Rollup](https://rollupjs.org/).

This comment has been minimized.

Copy link
@sebastianbenz

sebastianbenz Nov 7, 2024

Collaborator

Maybe link to the rollup file here.


Expand Down

0 comments on commit 62b1105

Please sign in to comment.