Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@jcayzac/astro-build-cache

Package Overview
Dependencies
Maintainers
0
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jcayzac/astro-build-cache

Persistent build cache for artifacts you generate during an SSG Astro build (social images, etc).

  • 0.1.10
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
14
increased by366.67%
Maintainers
0
Weekly downloads
 
Created
Source

@jcayzac/astro-build-cache

This module provides a simple build cache for artifacts you may be generating during an Astro build.

As with Astro's own build artifacts, the cache is stored under node_modules/.astro where it can be easily ignored by version control systems and cached by cloud providers.

$ ls -1 node_modules/.astro/
assets
build-cache.development     # dev cache
build-cache.development-shm
build-cache.development-wal
build-cache.production      # prod cache
build-cache.production-shm
build-cache.production-wal
bundle
chunks
content
data-store.json

To clear the cache, simply delete node_modules/.astro/build-cache.*.

Installation

# pnpm
pnpm add @jcayzac/astro-build-cache

# bun
bunx add @jcayzac/astro-build-cache

# npm
npx add @jcayzac/astro-build-cache

# yarn
yarn add @jcayzac/astro-build-cache

# deno
deno add npm:@jcayzac/astro-build-cache

Usage

import { Cache } from '@jcayzac/astro-build-cache'

// Create a cache instance. Name is optional. Values are scoped by name.
const { cached } = new Cache('name')

// Now you can get values, with cache support, from anywhere.
const value = cached<Uint8Array>(
  // keyable material
  {
    format: 'png',
    options,
    fonts,
    element: serializeJsx(node),
  },
  // generator
  async () =>
  new Resvg(
    (await satori(node, options)),
    {
      fitTo: {
          mode: 'width',
          value: options.width,
      },
    },
  )
    .render()
    .asPng(),
)

[!TIP] To avoid any build error when using this module, you should add it to the list of externalized packages:

// astro.config.mjs
export default defineConfig({
  /* ...other options... */
  vite: {
    build: {
      rollupOptions: {
        external: [
          '@jcayzac/astro-build-cache',
        ],
      },
    }
  },
})

Like it? Buy me a coffee!

If you like anything here, consider buying me a coffee using one of the following platforms:

GitHub Sponsors Revolut Wise Ko-Fi PayPal

Keywords

FAQs

Package last updated on 06 Oct 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc