Shared repo for compiling services or libraries
The jest.shared.js
file is made to provide certain default values that are shared by all projects. Then each project can customize as needed.
Example config:
import {
getProjectConfig, // Project specific configuration, which files to cover, where tests are to run
rootConfig, // The global configuration. Things like code coverage
} from '../../jest.shared';
const config = {
...rootConfig,
projects: [
getProjectConfig(__dirname),
],
};
export default config;
Yarn constraints used to lint package.json files. Most of the configs are copied from the babel project.
Main constraints rules.
- Sets a standard node engine for all projects. Should be the minimum supported.
- All project versions should be 0.0.0, as we use semantic release for versioning
- Any packages that use other packages should use
workspace:^
as the version - All non-private packages should be using the 'MIT' license
- All repos should have a repository field
- The author field should always be set to
LifeOmic <[email protected]>
- Dependencies shouldn't show up in both the
dependencies
anddevDependencies
sections main
andtypes
fields should start with./
- The
main
field should leave off the file extension. If the file extension is set to.js
then tests will fail when importing parallel workspaces. Currentlyts-jest
is not able to handle typescript files inpnp
packages, so we are using@swc-node/jest
to transform typescript files - The
types
field should leave off the.d.ts
extension while developing. This is again for testing inter-package dependencies.
Constraints to be used when ready to actually publish
- Updates the
main
field to end with.js
- Updates the
types
field to end with.d.ts
semantic-release is being used to handle the git tags, and github release publishing.
The version created by semantic-release is then used to version the local packages.
Finally, we use yarn workspaces foreach --no-private npm publish
to publish each of the packages to NPM.