A basic example showing how to use modern JavaScript syntax (import statements) with chainsig.js in Node.js using TypeScript and ts-node.
- Modern import syntax works with chainsig.js
- TypeScript handles CommonJS compatibility automatically
- Simple one-command execution
- All exports are accessible and typed
cd simple-node-example
npm install
npm startYou write modern syntax:
import { chainAdapters, constants } from 'chainsig.js';ts-node automatically transpiles it to:
const { chainAdapters, constants } = require('chainsig.js');{
"type": "commonjs",
"scripts": {
"start": "ts-node index.ts"
},
"dependencies": {
"chainsig.js": "file:../chainsig.js"
}
}{
"compilerOptions": {
"module": "CommonJS",
"esModuleInterop": true
}
}- 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)
Add to package.json:
{
"scripts": {
"build": "tsc",
"start:compiled": "node dist/index.js"
}
}Then run:
npm run build
npm run start:compiledsimple-node-example/
├── package.json
├── tsconfig.json
├── index.ts
└── README.md
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! 🎉
../vanilla-js-test/- Comprehensive testing of various import scenarios../chainsig.js/examples/- Official chainsig.js examples../chainsig.js/- The main chainsig.js library