vite-plugin-fastly-js-compute

raw JSON →
0.4.2 verified Mon Apr 27 auth: no javascript

Vite plugin for Fastly Compute environments that provides Fastly Compute global variables and classes (like `fastly:xxx` imports) for use in Vite and Vitest. Current stable version: 0.4.2. Release cadence: occasional updates. Key differentiators: bridges the gap between Vite/Vitest and Fastly Compute's runtime-specific globals, enabling testing with Vitest. Supports TypeScript and ESM.

error Cannot find module 'vite-plugin-fastly-compute-js' or its corresponding type declarations.
cause Typo in package name: vite-plugin-fastly-compute-js instead of vite-plugin-fastly-js-compute.
fix
Install and import the correct package: npm install -D vite-plugin-fastly-js-compute and import from 'vite-plugin-fastly-js-compute'.
error TypeError: fastlyCompute is not a function
cause Using require() which returns an object (ESM default export is under .default).
fix
Use ESM import: import fastlyCompute from 'vite-plugin-fastly-js-compute'.
gotcha Import path error: 'vite-plugin-fastly-compute-js' vs 'vite-plugin-fastly-js-compute'
fix Use correct package name: vite-plugin-fastly-js-compute.
gotcha CommonJS require not supported; ESM only.
fix Use ESM import syntax (import fastlyCompute from '...').
deprecated No known deprecated features yet.
fix N/A
npm install vite-plugin-fastly-js-compute
yarn add vite-plugin-fastly-js-compute
pnpm add vite-plugin-fastly-js-compute

Example vitest.config.ts that uses the plugin to provide Fastly Compute globals in tests.

// vitest.config.ts
import { defineConfig } from 'vitest/config';
import fastlyCompute from 'vite-plugin-fastly-js-compute';

export default defineConfig({
  plugins: [fastlyCompute()],
  test: {
    // ...
  },
});