google / google/wireit

Proposal: Allow configuring wireit through .wireitrc.js

Open
#983 15 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
6.4k
Forks
128
Avg merge
4d 10h
Merged PRs (30d)
4

Description

I originally suggested this [here](https://github.com/google/wireit/issues/888#issuecomment-1814695008) in #888. However, I wanted to break it out completely so that it could be reviewed separately.

Currently, wireit is *only* configured through the `wireit` section of the package.json file. This means that the configuration is static.

However, if wireit allowed for `.wireitrc.js` file, then I think an entire eco-system is possible. Some examples of where this is useful:
1. detect the package's dependencies within the same mono-repo and add their build scripts to the `dependencies` array; example: `{ build: {command: 'tsc --build --pretty', dependencies: loadMonorepoDepencies(__dirname,['lint'])}}`
2. create re-usable scripts and script factories - import the script from some library and then use it, example: `build: buildTypescriptFactory({root: __dirname, additionalDependencies: ['lint']})`
3. add/remove dependencies based on build-environment (ie. maybe we choose not to run lint tasks during image creation and only during CI)
4. allow for dynamically defining environment variables

Those are just the use-cases that would be supported by this relatively simple change.

This would also bring wireit into alignment with tools like Jest, ESLint, and many others which, although they allow for configuration through the package.json file, they also support `.js` files which can do similar dynamic tasks.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.