Skip to content

Commit

Permalink
create contribution docs
Browse files Browse the repository at this point in the history
  • Loading branch information
lilioid committed Sep 15, 2022
1 parent 269eacc commit 1032838
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
57 changes: 57 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Welcome to the contributing guide

Contributions are always welcome.

If you have an idea for improvement or think something is wrong please create an issue in our [Issue Tracker](https://github.com/Viva-con-Agua/vite-plugin-runtime-config/issues).

# Build and Release Infrastructure docs

This section documents how the build system of this project is configured and explains why it was done so.
It also explains how new releases can be created.

## Builds

The distribution of this package include a few different kinds of artifacts.
Their build scripts are defined inside the [package.json](./package.json) and tied together under one script simply called `build`.
This will produce the following assets:

- `build:compile_ts` produces `dist/*.js` and `dist/*.d.ts`

This script compiles typescript (configured via [tsconfig.json](./tsconfig.json)) using the normal typescript compiler to produce EcmaScript module javascript as well as corresponding declaration files.
EcmaScript modules are the most recent and recommended module format which is why they are used.

- `build:bundle_plugin_entry` produces `dist/index.cjs`

In addition to EcmaScript module code, [index.ts](./src/index.ts) which forms the vite plugin entrypoint is also bundled into one CommonJS module.
This is required because most vue starter project configure typescript to resolve imports from `vite.config.ts` as node modules which currently still requires the CommonJS format.

- `build:bundle_patch_script` produces `dist/assets/patch_runtime_config.js`

This is the patch script that gets emitted when a user calls `vite build`.
It is generated from [script_entrypoint.ts](./src/script_entrypoint.ts) and does not require any external dependencies since everything is bundled into the script.
This is to make the script as portable as possible while still using the same source code ([patch_html.ts](./src/patch_html.ts)) as is used when running vite during development.

- `build:bundle_patch_bin:*` produces `dist/assets/patch_runtime_config.*.bin`

These are binary programs that not only bundle javascript dependencies but also nodejs itself.
They are required if a user wishes to perform configuration key replacement in an environment where node is not installed.
The build script generates these binaries using _pkg_ from `dist/assets/patch_runtime_config.js`.

## Releases

Releases are automatically performed via GitHub actions (workflow source [here](./.github/workflows/release.yml)) whenever a tag is pushed.
It also appends the tag subject and body as release body.

To author a release, the following steps need to be performed locally:

1. Bump version in [package.json](./package.json)
2. Create a commit with the bumped version.
3. Create git tag with the following command where _X.X.X_ is the new version.
```shell
git tag -a vX.X.X
```
4. Push the commit as well as the tag.
```shell
git push
git push --tags
```
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,10 @@ You can look in there for inspiration.
## Api

The most relevant API for users are [plugin options](./src/options.ts), [testing utilities](./src/testing.ts) and [replacer program arguments](./src/script_entrypoint.ts).

Additionally, the whole project is authored in typescript and type declaration files are distributed as part of our releases.
Your IDE should pick this up pretty well and offer you good autocompletion and documentation.

## Contributing

See [CONTRIBUTING.md](./CONTRIBUTING.md) for more details.

0 comments on commit 1032838

Please sign in to comment.