clockworklabs / clockworklabs/SpacetimeDB

Modernize typescript package

Open
#3,036 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
25.2k
Forks
1.1k
Avg merge
2d 7h
Merged PRs (30d)
46

Description

TS SDK is currently generated by tsc, which doesn't generate standard module syntax. This is the index.js:

'use strict';
var __createBinding =
	(this && this.__createBinding) ||
	(Object.create
		? function (o, m, k, k2) {
				if (k2 === undefined) k2 = k;
				var desc = Object.getOwnPropertyDescriptor(m, k);
				if (
					!desc ||
					('get' in desc ? !m.__esModule : desc.writable || desc.configurable)
				) {
					desc = {
						enumerable: true,
						get: function () {
							return m[k];
						},
					};
				}
				Object.defineProperty(o, k2, desc);
			}
		: function (o, m, k, k2) {
				if (k2 === undefined) k2 = k;
				o[k2] = m[k];
			});
var __exportStar =
	(this && this.__exportStar) ||
	function (m, exports) {
		for (var p in m)
			if (p !== 'default' && !Object.prototype.hasOwnProperty.call(exports, p))
				__createBinding(exports, m, p);
	};
Object.defineProperty(exports, '__esModule', { value: true });
__exportStar(require('./spacetimedb'), exports);
__exportStar(require('./identity'), exports);
__exportStar(require('./address'), exports);
__exportStar(require('./client_db'), exports);
__exportStar(require('./message_types'), exports);

This isn't standard compliant and more importantly, redundant.

Solution:

Use rollup-based setup to bundle this. We can use https://github.com/egoist/tsup, which uses rollup for bundling(everything in one single JS file rather than multiple), generates d.ts, and sourcemaps all in one go with minimal config. I use it for all my npm packages and can't recommend it enough.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the TS SDK package setup and the generated index.js shown in the issue, then review how tsc currently produces the package. Evaluate a tsup or rollup-based build for bundled JavaScript, declarations, and sourcemaps; done means the package emits standard module syntax and the existing SDK exports remain available.

Written by the indexing model from the issue text.

Assessment

Tech stack
rollup, typescript
Domain
build-system, tooling
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.