Skip to content

GregProuty/chainsig-simple-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Node.js Example with chainsig.js

A basic example showing how to use modern JavaScript syntax (import statements) with chainsig.js in Node.js using TypeScript and ts-node.

What this shows

  • Modern import syntax works with chainsig.js
  • TypeScript handles CommonJS compatibility automatically
  • Simple one-command execution
  • All exports are accessible and typed

Quick start

cd simple-node-example
npm install
npm start

How it works

You write modern syntax:

import { chainAdapters, constants } from 'chainsig.js';

ts-node automatically transpiles it to:

const { chainAdapters, constants } = require('chainsig.js');

Configuration

package.json

{
  "type": "commonjs",
  "scripts": {
    "start": "ts-node index.ts"
  },
  "dependencies": {
    "chainsig.js": "file:../chainsig.js"
  }
}

tsconfig.json

{
  "compilerOptions": {
    "module": "CommonJS",
    "esModuleInterop": true
  }
}

Benefits

  • Write modern code with import/export syntax
  • No complex build process
  • Full TypeScript support
  • Works with chainsig.js without compatibility issues
  • Dependencies stay external (no bundling)

Alternative: Compile to JavaScript

Add to package.json:

{
  "scripts": {
    "build": "tsc",
    "start:compiled": "node dist/index.js"
  }
}

Then run:

npm run build
npm run start:compiled

Project structure

simple-node-example/
├── package.json
├── tsconfig.json
├── index.ts
└── README.md

🏆 Bottom Line

This example proves that developers don't need to choose between modern syntax and chainsig.js compatibility.

TypeScript + ts-node gives you the best of both worlds:

  • ✅ Write modern import syntax
  • ✅ Execute with one command
  • ✅ Full compatibility with chainsig.js
  • ✅ No ecosystem coordination needed

Perfect solution for 99% of JavaScript developers! 🎉


🔗 Related Examples

  • ../vanilla-js-test/ - Comprehensive testing of various import scenarios
  • ../chainsig.js/examples/ - Official chainsig.js examples
  • ../chainsig.js/ - The main chainsig.js library

About

Simple Node.js example using chainsig.js with modern syntax

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors