Contributors

Developing Nerdamer

This is the practical path from cloning the repository to making and validating a change. The Nerdamer repository and its main development line are the source for current commands, file locations, and contributor guidance.

Keep the feedback loop short. For most changes, type-check and run the relevant tests while you work, then run the full test and build commands before considering the change complete.

Set up the repository

git clone https://github.com/jiggzson/nerdamer.git
cd nerdamer
npm install

The source is TypeScript. Nerdamer now builds its public API modules separately from its browser bundles. The full bundle and parser-only bundle are separate targets, while build:modules produces the package subpath modules and declarations.

The normal contributor loop

1 · Editsrc/

Make the smallest change in the subsystem that owns the behavior.

2 · Checknpm run typechecknpm test

Catch type and behavioral regressions while the change is still small.

3 · Buildnpm run buildnpm run build:parser

Verify both the complete package and parser-only browser targets.

Development commands

Use the repository scripts for type checking, testing, builds, documentation, and local experiments.

CommandUse it forWhat it checks or produces
npm run typecheckFast correctness check while editingRuns TypeScript without emitting files.
npx tscDirect TypeScript compiler workflowRuns the TypeScript compiler directly.
npm testBehavior and regression coverageRuns the Jest suite.
npm run build:modulesRefresh package API modulesBuilds the generated JavaScript and declarations used by public package subpath imports.
npm run build:bundleBuild the complete browser bundleProduces dist/bundle.js from the full package entry point.
npm run build:bundle:all-languagesBuild the browser bundle with every languageProduces dist/bundle.js with all translated error-message catalogs included.
npm run build:parserBuild the parser-only browser targetProduces dist/parser.js from src/api/parser.ts and runs its smoke check.
npm run build:fullBuild the complete packageRuns the module build, complete browser bundle, and full-bundle smoke check.
npm run buildRelease-facing complete buildRuns build:full. The parser-only target remains a separate build:parser step.
npm run build:all-languagesBuild the complete package with every browser languageBuilds the package modules, the full browser bundle with every language catalog, and runs the full-bundle smoke check.
npm run devScratch-driven developmentRuns tools/dev.ts through the development watcher.
npm run lintStatic code checksRuns ESLint over the TypeScript source.

Full package and parser-only composition

The browser builds no longer assume that every parser entry point should pull in the complete CAS. src/index.ts assembles the complete package and calls registerNerdamerFunctions(), which registers parser-visible functions from core, math, algebra, calculus, and solving. The parser façade at src/api/parser.ts calls loadParserFunctions() instead, registering parser/core and math functionality without importing the higher-level algebra, calculus, and solver domains.

npm run build          # complete package: modules + dist/bundle.js

npm run build:parser   # parser-only browser target: dist/parser.js

This separation keeps nerdamer/parser and the parser browser target useful without recreating the old dependency from the parser back into the complete package. Domain dispatch modules register their own functions when the complete package is assembled.

Language-targeted browser builds

Browser bundles include English by default. The full and parser-only targets can include one or more translated error-message catalogs without carrying every translation. Supported language codes are spa, fra, deu, por, ita, and nld.

# Full browser bundle with Spanish

npx webpack --mode=production --env target=full --env language=spa

# Full browser bundle with Spanish and French

npx webpack --mode=production --env target=full --env language=spa,fra

# Parser-only browser bundle with Spanish and French

npx webpack --mode=production --env target=parser --env language=spa,fra

English is always included. For a targeted list, the first requested non-English language is selected initially and the other included catalogs are available for runtime switching. For example, language=spa,fra includes English, Spanish, and French, starts in Spanish, and allows the runtime LANGUAGE setting to switch to French or back to English.

When the complete package needs every translated catalog, use the named all-languages build:

npm run build:all-languages

This builds the package modules, produces the full dist/bundle.js with every language catalog, and runs the full-bundle smoke test. If only the all-languages browser bundle needs to be rebuilt, use:

npm run build:bundle:all-languages

The parser-only target can still be built with every catalog through its webpack target:

npx webpack --mode=production --env target=parser --env language=all

all cannot be combined with individual language codes. Unknown language codes fail the build. Repeated codes in a targeted list are ignored.

The normal npm run build:bundle and npm run build:parser commands omit the language option, so they produce English-only browser builds. Language targeting affects browser bundle composition; it does not replace the package module build.

Runtime language selection does not load catalogs. nerdamer.set('LANGUAGE', ...) and Parser.set('LANGUAGE', ...) can select only catalogs that were included when the browser bundle was built. Use a comma-separated subset such as language=spa,fra when only those languages are needed, or npm run build:all-languages when the application must switch among every supported catalog.

Use the development scratch file

tools/dev.ts is available for experiments, debugging, and quick local checks.

import nerdamer from '../src';

console.log(nerdamer('factor(x^4-1)').text());

If tools/dev.ts imports through one of the public API package paths, such as nerdamer/core, nerdamer/calculus, or nerdamer/structures, refresh the generated module output after changing the source:

npm run build:modules

Those package paths resolve through the generated module output, so without rebuilding them the scratch file can execute stale code.

Run the development watcher with:

npm run dev

Where should the change go?

src/core

Parser behavior, symbolic representation, shared operations, converters, settings, rationals, matrices, vectors, and common infrastructure.

src/algebra

Factoring, simplification, polynomial work, GCD/LCM, partial fractions, and related algebra algorithms.

src/calculus

Differentiation, integration, limits, sums/products, and transforms.

src/solve

Single-equation, polynomial, function, and multivariate/system solving.

src/math

Mathematical functions and lower-level numerical/symbolic helpers used by the higher layers.

spec

Targeted behavior specs and regression coverage. Add a reproducer here when a bug fix needs permanent protection.

Read the code conventions

Code conventions

Implementation patterns for reuse, types, parser entities, return flow, constants, access modifiers, files, and regression tests.

Code conventions

Before you finish

A change that works in one scratch example is not enough. Check the surrounding subsystem, add a targeted regression when fixing a bug, and run the full validation commands before handing the change off.

npm run typecheck
npm test
npm run build
npm run build:parser
Nerdamer repository

The repository is the source for current code, commands, package entry points, and contributor documentation.

github.com/jiggzson/nerdamer
Need the code map first?

The Codebase Map shows how the major source areas relate before you decide where to edit.

Codebase map