Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
route-manifest
Advanced tools
Readme
A tiny (412B) runtime to retrieve the correct entry from a Route Manifest file.
This is the runtime/client-side component for webpack-route-manifest
.
It is required that your manifest's routes be sorted by specificity, which is the webpack plugin's default setting.
Important: This
route-manifest
does not fetch files or apply headers on your behalf!
The module is available in three formats:
dist/rmanifest.mjs
dist/rmanifest.js
dist/rmanifest.min.js
$ npm install --save route-manifest
import { preload } from 'quicklink';
import rmanifest from 'route-manifest';
// Manually fetch Manifest file contents
fetch('/manifest.json').then(r => r.json()).then(data => {
/*
Assume Manifest (`data`) is:
{
[pattern]: {
files: { href: string, type: string }
headers: [...skip...]
}
}
*/
const files = new Set();
// We want to preload these pages' assets
['/blog', '/about', '/features'].forEach(str => {
let entry = rmanifest(data, str);
entry.files.forEach(x => files.add(x.href));
});
// Note:
// The `quicklink` module will do the actual prefetching!
// We just have have to give it a file path, or an array
// of file paths in this case~!
return preload([...files]);
});
Returns: { files: Array, headers: Array }
Returns an object containing files
and headers
keys, both of which will be arrays. The arrays' items are copied from your Manifest file directly, so you will (presumably) already know the shape of your data.
Type: Object
The Manifest file's contents.
Any format returned by webpack-route-manifest
is valid.
Important: The route pattern keys must be sorted for matching correctness.
Type: String
The URL for which you want to find files or headers.
Note: Only include the
pathname
segment of a URL, unless a pattern is explicitly looking for other segments.
Type: Boolean
Default: false
Whether or not the base/root-wildcard entry should be included.
When true
and when a "*"
pattern is defined, this will include the wildcard's entry in addition to the route's own specific entry too, if any. The result is still a single object of { files, headers }
shape – the difference is just that the two entries have their keys' items concatenated into a single array.
When false
, this module will only return the entry specific to the requested uri
pathname.
MIT © Luke Edwards
FAQs
A tiny (412B) runtime to retrieve the correct entry from a Route Manifest file
The npm package route-manifest receives a total of 9,464 weekly downloads. As such, route-manifest popularity was classified as popular.
We found that route-manifest demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.