Skip to content

Build Scripts

Lee Yi edited this page Feb 16, 2023 · 1 revision

Build Commands

For modules to be used with Source, they must be transpiled and bundled into Javascript. The modules repository has several scripts for this purpose. Most of these commands can be found in package.json alongside their descriptions.

Common Options

These options can be used with most of the build commands

Option Function
--srcDir Change the directory to access for module source files
--outDir Change the output directory
--manifest Change the manifest file
-v, --verbose Log extra information about the build process
--help Get usage help for the command

Prebuild Options

These options can be used with yarn build, yarn build modules and yarn build tabs

Option Function
--tsc Run the typescript compiler to perform type checking
--lint Run ESLint to detect linting errors
--fix Run ESLint and fix autofixable linting errors

yarn build

This is the primary command to be used. Running this will build bundles, tabs and documentation. yarn build by default will not run typechecking or linting. To run those, use the following options:

Option Function
--tsc Run the typescript compiler to perform type checking
--lint Run ESLint to detect linting errors
--fix Run ESLint and fix autofixable linting errors

If linting or typechecking is specified, and there are errors, the build will not continue.

Specifying specific modules will cause only the bundles, tabs and jsons for those modules to be built: yarn build csg curve repeat will only build the assets from CSG, Curve and Repeat modules.

There are several build subcommands that can be used:

Option Function
yarn build modules Same as yarn build, but will not build documentation
yarn build tabs Will only build all tabs, or specific tabs that the user specifies
yarn build docs Build both HTML and JSON documentation for all modules, or only the ones that the user specifies
yarn build json Build only JSON documentation for all modules, or only the ones that the user specifies
yarn build html Build only HTML documentation

Prebuild Commands

Option Function
yarn lint Run ESLint on all bundles and tabs, or only on specific bundles and tabs
yarn typecheck Run tsc on all bundles and tabs, or only on specific bundles and tabs

To specify which bundles and tabs to run on specifically, use -m to specify modules and -t to specify tabs.

Miscellaneous Commands

Option Function
yarn serve Run the HTTP server to serve module files
yarn watch Run the build system in watch mode to rebuild assets on file changes
yarn test Run jest for module tests

yarn watch will not perform typechecking or linting, but will build documentation, unless --no-docs is specified.

Meta Commands

These are commands related to the build scripts themselves:

Option Function
yarn build:scripts Compile the build scripts and output to scripts/bin
yarn test:scripts Run jest for script tests
yarn lint:scripts Run ESLint for script files

You shouldn't need to use these in regular development, but if you're making changes to the build scripts then these will be the commands to take note of.

Clone this wiki locally