Skip to content

NetworkResources

[<Interface>]
type NetworkResources =
    static member Create (put: Action<string,string>) : NetworkResources
    abstract member put (url: string, data: string) : unit
AssemblyXantham.Fable.Node
Attributes[<Interface>]

Methods

static member Create (put: Action<string,string>) : NetworkResources
abstract member put (url: string, data: string) : unit

This feature is only available with the --experimental-inspector-network-resource flag enabled.

The inspector.NetworkResources.put method is used to provide a response for a loadNetworkResource request issued via the Chrome DevTools Protocol (CDP). This is typically triggered when a source map is specified by URL, and a DevTools frontend—such as Chrome—requests the resource to retrieve the source map.

This method allows developers to predefine the resource content to be served in response to such CDP requests.

const inspector = require('node:inspector');
// By preemptively calling put to register the resource, a source map can be resolved when
// a loadNetworkResource request is made from the frontend.
async function setNetworkResources() {
const mapUrl = 'http://localhost:3000/dist/app.js.map';
const tsUrl = 'http://localhost:3000/src/app.ts';
const distAppJsMap = await fetch(mapUrl).then((res) => res.text());
const srcAppTs = await fetch(tsUrl).then((res) => res.text());
inspector.NetworkResources.put(mapUrl, distAppJsMap);
inspector.NetworkResources.put(tsUrl, srcAppTs);
};
setNetworkResources().then(() => {
require('./dist/app');
});

For more details, see the official CDP documentation: Network.loadNetworkResource

@since v22.19.0