Feel free to ask your questions in any of these places:
- Fork the repo at https://github.com/starbeamjs/starbeam/fork
git clone <your repo URL>
cd starbeam
pnpm install
pnpm test:workspace:lint
pnpm test:workspace:lint --fix
At the root of this monorepo, the pnpm demo
script can be used to start the various demos.
pnpm demo react
pnpm demo react-jsnation
pnpm demo react-store
pnpm test
-- Runs cli-based node testspnpm test:prod
-- Runs cli-based node tests in production mode
pnpm test:workspace:types
pnpm test:workspace:lint
pnpm check:unused
pnpm build
-- uses rollup to build out every package
The packages in <repo-root>/workspace
are workspace-private packages that are used to facilitate
testing and building. They are not published to npm.
These are aliased via pnpm dev
at the monorepo root and is an alias for the scripts located at <repo-root>/workspace/scripts/*
.
Common monorepo tasks can be added to <repo-root>/workspace/scripts/*
and then invoke with pnpm dev <command name>
If you're ever unsure about the cache status of each package, you can inspect what turbo thinks is going to happen with
pnpm turbo run list of tasks --dry-run=json \
| jq 'reduce .tasks[] as {$package,$task,$cache} ({};
.[$package][$task] |= $cache
)
'
For example
pnpm turbo run test:lint test:types --dry-run=json \
| jq 'reduce .tasks[] as {$package,$task,$cache} ({};
.[$package][$task] |= $cache
)
'
To use this information with other scripts, pipe it to jq -c
To see what inputs turbo is expecting for a package, use:
pnpm turbo run test:lint --dry-run=json \
| jq 'reduce .tasks[] as {$package,$task,$inputs} ({};
.[$package][$task] |= $inputs
)' \
| jq '."@starbeam/universal"'
This can be useful when debugging either unexpected cache misses, or unexpected cache hits.
The tooling in this repository is driven by a number of keys in package.json
under the starbeam
namespace.
Keys can be nested inside of the starbeam
key, or they can be at the top level of the
package.json
as "starbeam:<key>"
.
The type
field is used to determine which type of package this is. Among other things, it is used
to drive the templating facility (pnpm dev template
) The following types are supported:
library
- A library packagedemo:react
- A demo packageinterfaces
- A package containing interfaces that are shared between packages but don't contain any code that would need to be imported at runtime.support:build
- A package that contains build support code. It should only be used as a dev dependency of packages in the workspace.support:tests
- A package that contains test support code. It should only be used as a dev dependency of test packages in the workspace.draft
- A package that doesn't "work" yet and therefore shouldn't have any transformations, tests or checks applied to it. It should also not be cleaned up.root
- The root of the workspace.unknown
- The default type. This is used for packages that don't have astarbeam:type
field in theirpackage.json
file. This is purely for completeness. Do not check in packages with this type.none
- This is used to indicate that a package should not be processed by the monorepo tooling.
The source
field is used to determine which files in the directory should be treated as input
files.
When a file is treated as an input file:
- the
pnpm dev unused
facility searches them for dependency uses
When a file is not treated as an input file:
- the
pnpm dev clean
facility might delete it if it matches an output pattern (such as.d.ts
, see below)
The following table shows the files that are treated as input files for each type of package:
Source type | .ts |
.tsx |
.js |
.jsx |
.d.ts |
---|---|---|---|---|---|
ts |
✅ | ❌ | ❌ | ❌ | ❌ |
tsx |
✅ | ✅ | ❌ | ❌ | ❌ |
js:untyped |
❌ | ❌ | ✅ | ❌ | ❌ |
js:typed |
❌ | ❌ | ✅ | ❌ | ✅ |
jsx:untyped |
❌ | ❌ | ✅ | ✅ | ❌ |
jsx:typed |
❌ | ❌ | ✅ | ✅ | ✅ |
d.ts |
❌ | ❌ | ❌ | ❌ | ✅ |
A list of packages that should be inlined into this package when built.
The jsx
field is used to determine which JSX factory should be used when building this package.
The tooling only supports the automatic runtime, so only a single value is necessary.
A list of packages that are used by this package, but not otherwise identified by the pnpm dev unused
tooling.
Each entry in the list should be in the format:
{
"reason": "The reason why this package is used",
"packages": ["<name>"]
}
For example:
{
"starbeam:unused": [{ "reason": "tests", "packages": ["vitest"] }]
}