-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
804e59c
commit 638bb64
Showing
7 changed files
with
726 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Contributing | ||
|
||
Thanks for your interest in contributing to this project! We welcome any contributions, including bug reports, feature requests, questions, discussions, code, documentation, tests, or anything else that you think would improve the project. | ||
|
||
PRs for bug fixes can be submitted directly, but PRs for new features should be discussed in an issue first. | ||
|
||
Before you get started, please read the following guidelines. | ||
|
||
## Setup | ||
|
||
1. Fork the repository on GitHub and clone your fork to your local machine. | ||
2. Run `corepack enable` at the repo root to enable Corepack and PNPM. This repo is a PNPM monorepo, so all package manager commands will be PNPM commands. | ||
3. Run `pnpm install` at the repo root to restore all dependencies. | ||
4. Run `pnpm build` at the repo root to build all packages. | ||
5. Run `pnpm test` at the repo root to run all tests. | ||
|
||
## Style | ||
|
||
Please use the following style guide when contributing to this project. | ||
|
||
- Use 2 spaces for indentation. | ||
- Use single quotes for strings. | ||
- Use `camelCase` for variable and function names. | ||
- Use `PascalCase` for class names. | ||
- Use `kebab-case` for filenames. | ||
- Name the file after the class or function it exports. | ||
- Export only one class or function per file. | ||
- Exporting supporting types is also fine. | ||
- Wrap all code at 120 characters (max). | ||
- Use Expect (instead of Assert) syntax for tests. | ||
|
||
This project uses ESLint to check style, but not all rules are strictly enforced, and you should use your best judgment when contributing. | ||
|
||
If you use VSCode (recommended), you can install the [ESLint extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) to get real-time feedback on your code. | ||
|
||
Useful VSCode [Project Settings](.vscode/settings.json): | ||
|
||
```json | ||
{ | ||
"explorer.excludeGitIgnore": true, | ||
"eslint.format.enable": true, | ||
"editor.defaultFormatter": "dbaeumer.vscode-eslint", | ||
"editor.tabSize": 2, | ||
} | ||
``` | ||
|
||
## Test | ||
|
||
Please add/modify tests for any code changes you make. Generally, we want test files to be fairly self contained, so please keep any utilities, fixtures, or constants in the same file as the tests that use them. Test files should be placed in the `__tests__` directory. | ||
|
||
## Merge | ||
|
||
Once you open a PR, it will be reviewed by a maintainer. If the PR is approved, it will be merged. If the PR is not approved, the maintainer will leave a comment explaining why, and possible changes that could be made to get the PR approved. | ||
|
||
After the PR is merged, it will be released in the next version of the project. The next version may not be released immediately, and it may contain changes for several PRs. We will try to release new version in a timely manner. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# Vite Plugin Auto Lib | ||
|
||
Vite plugin that configures sane defaults for building libraries. | ||
|
||
## Getting Started | ||
|
||
Install the plugin: | ||
|
||
```sh | ||
npm install vite-plugin-auto-lib --save-dev | ||
``` | ||
|
||
Add the plugin to your `vite.config.js`: | ||
|
||
```ts | ||
import { defineConfig } from 'vite'; | ||
import { lib } from 'vite-plugin-auto-lib'; | ||
|
||
export default defineConfig({ | ||
plugins: [lib()] | ||
}); | ||
``` | ||
|
||
As long as you have a [common entrypoint](#common-entrypoints) (eg. `src/index.ts`), this should be a working configuration for most libraries. | ||
|
||
Only [defaults](#config-defaults) are provided, so any configuration set by earlier plugins or by the user will be left as-is. | ||
|
||
```ts | ||
export default defineConfig({ | ||
plugins: [lib()], | ||
// Override the auto-detected lib entry. | ||
build: { | ||
lib: { | ||
entry: 'src/foo.ts', | ||
} | ||
} | ||
}); | ||
``` | ||
|
||
## Common Entrypoints | ||
|
||
The plugin will auto detect entrypoints with the following prefixes and extensions: | ||
|
||
- Prefixes: `index`, `bin`, `main`, `src/index`, `src/bin`, `src/main` | ||
- Extensions: `.ts`, `.tsx`, `.mts`, `.cts`, `.js`, `.jsx`, `.mjs`, `.cjs` | ||
|
||
Multiple entrypoints can be detected. However, if the same prefix exists with multiple extensions, only one will be detected as an entrypoint. The extensions are listed in order of priority, with the highest priority first. Therefore, if `index.ts` and `index.tsx` both exist, then `index.ts` will be detected. | ||
|
||
## Config Defaults | ||
|
||
- `build.target`: `'esnext'` | ||
- `build.sourcemap`: `true` | ||
- `build.lib.formats`: Auto-detected from the `type` field in the nearest | ||
`package.json` file. | ||
- `build.lib.fileName`: `'[name]'` | ||
- `build.lib.entry`: Auto-detected at the Vite `root` from a list of common | ||
entry points. | ||
- `build.rollupOptions.treeshake`: `false` | ||
- `build.rollupOptions.external`: Externalizes NodeJS built-ins, native | ||
modules, and production dependencies. | ||
- `build.rollupOptions.output.preserveModules`: `true` | ||
|
||
## Recommended Supplemental Plugins | ||
|
||
- [vite-plugin-checker](https://www.npmjs.com/package/vite-plugin-checker) | ||
- Type checking. | ||
- [vite-plugin-dts](https://www.npmjs.com/package/vite-plugin-dts) | ||
- Type declarations. | ||
- [vite-plugin-bin](https://www.npmjs.com/package/vite-plugin-bin) | ||
- Bin script helper. | ||
- [vite-plugin-data](https://www.npmjs.com/package/vite-plugin-data) | ||
- Build-time data injection. | ||
- [rollup-plugin-node-externals](https://www.npmjs.com/package/rollup-plugin-node-externals) | ||
- More complete and configurable externalization. |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.