Developer Guide
Quick Start
From a clean checkout:
cd neuron-xray-extension
npm run setup:dev
This single command:
- Installs UI dependencies
- Builds and packs UI packages (dev mode with source maps)
- Installs extension dependencies
- Installs UI tarballs into
node_modules/ - Builds the extension
Then press F5 to debug.
Package.json Scripts
Setup & Install
| Script | Command | Description |
|---|---|---|
setup:dev |
npm run setup:dev |
Full local dev setup (UI build + extension build) |
install:ui-components |
npm run install:ui-components |
Installs pre-built UI tarballs from ../ui/packages/ |
Build Scripts
| Script | Command | Description |
|---|---|---|
build |
npm run build |
Standard build - React components + rollup extension bundle (external) |
build:internal |
npm run build:internal |
Builds with RELEASE_TYPE=internal (internal features enabled) |
build:external |
npm run build:external |
Builds with RELEASE_TYPE=external (public release) |
build-react |
npm run build-react |
Compiles only the React webview components |
build-react:dev |
npm run build-react:dev |
Compiles React components in development mode (no minification) |
Package Scripts
| Script | Command | Description |
|---|---|---|
package |
npm run package |
Creates a .vsix package in build/vscode-extension-artifacts/ |
package:external |
npm run package:external |
Compiles (external) + creates external release .vsix |
package:internal |
npm run package:internal |
Compiles (internal) + creates internal release .vsix |
release |
npm run release |
Generates attribution, lint, test, then packages both .vsix builds |
Other Scripts
| Script | Command | Description |
|---|---|---|
compile |
npm run compile |
Full compilation (React + rollup extension bundle) |
lint |
npm run lint |
Runs ESLint on source files |
test |
npm run test |
Runs Jest tests with coverage |
watch |
npm run watch |
Watches for changes and rebuilds (internal mode, for F5 debugging) |
clean |
npm run clean |
Removes dist/, node_modules/, and build artifacts |
format |
npm run format |
Formats source files with Prettier |
Build Architecture
The extension uses rollup to bundle src/extension.ts into a single CJS file (dist/extension.js). This is necessary because:
- VS Code's extension host loads extensions via
require()(CommonJS) - The UI packages use
"type": "module"(ESM) - Rollup handles the ESM→CJS conversion, avoiding TypeScript's strict CJS/ESM boundary enforcement
The tsconfig.json uses "module": "ESNext" + "moduleResolution": "bundler" for type-checking (no CJS/ESM errors in the editor), while rollup produces the actual CJS output.
Key files:
rollup.config.extension.js— bundlessrc/extension.ts→dist/extension.js(CJS)rollup.config.js— bundles React webview components →dist/react-components/*.min.jstsconfig.json— type-checking config (ESNext/bundler, no emit)tsconfig.react.json— React components compilation →dist/react-components/
RELEASE_TYPE
The RELEASE_TYPE environment variable controls which features are enabled:
external(default) — public release, internal features disabledinternal— internal features enabled (AWS auth, upload, etc.)
It's baked in at build time by rollup's replace plugin. The default is external (safe) — internal must be explicitly set.
| Context | Value |
|---|---|
npm run build |
external (default) |
npm run build:internal |
internal |
npm run watch (F5) |
internal |
npm run package:external |
external |
npm run package:internal |
internal |
Resolving UI Dependencies
The extension depends on UI packages from ui/:
neuron-explorer-code-editorneuron-explorer-commonneuron-explorer-timeline-viewerneuron-explorer-ui-components
These are listed as optionalDependencies (with version "*") so npm install doesn't fail when they can't be resolved from a public registry.
Local dev: npm run setup handles everything — builds UI, packs tarballs, installs them.
After UI changes: Re-run the UI build and reinstall tarballs:
cd ../ui && npm run build:dev
cd ../neuron-xray-extension && npm run install:ui-components
Debugging (F5)
- Run
npm run setup:dev(first time) ornpm run build:internal(subsequent) - Open
neuron-xray-extension/as the workspace in VS Code - Select "Run Extension (Internal Mode)" from the debug dropdown
- Press F5
The watch task (triggered by F5's preLaunchTask) uses rollup in watch mode with RELEASE_TYPE=internal. It produces CJS output with source maps — breakpoints work.
Project Structure
src/- Source codeextension.ts- Main extension entry pointconfig/buildConfig.ts- Build-time configuration (RELEASE_TYPE)react-components/- React wrapper components for webviewswebViews/- WebView panel implementationslisteners/- Event listenersservices/- Service modulestypes/- TypeScript type definitions
dist/- Compiled outputextension.js- Bundled extension (CJS, single file)react-components/- Bundled webview components
build/vscode-extension-artifacts/- Packaged.vsixfilesscripts/- Build and utility scriptssetup.sh- Full local dev setupinstall-ui-components.sh- Installs UI tarballs
resources/- Static resources (icons, etc.)
Adding Widgets
See AGENTS.md for a detailed step-by-step guide — including code templates and a completion checklist.
Summary of steps:
- Verify base widget and widget type entries exist in
ui/packages/common/src/services/types/Widget.types.ts - Create the VS Code widget component (
<WidgetName>VSCode.tsx) and export it fromwidgets/index.ts - Create the React wrapper entry point in
src/react-components/ - Create the WebviewPanel class in
src/webViews/ - Register the panel in
widgetManager.ts(import + switch case) - Add the widget to the sidebar dropdown in
widgetsSidebar.ts