https://github.com/ifyoumakeit/parcel-plugin-prefetch
Simple JSON to prefetch data in bundle.
https://github.com/ifyoumakeit/parcel-plugin-prefetch
Last synced: about 1 year ago
JSON representation
Simple JSON to prefetch data in bundle.
- Host: GitHub
- URL: https://github.com/ifyoumakeit/parcel-plugin-prefetch
- Owner: ifyoumakeit
- Created: 2018-02-25T20:11:53.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-02-25T21:37:06.000Z (over 8 years ago)
- Last Synced: 2025-03-06T01:11:50.146Z (over 1 year ago)
- Language: JavaScript
- Size: 50.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# parcel-plugin-prefetch
Write some JSON to prefetch data in bundle.
## How to use
`yarn add parcel-plugin-prefetch`
1. Create JSON file with extension `.jsonpf`
2. JSON should be a list in the format...
```json
[{
"key": "foo",
"url": "https://..."
}]
```
3. Add `import {foo, STATES} from "./data.jsonpf"` to the top of file.
4. `yarn parcel index.html` or whatever you use.
5. Parcel will prefetch the data and return data in below format.
```js
{
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`.