Contributing¶
Contributions are welcome! This project is configured with:
-
pnpmas the package manager. -
TypeScript for compile-time type safety.
-
tsupfor bundling the code into multiple formats: - esm
- cjs
-
iife (for CDN usage)
-
Vitest as the test runner.
-
ESLint/Prettier for maintaining code quality and style.
-
Changesets for versioning and changelog management.
-
TypeDoc for SDK documentation.
Getting Started¶
-
Fork the repository.
-
Run the setup script (recommended):
If you prefer manual setup, ensure you are using node version >= 22.14.0 and pnpm version 10.8.0
-
Create a new feature branch.
-
Make your changes and commit with clear messages.
-
Open a pull request with a description of your changes.
-
Before submitting a PR, make sure to format, lint, and test:
Testing SDK Builds Locally¶
To test the local SDK builds across different module formats by creating temporary files in a temp folder and importing from the dist directory.
This ensures the bundle works correctly in Node.js (CommonJS, ESM) and in the browser (IIFE).
CommonJS (Node.js)¶
Create a file temp/test-cjs.js:
const { Beam } = require('./dist/index.js');
const beam = await Beam.init({
cid: 'YOUR_CUSTOMER_ID',
pid: 'YOUR_PROJECT_ID',
});
console.log(beam.player.id);
Run:
ES Modules (Node.js)¶
Create a file temp/test-esm.mjs:
import { Beam } from './dist/index.mjs';
const beam = await Beam.init({
cid: 'YOUR_CUSTOMER_ID',
pid: 'YOUR_PROJECT_ID',
});
console.log(beam.player.id);
Run:
Browser (IIFE)¶
Create an HTML file temp/test-iife.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Beam SDK Test</title>
</head>
<body>
<!-- Load the IIFE bundle; exposes a global `Beam` symbol -->
<script src="../dist/index.global.js"></script>
<script>
// Instantiate the SDK via the `Beam` constructor
const { Beam, BeamEnvironment } = Beamable;
const beam = await Beam.init({
cid: 'YOUR_CUSTOMER_ID',
pid: 'YOUR_PROJECT_ID',
// Environment must be one of: 'Dev', 'Stg', or 'Prod'
environment: 'Prod',
});
// List all built-in environments:
console.log(BeamEnvironment.list());
// Display current player id:
console.log(beam.player.id);
</script>
</body>
</html>
Open the file in your browser and watch the console for output.
Releasing & Versioning¶
We use changesets for versioning. To create a changeset, run:
When we are ready to release, update the version and build: