esbuild-plugin-cache

Esbuid plugin to use cache for http/https

MIT 11 个版本
安装
npm install esbuild-plugin-cache
yarn add esbuild-plugin-cache
pnpm add esbuild-plugin-cache
bun add esbuild-plugin-cache
README

esbuild-plugin-cache

Esbuid plugin to cache http/https imports.

The plugin allows to use http/https imports without installing npm packages on node_modules.

It also allows to use import-maps .

It can provide a feature similar to Snowpack 3.0, the new Streaming NPM Imports, which allows to skip the NPM install and node_modules.

//index.js
import React from 'https://cdn.skypack.dev/react@17.0.1'
console.log(React.version)

Build script:

//build.js
import esbuild from 'esbuild'
import { cache } from 'esbuild-plugin-cache'

esbuild
  .build({
    entryPoints: ['index.js'],
    bundle: true,
    outfile: 'bundle.js',
    plugins: [cache()],
  })
  .catch(() => process.exit(1))

Config:

config: {importmap: {imports:{[key: string]: string}}, directory: string}

  • importmap: Import-map object. Default: {}

  • directory: Path or name for the directory of the cache. Default to Deno cache directory. Optionally the cache directory can be defined with DENO_DIR env variable: process.env.DENO_DIR = 'cache'.

Using with importmap

//index.js
import React from 'react'
console.log(React.version)
//build.js
import esbuild from 'esbuild'
import { cache } from 'esbuild-plugin-cache'

const importmap = {
  imports: {
    react: 'https://cdn.skypack.dev/react@17.0.1',
  },
}

esbuild
  .build({
    entryPoints: ['index.js'],
    bundle: true,
    outfile: 'bundle.js',
    plugins: [cache({ importmap, directory: './cache' })],
  })
  .catch(() => process.exit(1))
版本列表
0.2.10 2022-11-23
0.2.9 2021-06-10
0.2.8 2021-05-21
0.2.7 2021-05-21
0.2.6 2021-05-02
0.2.5 2021-04-13
0.2.4 2021-04-13
0.2.3 2021-04-13
0.2.2 2021-04-13
0.2.1 2021-01-15
0.2.0 2021-01-08