Registry / devops / vite-plugin-fastly

vite-plugin-fastly

JSON →
library0.2.0jsnpmunverified

Seamlessly integrates Vite with Fastly Compute for serverless edge deployments. Version 0.2.0 is the current release, requiring Node 22+ (including 24-26), Vite ~7.3 or 8, and @fastly/js-compute 3. This plugin extends Vite's build pipeline to support Fastly's compute environment, enabling developers to use Vite's dev server, HMR, and optimized builds for edge functions. It leverages the Viceroy local testing tool and Fastly's JS SDK, differentiating from generic vite plugins by providing Fastly-specific configurations, such as handling edge runtime APIs and output formats for @fastly/js-compute.

npm install vite-plugin-fastly
INSTALL
IMPORT
SIG · VITE-PLUGIN-FASTLY
V
vite-plugin-fastly
devopsjavascriptv0.2.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import vitePluginFastly from 'vite-plugin-fastly'
import { vitePluginFastly } from 'vite-plugin-fastly'
The plugin is a default export; named import will result in undefined.
FastlyComputeOptions
import type { FastlyComputeOptions } from 'vite-plugin-fastly'
import { FastlyComputeOptions } from 'vite-plugin-fastly' (without type keyword)
Type-only export; import as type to avoid runtime errors.
require
const vitePluginFastly = require('vite-plugin-fastly')
const { vitePluginFastly } = require('vite-plugin-fastly')
CommonJS require uses default require, not destructured.

Minimal Vite config using vite-plugin-fastly with required Fastly credentials and compute settings.

import { defineConfig } from 'vite'; import vitePluginFastly from 'vite-plugin-fastly'; export default defineConfig({ plugins: [ vitePluginFastly({ applicationId: process.env.FASTLY_APPLICATION_ID ?? '', serviceId: process.env.FASTLY_SERVICE_ID ?? '', personalAccessToken: process.env.FASTLY_API_TOKEN ?? '', backend: 'my_backend', compute: { name: 'my-edge-app', language: 'javascript' } }) ] });
Debug
Known issues
breakingRequires Node 22 or later. Older Node versions are not supported.
fix
Upgrade Node to 22+ or use an older version of the plugin if available.
affects: <0.2.0
deprecatedThe 'backend' option is deprecated in favor of 'backends' array.
fix
Replace 'backend' with 'backends' as an array of backend configurations.
affects: >=0.1.0 <0.2.0
gotchaPlugin must be placed after other Vite plugins that modify module resolution (e.g., vite-plugin-pwa) to avoid conflicts.
fix
Order vite-plugin-fastly last in the plugins array.
affects: >=0.0.0
gotchaUsing CommonJS require may cause type issues with TypeScript projects; prefer ESM imports.
fix
Use import syntax or configure TypeScript to allow CommonJS interop.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module '@fastly/js-compute'
Missing or incorrect peer dependency @fastly/js-compute.
fix
Install @fastly/js-compute: npm install @fastly/js-compute@3
TypeError: vitePluginFastly is not a function
Using named import instead of default import.
fix
Use default import: import vitePluginFastly from 'vite-plugin-fastly'
PluginValidationError: Plugin must export a function
Wrong import pattern or version mismatch. Plugin expects a function after import.
fix
Ensure you use the default export and that the plugin version matches Vite version requirements.
SyntaxError: Unexpected token 'export' in Node.js
Using ESM syntax without setting type: 'module' in package.json or using .mjs extension.
fix
Add 'type': 'module' to package.json or rename file to .mjs.
Upgrade
Version history
0.2.0latest on npm
Audit
Dependencies
@fastly/js-computerequiredRequired peer dependency: provides the JavaScript runtime and WASM compilation for Fastly Compute.
viterequiredRequired peer dependency: this plugin is a Vite extension.
Agent activity
6 hits · last 30 days
node
6
Resources
vite-plugin-fastly — npm install vite-plugin-fastly · libregistry