parcel-plugin-prefetch
v1.3.0
Published
Write some JSON to prefetch data in bundle.
Downloads
27
Readme
parcel-plugin-prefetch
Write some JSON to prefetch data in bundle.
How to use
yarn add parcel-plugin-prefetch
- Create JSON file with extension
.jsonpf
- JSON should be a list in the format...
[{
"key": "foo",
"url": "https://..."
}]
- Add
import {foo, STATES} from "./data.jsonpf"
to the top of file. yarn parcel index.html
or whatever you use.- Parcel will prefetch the data and return data in below format.
{
foo: {
key: "foo",
url: "https://...",
state: "FETCHING" // FAILED || FETCHED
data: {} // Data returned if "FETCHED"
error: Error // Error returned if "FAILED"
},
// States for comparison.
STATES: {
FETCHING: "FETCHING",
FETCHED: "FETCHED",
FAILURE: "FAILURE"
}
}
Missing data?
Try running with --no-cache
.