Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modernize typescript package #49

Open
PuruVJ opened this issue Jun 30, 2024 · 0 comments
Open

Modernize typescript package #49

PuruVJ opened this issue Jun 30, 2024 · 0 comments
Assignees

Comments

@PuruVJ
Copy link
Collaborator

PuruVJ commented Jun 30, 2024

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.

@PuruVJ PuruVJ self-assigned this Jun 30, 2024
@PuruVJ PuruVJ mentioned this issue Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant