vite-plugin-cds
A CAP plugin that serves a Vite app from the app folder through cds watch, makes .cds files importable into the frontend build, and can polyfill enough of Node to run @sap/cds in the browser.
Installed as a dev dependency of a CAP project, it puts a Vite frontend under the same command as the service: a vite.config.js beside an index.html in app/ and cds watch serves that page through Vite. Its cds() plugin makes a .cds model file importable from frontend code, so a model reaches the browser as a module rather than through a build step written by hand. node() and cap() go further and polyfill enough of Node for @sap/cds@sap/cdsThe CAP Node.js runtime, which compiles the CDS model, serves the services declared in it, answers generic requests before any handler runs, and loads every cds-plugin.sap official, cap to run in the page itself: the README compiles a CSN model in the browser, deploys it to @cap-js/sqlite@cap-js/sqliteThe SQLite service, in memory during the inner loop — which is why a CAP project runs before anyone has provisioned a database.sap official, cap over SQLiteSQLiteAn embedded SQL database engine used as a selectable local cache store by CAP caching plugins. built to WebAssembly, and serves OData from an Express app the page calls directly. The README names the limitation of that browser runtime, that cds.context is not unique per request or transaction, and points at its own note on asynchronous context tracking.
Facts
Where it sits
Who is behind it
In the atlas: maintains 1, contributes to 28, wrote 10@AkatuoromaintainerChristian GeorgiContributes to this
In the atlas: maintains 1, contributes to 53@chgeo1 contributor
Before choosing this
Conditions
LicenceSAP Developer License Agreement 3.2 CAP§ 1, 2, 3A cds-plugin is used with SAP CAP materials, or an artifact is explicitly identified as a CAP plugin or application.
- § 1 License. Productive customer applications are limited to SAP BTP or another SAP-licensed platform, and mass extraction to a non-SAP product is restricted except where solely required for SAP interoperability.
- § 2 Intellectual Property. The agreement retains SAP's rights in the covered materials and limits making APIs, tools or software available to third parties, while preserving ownership of customer applications subject to SAP's underlying rights.
- § 3 Artificial Intelligence Training. The agreement prohibits use of the covered materials and customer applications for training artificial-intelligence models or systems.
What it declares
Every artifact
- Type
- CDS plugin
- Origin
- Independently maintained
- Runtime
- Node.js
As a CDS plugin
- Declared for
- >=9
- Distributed through
- npm
Connections
Running the whole stack on a laptop against real bindings
CAP Node.js runtime
A build tool and development server for web frontends. For the things here it is what bundles and serves a CAP project's frontend when a plugin brings the two under cds watch.
SQLite database service for CAP, in memory during development
An embedded SQL database engine used as a selectable local cache store by CAP caching plugins.
Download
Install
npm add vite-plugin-cdsDerived from the package name. No recipe recorded; the README has the configuration.
Where it sits in your app
Download
README
quoted from Akatuoro/vite-plugin-cds under MIT, readvite-plugin-cds
viteapps withcds watch- Import
.cdsmodel files in your vite app @sap/cdsin the browser
Usage
Prerequisite:
- This library has a peer dependency to @sap/cds.
Vite apps with cds watch
Install vite and this plugin as development dependencies in your CAP project.
npm install --save-dev vite vite-plugin-cds
Add a vite.config.js to any frontend application in the app/ folder of your CAP project.
app/
my-vite-app/
index.html
vite-config.js
The index.html is now served automatically via vite when you run:
cds watch
Import cds model files in your vite app
Add the cds plugin to your vite config.
// vite.config.js
import { defineConfig } from 'vite'
import { cds } from 'vite-plugin-cds'
export default defineConfig({
plugins: [ cds() ],
root: './',
})
In your vite app, you can now import cds model files.
import cdsModel from './index.cds';
cds in the browser
You need the following dependencies for a functional runtime:
npm install --save-dev vite vite-plugin-cds @sap/cds @cap-js/sqlite @sqlite.org/sqlite-wasm express
Configure the plugins in your vite config:
// vite.config.js
import { defineConfig } from 'vite'
import { node, cap } from 'vite-plugin-cds'
export default defineConfig({
plugins: [ node(), cap() ],
root: './',
})
In your frontend vite app, you can now compile a model and start the cds runtime:
import cds from '@sap/cds'
import sqlite from 'better-sqlite3'
import express from 'express';
//======= compile a csn model =======
const csn = cds.compile(`
entity my.Books {
key ID: Integer;
title: String
}
service CatalogService {
entity Books as projection on my.Books;
}`);
console.log(csn.definitions)
//======= start a cds server =======
await sqlite.initialized // wait for sqlite3-wasm to be ready (part of polyfill)
cds.model = cds.compile.for.nodejs (csn);
cds.db = await cds.connect.to('db');
await cds.deploy(csn).to(cds.db);
const app = express();
await cds.serve('all').from(csn).in(app);
const response = await app.handle({url: '/odata/v4/catalog/Books'}) // part of polyfill
console.log('response', response);
Known limitations:
cds.contextis not unique per request / transaction, see asynchronous context tracking
History
Notes
Now also fully functional in workers
Notes
Notes
improved support for ssr scenarios
Notes
fixed warnings, improved rolldown compatibility
Notes
vite8 support
Notes
Support for cds 9.8
Notes
removed
minify: false, added manual chunksNotes
handle custom db functions and approximate asynchronous context tracking
Notes
Notes
add csv loading
Notes
Use minify with esbuild
Notes
vite buildfor@sap/cdsin the browserNotes
cds.servein the browserNotes
Others providing
Compare all 15 on the Local development page →- abap2UI5 Playgroundabap2UI5 PlaygroundABAP in the editor on the left and the abap2UI5 app it builds on the right, both inside one browser tab: the framework is transpiled to JavaScript at build time and the class in the editor is compiled when Run is pressed.community org, abapIn-browser ABAP editor beside the abap2UI5 app it buildsfrom ABAP
- web-abap2UI5web-abap2UI5A build pipeline and the page it deploys: the abap2UI5 backend downported, transpiled to JavaScript and webpacked into one script that runs inside a browser tab, with no server and no SAP system behind it.community org, abapabap2UI5 transpiled to JavaScript and run in a browser tabfrom ABAP
- com.sap.cds:cds-feature-dev-dashboardcom.sap.cds:cds-feature-dev-dashboardA browser dashboard for a running CAP Java service that shows and manages its messaging, resilience and multitenancy state while developing, open to users with the cds.Developer role.sap official, capBrowser dashboard for a running CAP Java service during developmentfrom CAP
- com.sap.cds:cds-maven-plugincom.sap.cds:cds-maven-pluginThe Maven plugin that runs CDS build steps in a CAP Java project: compiling the model, generating typed Java accessor interfaces and adding facets to an existing project.sap official, capMaven plugin running CDS build steps in a CAP Java projectfrom CAP
- @cap-js-community/common@cap-js-community/commonSix independent features for CAP services in one package: replication cache, migration check, rate limiting, a Redis client broker, a local HTML5 repository and a CDM builder.community org, capSix CAP features in one package, from replication cache to rate limitsfrom CAP
- abap_trial_dockerabap_trial_dockerShell scripts that build a Docker image from the SAP NetWeaver ABAP Developer Edition 7.52 SP04 installation files and run it as an unprivileged container, setting the stable hostname the installer wants.independent, abapScripts running the ABAP Developer Edition in Dockerfrom ABAP
- @neoimpulse/cap-js-bootstrap@neoimpulse/cap-js-bootstrapA command-line tool that starts a local CAP environment with several services and an AppRouter together from one command, documented in German and requiring Node 22 or newer.independent, capCLI starting several CAP services and an AppRouter locally togetherfrom CAP
- open-steamgateopen-steamgateAn ABAP application server you clone and run on your own machine: transpiled ABAP serving classic /IWBEP/ OData v2 to Fiori over a local database, with no SAP system attached.independent, abapLocal ABAP server serving /IWBEP/ OData v2 without an SAP systemfrom ABAP
- pokrakam/abapDevSysInitpokrakam/abapDevSysInitA single ABAP report that automates setting up a new ABAP Developer Edition or trial system, from the user profile and a GitHub RFC destination to fetching abapGit and pulling repositories.independent, abapABAP report setting up a new ABAP Developer Edition or trial systemfrom ABAP
- @sang2x/captools@sang2x/captoolsA CLI of eight CAP development commands aimed at Cloud Foundry workflows, shipped without a repository or README, whose binding step writes resolved VCAP_SERVICES into default-env.json.independent, capCLI of CAP development tools for Cloud Foundry workflowsfrom CAP
- @sap/ams-dev@sap/ams-devCompiles the DCL authorization policies of SAP's Authorization Management Service to DCN, so an AMS-secured application runs and is tested on a laptop.sap official, capCompiler from AMS DCL policies to DCN for local runs and testsfrom CAP
- @sap/cds-dk@sap/cds-dkThe command line client and development toolkit for CAP projects, with the commands cds build, cds deploy, cds watch and cds add among them.sap official, capCommand line client and development toolkit for CAPfrom CAP
- @sap/cds@sap/cdsThe CAP Node.js runtime, which compiles the CDS model, serves the services declared in it, answers generic requests before any handler runs, and loads every cds-plugin.sap official, capCAP Node.js runtimefrom CAP
- dev-approuterdev-approuterA development-time wrapper for the SAP Application Router that serves UI5 and CDS modules once they are added to the project as dependencies.community org, capDev-time wrapper for the SAP Application Routerfrom CAP
Details
Sources
Sources are graph entities: the same page may back several entries, and an unreachable source flags every row that rests on it.
Compatibility and provenance
Contributors
History in the atlas
- First seen.
For your agent
- Ref
artifact:akatuoro-vite-plugin-cds- JSON
- /artifacts/akatuoro-vite-plugin-cds.json
- MCP
- Connecting an agent