Random utilities used by Gradebook
These utilities are tiny convenience packages used throughout Gradebook. As such, we use Lerna to manage each package. All packages are located in the packages directory. Our package manager of choice is Yarn, and we use Yarn Workspaces in conjunction with Lerna.
The core of each package is written in TypeScript, while tests are written in javascript, with type-checking enabled. While TypeScript is our preferred language, the compilation can be time-consuming, and messes with the stack-trace of the file that's being edited. Thus, the compromise is to use TS in the core code, and JS in test code.
Each package has common code-quality scripts:
test
to run the tests (located in the__tests__
folder)test:coverage
to run tests with test coverage enabled. We don't have CI coverage enabled at the moment
The code for each package is written in the src
folder, and compiled to the lib
folder
Note this is changing - see #93, or reach out if you'd like to contribute!
As we are unable to exclusively use ES Modules until at least Node 14.x (becomes LTS), some packages will require compilation to multiple module types.
The standard module type is CommonJS. The tsconfig.json
file in each package should compile to that.
-
Add the additional typescript configurations with the filename
tsconfig.{type}.json
- In each tsconfig, the output folder should be
lib/{target}
- e.g.lib/commonjs
orlib/module
- In each tsconfig, the output folder should be
-
Ensure the
main
andmodule
keys exist inpackage.json
. Main should reference CommonJS and -
Update the
prepublish
script to run../../scripts/compile-all.js
-
Add the
targets
property topackage.json
with a list of additional tsconfig projects- If you want to compile to CommonJS and ESModule, the value would be
["module"]
assuming the secondary config file istsconfig.module.json
- thecompile-all.js
will run tsc usingtsconfig.json
andtsconfig.module.json
- If you want to compile to CommonJS and ESModule, the value would be