Registry / http-networking / akore
library2.2.0jsnpmunverified

Akore is a powerful transpiler maker for JavaScript/TypeScript, currently at version 2.2.0. It provides a robust framework for parsing, analyzing, and transforming code, allowing developers to build custom transpilers with ease. Key differentiators include an extensible architecture with concepts like Schema, Registry, Lexer, and BaseTranspiler, and support for both JavaScript and TypeScript. Release cadence is not specified but appears active with recent updates. It requires Node.js >=16 and npm >=8. Compared to alternatives like Babel or SWC, Akore focuses on simplifying the creation of custom transpiler pipelines rather than being a pre-built transpiler.

npm install akore
INSTALL
IMPORT
SIG · AKORE
A
akore
http-networkingjavascriptv2.2.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Schema
import { Schema } from 'akore'
const { Schema } = require('akore')
Akore is ESM-only since v2; CommonJS require is not supported.
Registry
import { Registry } from 'akore'
import registry from 'akore'
Registry is a named export, not a default export.
BaseTranspiler
import { BaseTranspiler } from 'akore'
import { Transpiler } from 'akore'
The class is named BaseTranspiler, not Transpiler.
Lexer
import { Lexer } from 'akore'
import Lexer from 'akore'
Lexer is a named export, not a default export.

Demonstrates creating a Schema, Registry, custom Lexer, and BaseTranspiler to transpile a simple number token.

import { Schema, Registry, BaseTranspiler, Lexer } from 'akore'; // Create a schema for a simple language const numberSchema = new Schema('number', { type: 'number' }); // Create a registry and register schemas const registry = new Registry(); registry.set('number', numberSchema); // Define a custom lexer (minimal example) class MyLexer extends Lexer { tokenize(code) { // Simplified tokenization if (code === '42') { return [{ type: 'number', value: 42 }]; } return []; } } // Create a transpiler using the registry const transpiler = new BaseTranspiler(registry); // Example code to transpile const code = '42'; const tokens = new MyLexer().tokenize(code); const result = tokens.map(t => t.value).join(' '); console.log(result); // Output: 42
Debug
Known issues
breakingVersion 2.0.0 dropped CommonJS support; require() throws a runtime error.
fix
Switch to ESM imports: use 'import' statements and ensure package.json has 'type': 'module'.
affects: >=2.0.0
breakingVersion 2.0.0 renamed 'Transpiler' class to 'BaseTranspiler'. Old imports break.
fix
Replace all 'import { Transpiler }' with 'import { BaseTranspiler }'.
affects: >=2.0.0
deprecatedSchema constructor argument order changed in v2.1.0: 'identifier' and 'schema' swapped.
fix
Use new Schema('identifier', schemaObject) pattern instead of Schema(schemaObject, 'identifier').
affects: >=2.1.0
gotchaLexer must be subclassed; the base class throws an error if tokenize is not overridden.
fix
Always extend Lexer and implement the tokenize method returning an array of tokens.
affects: >=1.0.0
gotchaRegistry inherits from Map but get() returns Schema | undefined; TypeScript strict mode requires null checks.
fix
Use optional chaining: registry.get('key')?.validate(data) or check for undefined.
affects: >=1.0.0
Errors
Common errors & fixes
Error: The Schema identifier must be a string.
Passing a non-string value as the first argument to new Schema() before v2.1.0.
fix
Ensure first argument is a string: new Schema('mySchema', { type: 'string' }).
TypeError: registry.get is not a function
Using an older version where Registry did not extend Map; the API was different.
fix
Update to akore ^2.0.0 and use registry.set/get as Map methods.
SyntaxError: Named export 'Transpiler' not found.
Importing 'Transpiler' which was renamed to 'BaseTranspiler' in v2.
fix
Change import to: import { BaseTranspiler } from 'akore'.
Cannot find module 'akore' or its corresponding type declarations.
Akore is ESM-only; using require() in a CommonJS project or missing 'type': 'module' in package.json.
fix
Set 'type': 'module' in package.json or use dynamic import: const akore = await import('akore').
Upgrade
Version history
2.2.0latest on npm
Audit
Dependencies
typescriptoptionalTypeScript support requires TypeScript to be installed as a peer dependency for type checking and transformation.
Agent activity
52 hits · last 30 days
node
42
OpenAI (training)
1
Resources
akore — npm install akore · libregistry