Concordialang Plugin
raw JSON → 1.3.2 verified Fri May 01 auth: no javascript
TypeScript interface for building Concordia Compiler plug-ins (v1.3.2). This package defines the Plugin interface and related types that must be implemented by any Concordia plug-in. It is released on npm with monthly updates. Compared to direct compiler extension, it provides a standardized API for code generation and test execution. ESM-only, requires Node >=12.20, and ships TypeScript declarations.
Common errors
error ERR_REQUIRE_ESM: require() of ES Module /path/to/concordialang-plugin not supported. ↓
cause This package is ESM-only and cannot be loaded with require().
fix
Use import or dynamic import. For CommonJS, use async import() or switch to ESM.
error TypeError: MyPlugin is not a constructor ↓
cause Forgetting to use default export for plugin class.
fix
Add 'export default class MyPlugin implements Plugin'
error Property 'heal' does not exist on type 'TestScriptExecutionOptions' ↓
cause Using a version earlier than 1.3.0 where 'heal' was added.
fix
Update to concordialang-plugin >=1.3.0.
error Cannot find module 'concordialang-types' or its corresponding type declarations. ↓
cause Missing peer dependency 'concordialang-types'.
fix
Install it: npm i concordialang-types
Warnings
breaking v1.0.0 introduced a new API that is incompatible with earlier versions. ↓
fix Update your plugin implementation to match the new interfaces.
gotcha The Plugin interface members are optional. If not implemented, the corresponding step will be skipped. ↓
fix Ensure you implement at least generateCode and/or executeCode as needed; omit serveCommand if not required.
deprecated Properties 'heal' in TestScriptExecutionOptions was added in v1.3.0; previously unused properties were renamed. ↓
fix If using the options object, check for new/changed properties.
gotcha Package is ESM-only; require() fails with error 'ERR_REQUIRE_ESM'. ↓
fix Use import syntax or dynamic import(). Set { 'type': 'module' } in your package.json if needed.
gotcha Requires 'concordialang-types' as a peer dependency for type definitions. ↓
fix Install 'concordialang-types' as a dependency: npm i concordialang-types
Install
npm install concordialang-plugin yarn add concordialang-plugin pnpm add concordialang-plugin Imports
- Plugin wrong
import Plugin from 'concordialang-plugin'correctimport { Plugin } from 'concordialang-plugin' - TestScriptGenerationOptions wrong
const { TestScriptGenerationOptions } = require('concordialang-plugin')correctimport { TestScriptGenerationOptions } from 'concordialang-plugin' - TestScriptExecutionOptions
import { TestScriptExecutionOptions } from 'concordialang-plugin'
Quickstart
import { Plugin, TestScriptGenerationOptions, TestScriptGenerationResult, TestScriptExecutionOptions, TestScriptExecutionResult } from 'concordialang-plugin';
export default class MyPlugin implements Plugin {
serveCommand?: string;
async generateCode(
abstractTestScripts: any[],
options: TestScriptGenerationOptions
): Promise<TestScriptGenerationResult> {
// Generate test code from abstract scripts
return { generatedFiles: [] };
}
async executeCode(
options: TestScriptExecutionOptions
): Promise<TestScriptExecutionResult> {
// Run the tests
return { success: true, output: '' };
}
}