Export calculation engine as standalone npm package#37
Merged
Conversation
Co-authored-by: kcrt <505011+kcrt@users.noreply.github.com>
- Created lib/index.ts as main export file for the package - Added TypeScript build configuration (tsconfig.lib.json) - Updated package.json with exports, main, types, and build:lib script - Split dependencies: core deps (expr-eval, zod) vs optional Next.js deps - Added comprehensive library tests to verify exports work correctly - Created LIB_README.md with usage examples and API documentation - Updated main README.md to include npm package usage instructions - Added /dist to .gitignore to avoid committing build artifacts - Fixed CalculationFormula and HtmlFormula types to align with Formula schema Co-authored-by: kcrt <505011+kcrt@users.noreply.github.com>
- Removed jsx compiler option from tsconfig.lib.json (not needed for library) - Removed .js extensions from TypeScript imports in lib/index.ts (let tsc-alias handle it) - Updated package description to clarify dual use as library and web app - All tests pass (except pre-existing ShareButton test failure unrelated to changes) Co-authored-by: kcrt <505011+kcrt@users.noreply.github.com>
- Created PACKAGE_PUBLISHING.md with step-by-step instructions - Includes pre-publishing checklist - Covers publishing steps, testing, and troubleshooting - Documents what gets published and how users will consume the package Co-authored-by: kcrt <505011+kcrt@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add calculation feature for npm installation
Export calculation engine as standalone npm package
Feb 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Next.js application's calculation engine can now be consumed as an npm package by external applications.
Changes
Library Export (
lib/index.ts)Build Pipeline
tsconfig.lib.jsontargeting CommonJS for Node.js compatibilitytsc-aliasto resolve@/*path mappings at build timenpm run build:libPackage Configuration
private: true, addedmainandtypesfieldsfileswhitelist:dist/,src/formulas/prepublishOnlyhook ensures build before publishType Safety
CalculationFormulaandHtmlFormulato include base Formula fields (name, info, metadata, locales)Usage
Core dependencies:
expr-eval,zod. Next.js/React dependencies included but not required for calculation functionality.Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.