{"id":22601,"library":"vite-plugin-cds","title":"Vite Plugin for SAP CDS","description":"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.","status":"active","version":"0.2.0","language":"javascript","source_language":"en","source_url":"https://github.com/Akatuoro/vite-plugin-cds","tags":["javascript","vite","plugin","cap","cds"],"install":[{"cmd":"npm install vite-plugin-cds","lang":"bash","label":"npm"},{"cmd":"yarn add vite-plugin-cds","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-plugin-cds","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency, provides the CDS runtime and compiler","package":"@sap/cds","optional":false}],"imports":[{"note":"Named export for the plugin factory. Default export is not provided.","wrong":"import cds from 'vite-plugin-cds' or const cds = require('vite-plugin-cds')","symbol":"cds","correct":"import { cds } from 'vite-plugin-cds'"},{"note":"Named export for the node polyfill plugin.","wrong":"import node from 'vite-plugin-cds'","symbol":"node","correct":"import { node } from 'vite-plugin-cds'"},{"note":"Named export for the CAP runtime plugin.","wrong":"import cap from 'vite-plugin-cds'","symbol":"cap","correct":"import { cap } from 'vite-plugin-cds'"}],"quickstart":{"code":"// vite.config.js\nimport { defineConfig } from 'vite'\nimport { cds } from 'vite-plugin-cds'\n\nexport default defineConfig({\n  plugins: [cds()],\n  root: './app',\n})\n\n// In your JavaScript file:\nimport cdsModel from './index.cds'\nconsole.log(cdsModel) // compiled CSN object","lang":"javascript","description":"Import a .cds model file in a Vite app using the plugin. The plugin compiles the model at build time."},"warnings":[{"fix":"Use Vite 5 or later.","message":"The plugin is designed for Vite 5+; compatibility with older Vite versions is not guaranteed.","severity":"breaking","affected_versions":">=0.1.0"},{"fix":"If you need to disable minify, configure Vite's build.minify or use a custom rollup plugin.","message":"The 'minify: false' option was removed in v0.1.10; manual chunks configuration may be needed.","severity":"deprecated","affected_versions":">=0.1.10"},{"fix":"Avoid relying on cds.context for per-request state in browser usage.","message":"When using the CAP runtime in the browser, cds.context is not unique per request/transaction due to limited async context tracking.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run npm install @sap/cds","cause":"@sap/cds is not installed as a peer dependency.","error":"Cannot find module '@sap/cds'"},{"fix":"Ensure you import cds from '@sap/cds', not from the plugin: import cds from '@sap/cds'","cause":"cds imported from wrong source or not initialized.","error":"Uncaught TypeError: cds.compile is not a function"},{"fix":"Run npm install vite@5","cause":"Vite is not installed or version mismatch.","error":"The requested module 'vite' does not provide an export named 'defineConfig'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}