diff --git a/__tests__/lossless.ts b/__tests__/lossless.ts index d365389..3dd81d2 100644 --- a/__tests__/lossless.ts +++ b/__tests__/lossless.ts @@ -1,6 +1,6 @@ -import {Delta, DeltaFilter} from '../src/delta.js'; -import {Lossless} from '../src/lossless.js'; -import {RhizomeNode} from '../src/node.js'; +import {Delta, DeltaFilter} from '../src/delta'; +import {Lossless} from '../src/lossless'; +import {RhizomeNode} from '../src/node'; describe('Lossless', () => { const node = new RhizomeNode(); diff --git a/__tests__/lossy.ts b/__tests__/lossy.ts index 605a103..1b1fe12 100644 --- a/__tests__/lossy.ts +++ b/__tests__/lossy.ts @@ -1,9 +1,9 @@ import Debug from 'debug'; -import {Delta, PointerTarget} from "../src/delta.js"; -import {lastValueFromDeltas} from "../src/last-write-wins.js"; -import {Lossless, LosslessViewOne} from "../src/lossless.js"; -import {Lossy, valueFromCollapsedDelta} from "../src/lossy.js"; -import {RhizomeNode} from "../src/node.js"; +import {Delta, PointerTarget} from "../src/delta"; +import {lastValueFromDeltas} from "../src/last-write-wins"; +import {Lossless, LosslessViewOne} from "../src/lossless"; +import {Lossy, valueFromCollapsedDelta} from "../src/lossy"; +import {RhizomeNode} from "../src/node"; const debug = Debug('test:lossy'); type Role = { diff --git a/__tests__/peer-address.ts b/__tests__/peer-address.ts index 3dbaafc..626b590 100644 --- a/__tests__/peer-address.ts +++ b/__tests__/peer-address.ts @@ -1,4 +1,4 @@ -import {parseAddressList, PeerAddress} from '../src/peers.js'; +import {parseAddressList, PeerAddress} from '../src/peers'; describe('PeerAddress', () => { it('toString()', () => { diff --git a/__tests__/run/001-single-node.ts b/__tests__/run/001-single-node.ts index aad9f96..bc5f114 100644 --- a/__tests__/run/001-single-node.ts +++ b/__tests__/run/001-single-node.ts @@ -1,4 +1,4 @@ -import {App} from "../../util/app.js"; +import {App} from "../../util/app"; describe('Run', () => { let app: App; diff --git a/__tests__/run/002-two-nodes.ts b/__tests__/run/002-two-nodes.ts index 23a5254..add6aaf 100644 --- a/__tests__/run/002-two-nodes.ts +++ b/__tests__/run/002-two-nodes.ts @@ -1,5 +1,5 @@ import Debug from 'debug'; -import {App} from '../../util/app.js'; +import {App} from '../../util/app'; const debug = Debug('test:two'); describe('Run', () => { diff --git a/examples/app.ts b/examples/app.ts index e2cd75a..d7d38ac 100644 --- a/examples/app.ts +++ b/examples/app.ts @@ -1,7 +1,7 @@ import Debug from 'debug'; -import {Collection} from "../src/collection.js"; -import {Entity} from "../src/entity.js"; -import {RhizomeNode} from "../src/node.js"; +import {Collection} from "../src/collection"; +import {Entity} from "../src/entity"; +import {RhizomeNode} from "../src/node"; const debug = Debug('example-app'); // As an app we want to be able to write and read data. diff --git a/package.json b/package.json index c5df3aa..3631039 100644 --- a/package.json +++ b/package.json @@ -19,21 +19,7 @@ ], "testMatch": [ "**/__tests__/**/*" - ], - "transform": { - "^.+\\.ts$": [ - "ts-jest", - { - "useESM": true - } - ] - }, - "extensionsToTreatAsEsm": [ - ".ts" - ], - "moduleNameMapper": { - "^(\\.{1,2}/.*)\\.js$": "$1" - } + ] }, "author": "Taliesin (Ladd) ", "license": "Unlicense", diff --git a/src/collection.ts b/src/collection.ts index b03b8e6..49a54d2 100644 --- a/src/collection.ts +++ b/src/collection.ts @@ -6,11 +6,11 @@ import Debug from 'debug'; import {randomUUID} from "node:crypto"; import EventEmitter from "node:events"; -import {Delta} from "./delta.js"; -import {Entity, EntityProperties} from "./entity.js"; -import {LastWriteWins, ResolvedViewOne} from './last-write-wins.js'; -import {RhizomeNode} from "./node.js"; -import {DomainEntityID} from "./types.js"; +import {Delta} from "./delta"; +import {Entity, EntityProperties} from "./entity"; +import {LastWriteWins, ResolvedViewOne} from './last-write-wins'; +import {RhizomeNode} from "./node"; +import {DomainEntityID} from "./types"; const debug = Debug('rz:collection'); export class Collection { diff --git a/src/delta.ts b/src/delta.ts index 1cc2d28..8dce43f 100644 --- a/src/delta.ts +++ b/src/delta.ts @@ -1,7 +1,7 @@ import {randomUUID} from "crypto"; import microtime from 'microtime'; -import {CreatorID, HostID, Timestamp, TransactionID} from "./types.js"; -import {PeerAddress} from "./peers.js"; +import {CreatorID, HostID, Timestamp, TransactionID} from "./types"; +import {PeerAddress} from "./peers"; export type DeltaID = string; diff --git a/src/deltas.ts b/src/deltas.ts index 6cd62e4..99382df 100644 --- a/src/deltas.ts +++ b/src/deltas.ts @@ -1,8 +1,8 @@ import Debug from 'debug'; import EventEmitter from 'node:events'; import objectHash from 'object-hash'; -import {Delta, DeltaNetworkImage} from './delta.js'; -import {RhizomeNode} from './node.js'; +import {Delta, DeltaNetworkImage} from './delta'; +import {RhizomeNode} from './node'; const debug = Debug('rz:deltas'); enum Decision { diff --git a/src/entity.ts b/src/entity.ts index 7dd7fc1..616da1b 100644 --- a/src/entity.ts +++ b/src/entity.ts @@ -7,8 +7,8 @@ // - As typescript interfaces? // - As typescript classes? -import {Collection} from "./collection.js"; -import {PropertyTypes} from "./types.js"; +import {Collection} from "./collection"; +import {PropertyTypes} from "./types"; export type EntityProperties = { [key: string]: PropertyTypes; diff --git a/src/filter/index.ts b/src/filter/index.ts index c6d347a..38ad0d5 100644 --- a/src/filter/index.ts +++ b/src/filter/index.ts @@ -1,5 +1,5 @@ import { add_operation, apply } from 'json-logic-js'; -import { Delta } from '../delta.js'; +import { Delta } from '../delta'; type DeltaContext = Delta & { creatorAddress: string; diff --git a/src/filter/known.ts b/src/filter/known.ts index 3ee0f57..13b5bd9 100644 --- a/src/filter/known.ts +++ b/src/filter/known.ts @@ -1,4 +1,4 @@ -import { FilterExpr } from "../types.js"; +import { FilterExpr } from "../types"; // import { map } from 'radash'; // A creator as seen by a host diff --git a/src/http/api.ts b/src/http/api.ts index 0ff7f4e..e9dbb80 100644 --- a/src/http/api.ts +++ b/src/http/api.ts @@ -1,7 +1,7 @@ import express, {Router} from "express"; -import {Collection} from "../collection.js"; -import {Delta} from "../delta.js"; -import {RhizomeNode} from "../node.js"; +import {Collection} from "../collection"; +import {Delta} from "../delta"; +import {RhizomeNode} from "../node"; export class HttpApi { router = Router(); diff --git a/src/http/html.ts b/src/http/html.ts index aeea65c..925abcf 100644 --- a/src/http/html.ts +++ b/src/http/html.ts @@ -1,6 +1,6 @@ import express, {Router} from "express"; -import {RhizomeNode} from "../node.js"; -import {htmlDocFromMarkdown, MDFiles} from "../util/md-files.js"; +import {RhizomeNode} from "../node"; +import {htmlDocFromMarkdown, MDFiles} from "../util/md-files"; export class HttpHtml { router = Router(); diff --git a/src/http/index.ts b/src/http/index.ts index 39cfa5a..801e22b 100644 --- a/src/http/index.ts +++ b/src/http/index.ts @@ -1,9 +1,9 @@ import Debug from "debug"; import express from "express"; import {Server} from "http"; -import {RhizomeNode} from "../node.js"; -import {HttpApi} from "./api.js"; -import {HttpHtml} from "./html.js"; +import {RhizomeNode} from "../node"; +import {HttpApi} from "./api"; +import {HttpHtml} from "./html"; const debug = Debug('rz:http-api'); export class HttpServer { diff --git a/src/last-write-wins.ts b/src/last-write-wins.ts index 0652575..8610d6e 100644 --- a/src/last-write-wins.ts +++ b/src/last-write-wins.ts @@ -1,8 +1,8 @@ // import Debug from 'debug'; -import {EntityProperties} from "./entity.js"; -import {CollapsedDelta, Lossless, LosslessViewOne} from "./lossless.js"; -import {Lossy, valueFromCollapsedDelta} from './lossy.js'; -import {DomainEntityID, PropertyID, PropertyTypes, Timestamp, ViewMany} from "./types.js"; +import {EntityProperties} from "./entity"; +import {CollapsedDelta, Lossless, LosslessViewOne} from "./lossless"; +import {Lossy, valueFromCollapsedDelta} from './lossy'; +import {DomainEntityID, PropertyID, PropertyTypes, Timestamp, ViewMany} from "./types"; // const debug = Debug('rz:lossy:last-write-wins'); type TimestampedProperty = { diff --git a/src/lossless.ts b/src/lossless.ts index 54fae05..cf19c49 100644 --- a/src/lossless.ts +++ b/src/lossless.ts @@ -3,10 +3,10 @@ import Debug from 'debug'; import EventEmitter from 'events'; -import {Delta, DeltaFilter, DeltaID, DeltaNetworkImage} from './delta.js'; -import {RhizomeNode} from './node.js'; -import {Transactions} from './transactions.js'; -import {DomainEntityID, PropertyID, PropertyTypes, TransactionID, ViewMany} from "./types.js"; +import {Delta, DeltaFilter, DeltaID, DeltaNetworkImage} from './delta'; +import {RhizomeNode} from './node'; +import {Transactions} from './transactions'; +import {DomainEntityID, PropertyID, PropertyTypes, TransactionID, ViewMany} from "./types"; const debug = Debug('rz:lossless'); export type CollapsedPointer = {[key: PropertyID]: PropertyTypes}; diff --git a/src/lossy.ts b/src/lossy.ts index 17118b5..a97af41 100644 --- a/src/lossy.ts +++ b/src/lossy.ts @@ -3,9 +3,9 @@ // into various possible "lossy" views that combine or exclude some information. import Debug from 'debug'; -import {DeltaFilter, DeltaID} from "./delta.js"; -import {CollapsedDelta, Lossless, LosslessViewOne} from "./lossless.js"; -import {DomainEntityID} from "./types.js"; +import {DeltaFilter, DeltaID} from "./delta"; +import {CollapsedDelta, Lossless, LosslessViewOne} from "./lossless"; +import {DomainEntityID} from "./types"; const debug = Debug('rz:lossy'); export type Initializer = (v: LosslessViewOne) => Accumulator; diff --git a/src/node.ts b/src/node.ts index 1df34ce..22c8cbd 100644 --- a/src/node.ts +++ b/src/node.ts @@ -1,11 +1,11 @@ import Debug from 'debug'; -import {CREATOR, HTTP_API_ADDR, HTTP_API_ENABLE, HTTP_API_PORT, PEER_ID, PUBLISH_BIND_ADDR, PUBLISH_BIND_HOST, PUBLISH_BIND_PORT, REQUEST_BIND_ADDR, REQUEST_BIND_HOST, REQUEST_BIND_PORT, SEED_PEERS} from './config.js'; -import {DeltaStream} from './deltas.js'; -import {HttpServer} from './http/index.js'; -import {Lossless} from './lossless.js'; -import {parseAddressList, PeerAddress, Peers} from './peers.js'; -import {PubSub} from './pub-sub.js'; -import {RequestReply} from './request-reply.js'; +import {CREATOR, HTTP_API_ADDR, HTTP_API_ENABLE, HTTP_API_PORT, PEER_ID, PUBLISH_BIND_ADDR, PUBLISH_BIND_HOST, PUBLISH_BIND_PORT, REQUEST_BIND_ADDR, REQUEST_BIND_HOST, REQUEST_BIND_PORT, SEED_PEERS} from './config'; +import {DeltaStream} from './deltas'; +import {HttpServer} from './http/index'; +import {Lossless} from './lossless'; +import {parseAddressList, PeerAddress, Peers} from './peers'; +import {PubSub} from './pub-sub'; +import {RequestReply} from './request-reply'; const debug = Debug('rz:rhizome-node'); export type RhizomeNodeConfig = { diff --git a/src/peers.ts b/src/peers.ts index 77a2d9c..3d79d76 100644 --- a/src/peers.ts +++ b/src/peers.ts @@ -1,9 +1,9 @@ import Debug from 'debug'; import {Message} from 'zeromq'; -import {Delta} from "./delta.js"; -import {RhizomeNode} from "./node.js"; -import {Subscription} from './pub-sub.js'; -import {PeerRequest, RequestSocket, ResponseSocket} from "./request-reply.js"; +import {Delta} from "./delta"; +import {RhizomeNode} from "./node"; +import {Subscription} from './pub-sub'; +import {PeerRequest, RequestSocket, ResponseSocket} from "./request-reply"; const debug = Debug('rz:peers'); export class PeerAddress { diff --git a/src/pub-sub.ts b/src/pub-sub.ts index c40bee6..83088f3 100644 --- a/src/pub-sub.ts +++ b/src/pub-sub.ts @@ -1,7 +1,7 @@ import Debug from 'debug'; import {Publisher, Subscriber} from 'zeromq'; -import {RhizomeNode} from './node.js'; -import {PeerAddress} from './peers.js'; +import {RhizomeNode} from './node'; +import {PeerAddress} from './peers'; const debug = Debug('rz:pub-sub'); export type SubscribedMessageHandler = (sender: PeerAddress, msg: string) => void; diff --git a/src/request-reply.ts b/src/request-reply.ts index 940776c..11c23f5 100644 --- a/src/request-reply.ts +++ b/src/request-reply.ts @@ -1,8 +1,8 @@ import Debug from 'debug'; import {EventEmitter} from 'node:events'; import {Message, Reply, Request} from 'zeromq'; -import {RhizomeNode} from './node.js'; -import {PeerAddress, RequestMethods} from './peers.js'; +import {RhizomeNode} from './node'; +import {PeerAddress, RequestMethods} from './peers'; const debug = Debug('rz:request-reply'); export type PeerRequest = { diff --git a/src/store.ts b/src/store.ts index f8244b5..85d3838 100644 --- a/src/store.ts +++ b/src/store.ts @@ -1,5 +1,5 @@ import { Level } from 'level'; -import { LEVEL_DB_DIR } from './config.js'; +import { LEVEL_DB_DIR } from './config'; import path from 'path'; function newStore(name: string): Level { diff --git a/src/transactions.ts b/src/transactions.ts index e6db31a..b8abb3e 100644 --- a/src/transactions.ts +++ b/src/transactions.ts @@ -1,8 +1,8 @@ import Debug from "debug"; import EventEmitter from "events"; -import {Delta, DeltaID} from "./delta.js"; -import {Lossless} from "./lossless.js"; -import {DomainEntityID, TransactionID} from "./types.js"; +import {Delta, DeltaID} from "./delta"; +import {Lossless} from "./lossless"; +import {DomainEntityID, TransactionID} from "./types"; const debug = Debug('rz:transactions'); function getDeltaTransactionId(delta: Delta): TransactionID | undefined { diff --git a/src/util/md-files.ts b/src/util/md-files.ts index 1f588e9..3103075 100644 --- a/src/util/md-files.ts +++ b/src/util/md-files.ts @@ -2,7 +2,7 @@ import Debug from "debug"; import {FSWatcher, readdirSync, readFileSync, watch} from "fs"; import path, {join} from "path"; import showdown from "showdown"; -import {RhizomeNode} from "../node.js"; +import {RhizomeNode} from "../node"; const {Converter} = showdown; const debug = Debug('rz:md-files'); diff --git a/tsconfig.json b/tsconfig.json index 49cade1..c482a52 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,17 +1,12 @@ { "compilerOptions": { - "target": "ESNext", - "module": "ESNext", + "target": "ES6", + "module": "CommonJS", "esModuleInterop": true, - "moduleResolution": "bundler", + "moduleResolution": "Node", "sourceMap": false, - "isolatedModules": true, - /* "allowImportingTsExtensions": true, */ - /* "noEmit": true, */ "baseUrl": ".", "outDir": "dist", - "lib": ["ESNext"], - "types": ["node", "jest"], "importsNotUsedAsValues": "remove", "strict": true, "skipLibCheck": true, @@ -24,10 +19,5 @@ "scratch/**/*", "__tests__/**/*" ], - "exclude": [ - "node_modules" - ], - "tsc-alias": { - "resolveFullPaths": true - } + "exclude": ["node_modules"] } diff --git a/util/app.ts b/util/app.ts index 76b15ac..5bbf7e6 100644 --- a/util/app.ts +++ b/util/app.ts @@ -1,5 +1,5 @@ -import {Collection} from "../src/collection.js"; -import {RhizomeNode, RhizomeNodeConfig} from "../src/node.js"; +import {Collection} from "../src/collection"; +import {RhizomeNode, RhizomeNodeConfig} from "../src/node"; const start = 5000; const range = 5000;