IDE Integration
This guide explains how to connect third-party IDE tooling (such as the IntelliJ SFCC plugin) to your B2C CLI configuration, and how to enable Script API IntelliSense in any IDE.
Looking for the Salesforce B2C Commerce VS Code Extension? See the dedicated VS Code Extension section — it consumes
dw.jsonand the active instance directly, no bridge script required.
Script API IntelliSense
Get autocomplete and inline documentation on require('dw/catalog/ProductMgr'), hover docs from JSDoc, signature help, and member completion in cartridge JavaScript files. The B2C tooling ships TypeScript definitions for the Script API (currently version 26.9) covering all dw/* modules, top-level globals (request, customer, session), and the ICustomAttributes extension hook.
There are three setup paths depending on your IDE:
Salesforce B2C Commerce VS Code Extension (recommended)
If you have the Salesforce B2C Commerce VS Code extension installed, IntelliSense is automatic:
- No configuration files are written into your repository.
- The extension registers a TypeScript Server plugin that resolves
dw/*modules transparently for any file inside a detected cartridge (folders containing a.projectfile alongside acartridge/directory). - Files outside your cartridges are unaffected.
You can disable the feature with the b2c-dx.features.scriptTypes setting (default: true).
The plugin also resolves SFCC cartridge-style requires, matching runtime semantics:
require('~/cartridge/scripts/foo')— resolves only within the cartridge that contains the current file (the SFCC~shortcut for "current cartridge"). Iffoodoesn't exist there, IntelliSense reports it unresolved — same as runtime.require('*/cartridge/scripts/foo')— walks the cartridge path from left to right and uses the first cartridge that has the file, the same as the platform. That holds even when the calling file is in a cartridge further right, so an overlay cartridge's override wins over the base.require('app_storefront_base/cartridge/scripts/foo')— resolves only within the named cartridge.require('server'),require('server/middleware'), etc. — bare requires resolve against the SFRAmodulescartridge if present (its tree is exposed at the root, not undercartridge/scripts/). When amodulescartridge is detected, the plugin also injects ambient type declarations for the SFRAserverAPI (Server, Route, Request, Response, middleware, forms, querystring) so cartridge code type-checks undercheckJs: truedespite the dynamic property assignments inmodules/server.jsthat TypeScript can't infer on its own.
Resolution follows the order shown in the extension's Cartridges view, which also drives ISML template links. The view uses the first of these that's available:
- An order you set in the view. Drag a cartridge onto another to place it before that cartridge, or use Move Up/Down in Cartridge Order from its context menu. The order is saved for this workspace only; Reset Cartridge Order in the view menu goes back to the automatic order.
- The
cartridgesfield from your resolved configuration (dw.json,SFCC_CARTRIDGES,.env, and so on). - A site's cartridge path on your instance. The extension uses the site set in Choose Site for Cartridge Order… in the view menu, then the
site-idfrom your configuration, and otherwise the site whose cartridge path names the most of your local cartridges (never Business Manager). It reads the path in the background only when you use client credentials, so it never opens a login page on its own; with browser sign-in, choose a site to read it. The path is cached per workspace. If it can't be read, the view falls back quietly and says why. - A guess: discovery order with known base cartridges (
app_storefront_base,modules) last.
The view's description shows which source is in use, and a cartridge's tooltip shows its position. Cartridges on disk that the chosen cartridge path doesn't name are listed last, with a dimmed icon, and marked not on cartridge path. The site doesn't run their code, so their controllers, overlays, hooks, and Custom APIs are left out of routes, the Endpoints view, and CodeLens; expand one to open its controller files.
To see routes as if the site ran every cartridge, use Include Cartridges Not on the Path in the Cartridges or Endpoints view menu (setting b2c-dx.cartridges.includeAllCartridges). The order still follows the cartridge path, with the other cartridges after it. Use Only the Cartridge Path switches back.
Editors that load the TypeScript plugin without the extension use the cartridges field from dw.json, then the guess.
Custom attributes
To type the custom property of Script API objects with your instance's custom attributes, run B2C DX: Write Custom Attribute Types to Project. Then product.custom.myAttribute gets completions, hover docs (display name, description, enum values), and type checking. Enum attributes narrow to their values, for example product.custom.color.value is 'red' | 'blue'.
The command reads attribute definitions from the configured instance through the Object Definitions API and writes .b2c-script-types/custom-attributes.d.ts, which the extension loads automatically. Commit the file to share it, and run the command again when attribute definitions change. It needs an Account Manager API client with the sfcc.object-definitions scope plus short-code and tenant-id (see Object Types); enum values need sfcc.object-definitions.rw. b2c setup ide vscode-types --custom-attributes writes the same file.
Legacy .ds scripts
The extension associates **/cartridge/scripts/**/*.ds with the JavaScript language mode, so legacy pipeline-era scripts get the same syntax highlighting, completions, hover docs, and debugger breakpoints as their .js siblings. Requires that land on a .ds file resolve as well — .js still wins when both exist, matching the platform. Override the association in your own settings if you use .ds files for something else:
{
"files.associations": {
"**/cartridge/scripts/**/*.ds": "plaintext"
}
}Standalone VS Code, WebStorm, or IntelliJ Ultimate
For IDEs without the extension, run the following from your project root to vendor the type bundle and a jsconfig.json:
b2c setup ide vscode-typesThis creates two artifacts at the repo root:
./.b2c-script-types/types/— vendored copy of the Script API definitions../jsconfig.json— TypeScript Language Service configuration mappingdw/*to the vendored types.
Add --custom-attributes to also generate ./.b2c-script-types/custom-attributes.d.ts with the instance's custom attributes (same requirements as the VS Code command above):
b2c setup ide vscode-types --custom-attributes --forceYou can commit both into your repository if you want everyone on the team to share the same setup. To re-vendor after upgrading the CLI, re-run the command with --force to overwrite the existing files. The vendored types are refreshed automatically because the --copy flag defaults to true. The jsconfig.json lives at the repo root by design — the paths mappings inside it are repo-root-relative and will not resolve correctly from a subdirectory.
The generated jsconfig.json looks like this — feel free to author it yourself if you prefer:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"allowJs": true,
"checkJs": false,
"noEmit": true,
"baseUrl": ".",
"paths": {
"dw/*": ["./.b2c-script-types/types/dw/*"]
},
"types": []
},
"include": [".b2c-script-types/types/global.d.ts", "**/cartridge/**/*.js"],
"exclude": ["**/cartridge/static/**", "**/node_modules/**"]
}Neovim, Helix, Zed, Sublime, or other LSP-based editors
Modern editors that drive tsserver through the Language Server Protocol have two ways to wire up Script API IntelliSense:
Option A — vendored jsconfig.json (dw/* only). Run b2c setup ide vscode-types at the repo root and your LSP picks it up on next start. Provides only dw/* resolution; cartridge-relative requires (~/cartridge/..., */cartridge/...) are not handled because TypeScript paths mappings can't express multi-cartridge lookups.
Option B — load the bundled TS Server plugin (full feature parity with the VS Code extension). Configure your LSP client to load @salesforce/b2c-script-types as a TypeScript Server plugin via init_options. The plugin auto-discovers cartridges by walking the project for .project files, and honors dw.json's cartridges field for ordering — no separate vendoring step.
Resolve the plugin location via the CLI:
b2c setup ide tsserver-plugin --json
# {"pluginName":"@salesforce/b2c-script-types","pluginPath":"/usr/lib/.../dist/script-types","typesPath":"...","version":"26.9.0"}The recommended language servers and what to install:
- Neovim with
nvim-lspconfig— use thets_lsserver (formerlytsserver), backed by thetypescript-language-servernpm package. Oldercoc-tsserversetups also work. The nvim-sfcc plugin wraps the wiring below. - Helix — bundles
typescript-language-server; nothing to wire up beyond installing the package globally (npm i -g typescript-language-server typescript). - Zed — ships TypeScript support out of the box; no extra configuration.
- Sublime Text — install
LSPandLSP-typescriptfrom Package Control.
A minimal Neovim 0.10+ snippet using nvim-lspconfig and the TS Server plugin:
local function b2c_plugin_path()
local out = vim.fn.system({ 'b2c', 'setup', 'ide', 'tsserver-plugin', '--json' })
return (vim.fn.json_decode(out) or {}).pluginPath
end
require('lspconfig').ts_ls.setup({
root_dir = require('lspconfig.util').root_pattern('jsconfig.json', 'tsconfig.json', '.project', '.git'),
filetypes = { 'javascript', 'javascriptreact', 'typescript', 'typescriptreact' },
init_options = {
plugins = {
{ name = '@salesforce/b2c-script-types', location = b2c_plugin_path() },
},
},
})If your editor's LSP client is launched outside the repo root (for example, opening a single cartridge subdirectory), point it at the project root so the plugin's auto-discovery walks the right tree.
Notes
- The bundle is version-locked to a Script API release (currently 26.9). Re-run
b2c setup ide vscode-typesafter upgrading the CLI to refresh the vendored copy; use--forceto overwrite existing files if they were previously created. The plugin path returned byb2c setup ide tsserver-pluginalways points at the bundle shipped with your installed CLI. - The vendored
jsconfig.jsononly configuresdw/*IntelliSense. Cartridge-relative requires (~/cartridge/...,*/cartridge/...,cartridgeName/cartridge/...) cannot be expressed in standalone TypeScriptpathsmappings (TypeScript allows at most one*per pattern), so they will appear unresolved without the Salesforce B2C Commerce VS Code extension or another host that loads@salesforce/b2c-script-types/pluginvia LSP.
IntelliJ SFCC Plugin
The IntelliJ SFCC plugin manages its own connection settings in .idea/misc.xml. A community B2C CLI plugin lets you share that configuration with the CLI so both tools stay in sync.
Setup
Install the b2c-plugin-intellij-sfcc-config plugin:
b2c plugins install sfcc-solutions-share/b2c-plugin-intellij-sfcc-configOnce installed, run CLI commands from your IntelliJ project directory and the plugin will automatically load connection settings from .idea/misc.xml.
See the 3rd Party Plugins guide for full details on environment variables, credential decryption, and instance selection.