@prpl/plugin-cache
TypeScript icon, indicating that this package has built-in type declarations

0.3.0 • Public • Published

@prpl/plugin-cache (WIP)

NOTE - This plugin is experimental. It may change significantly in the future. Not recommended for use at present.

A plugin for PRPL for cache manipulation. Useful for defining cache partitions that subsequent plugins may access.

Dependencies

@prpl/plugin-cache has zero dependencies.

Usage

For example, you may want to pre-define a partition that reads all HTML and CSS files in dist so that those files can be accessed in memory:

import { resolve } from 'path';
import { interpolate, PRPLCachePartitionKey } from '@prpl/core';
import { createCachePartition } from '@prpl/plugin-cache';
import { resolveHTMLImports } from '@prpl/plugin-html-imports';
import { resolveCSSImports } from '@prpl/plugin-css-imports';

await interpolate();

// Pre-define dist partition and use for subsequent plugins
await createCachePartition({
  entityPath: resolve('dist'),
  partitionKey: PRPLCachePartitionKey.dist,
  readFileRegExp: new RegExp(`.html|.css`)
});

await resolveHTMLImports({
  cachePartitionKey: PRPLCachePartitionKey.dist
});

await resolveCSSImports({
  cachePartitionKey: PRPLCachePartitionKey.dist
});

By doing this, we save each plugin from generating its own partition that reads from the file system. All plugins that interact with the cache should return the cache as an artifact that can be conveniently inspected.

Package Sidebar

Install

npm i @prpl/plugin-cache

Weekly Downloads

0

Version

0.3.0

License

MIT

Unpacked Size

3.5 kB

Total Files

5

Last publish

Collaborators

  • tyhopp