Registry / web-framework / vite-plugin-cds

vite-plugin-cds

JSON →
library0.2.0jsnpmunverified

A Vite plugin for @sap/cds (CAP) that enables importing .cds model files, running cds watch with Vite, and using the @sap/cds runtime in the browser. Current version 0.2.0 supports @sap/cds ^9. Release cadence is irregular with multiple minor patches. Key differentiators: allows using Vite's HMR and bundling for CAP frontends, and enables running the CAP runtime inside the browser via polyfills. Requires peer dependency @sap/cds ^9.

npm install vite-plugin-cds
INSTALL
IMPORT
SIG · VITE-PLUGIN-CDS
V
vite-plugin-cds
web-frameworkjavascriptv0.2.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

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

cds
import { cds } from 'vite-plugin-cds'
import cds from 'vite-plugin-cds' or const cds = require('vite-plugin-cds')
Named export for the plugin factory. Default export is not provided.
node
import { node } from 'vite-plugin-cds'
import node from 'vite-plugin-cds'
Named export for the node polyfill plugin.
cap
import { cap } from 'vite-plugin-cds'
import cap from 'vite-plugin-cds'
Named export for the CAP runtime plugin.

Import a .cds model file in a Vite app using the plugin. The plugin compiles the model at build time.

// vite.config.js import { defineConfig } from 'vite' import { cds } from 'vite-plugin-cds' export default defineConfig({ plugins: [cds()], root: './app', }) // In your JavaScript file: import cdsModel from './index.cds' console.log(cdsModel) // compiled CSN object
Debug
Known issues
breakingThe plugin is designed for Vite 5+; compatibility with older Vite versions is not guaranteed.
fix
Use Vite 5 or later.
affects: >=0.1.0
deprecatedThe 'minify: false' option was removed in v0.1.10; manual chunks configuration may be needed.
fix
If you need to disable minify, configure Vite's build.minify or use a custom rollup plugin.
affects: >=0.1.10
gotchaWhen using the CAP runtime in the browser, cds.context is not unique per request/transaction due to limited async context tracking.
fix
Avoid relying on cds.context for per-request state in browser usage.
affects: >=0.1.0
Errors
Common errors & fixes
Cannot find module '@sap/cds'
@sap/cds is not installed as a peer dependency.
fix
Run npm install @sap/cds
Uncaught TypeError: cds.compile is not a function
cds imported from wrong source or not initialized.
fix
Ensure you import cds from '@sap/cds', not from the plugin: import cds from '@sap/cds'
The requested module 'vite' does not provide an export named 'defineConfig'
Vite is not installed or version mismatch.
fix
Run npm install vite@5
Upgrade
Version history
0.2.0latest on npm
Audit
Dependencies
@sap/cdsrequiredPeer dependency, provides the CDS runtime and compiler
Agent activity
8 hits · last 30 days
node
6
Bingbot
1
OpenAI (training)
1
Resources
vite-plugin-cds — npm install vite-plugin-cds · libregistry