forked from vitejs/vite
-
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
Showing
23 changed files
with
1,552 additions
and
550 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,30 @@ | ||
# Vite Maintenance Principles | ||
|
||
## Ensure type support | ||
|
||
Vite aims to be fully usable as a dependency in a TypeScript project (e.g. it should provide proper typings for VitePress), and also in `vite.config.ts`. This means any types that are exposed needs to be part of `dependencies` instead of `devDependencies`. For example, if a config option uses an imported type from a `@types/x` package, that type package should be included as a dependency (e.g. `@types/http-proxy`) | ||
|
||
On the contrary, if a dependency's type isn't exposed, then its typing should be left in `devDependencies` to reduce user dependency downloads (e.g. `@types/ws`). | ||
|
||
## Think before adding a dependency | ||
|
||
Vite aims to be lightweight, and this includes being aware of the number of npm dependencies and their size. | ||
|
||
Note we pre-bundle most dependencies with rollup before publishing! Therefore most non-type dependencies should be added under `devDependencies` by default. | ||
|
||
Avoid dependencies that: | ||
|
||
- Cannot be properly bundled due to native deps. If it must be included due to critical functionality, put it under `dependencies` (auto excluded during rollup build). Example: `esbuild`. | ||
|
||
- Simple enought that it can be substituted with a local helper (e.g. one-function packages like `p-map-series`) | ||
|
||
- Has large transitive dependencies that results in bloated `node_modules` size compared to the functionality it provides. For example, `http-proxy` itself plus `@types/http-proxy` is a little over 1MB in size, but `http-proxy-middleware` pulls in a ton of dependencies that makes it 7MB(!) when a minimal custom middleware on top of `http-proxy` only requires a couple lines of code. | ||
|
||
## Think before adding yet another option | ||
|
||
We already have many config options, and we should avoid fixing an issue by adding yet another one. Before adding an option, try to think about: | ||
|
||
- Whether the problem is really worth addressing | ||
- Whether the problem can be fixed with a smarter default | ||
- Whether the problem has workaround using existing options | ||
- Whether the problem can be addressed with a plugin instead |
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 |
---|---|---|
|
@@ -2,9 +2,10 @@ | |
node_modules | ||
dist | ||
dist-ssr | ||
dist-types | ||
TODOs.md | ||
*.log | ||
temp | ||
explorations | ||
.idea | ||
*.local | ||
*.local |
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
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<h1>hello</h1> | ||
<h1>hello???fesf?</h1> | ||
<img src="/logo.png" alt=""> | ||
<script type="module" src="/test.js"></script> |
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
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 |
---|---|---|
@@ -1,5 +1,9 @@ | ||
export function hi() { | ||
console.log('hi') | ||
fetch('/api/todos/1') | ||
.then((res) => res.json()) | ||
.then((data) => { | ||
console.log(data) | ||
}) | ||
} | ||
|
||
hi() |
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,13 @@ | ||
import { defineConfig } from 'vite' | ||
|
||
export default defineConfig({ | ||
server: { | ||
proxy: { | ||
'/api': { | ||
target: 'http://jsonplaceholder.typicode.com', | ||
changeOrigin: true, | ||
rewrite: (path) => path.replace(/^\/api/, '') | ||
} | ||
} | ||
} | ||
}) |
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,53 @@ | ||
{ | ||
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", | ||
|
||
"projectFolder": "./src/node", | ||
|
||
"mainEntryPointFilePath": "./dist-types/node/index.d.ts", | ||
|
||
"dtsRollup": { | ||
"enabled": true, | ||
"publicTrimmedFilePath": "./dist/<unscopedPackageName>.d.ts" | ||
}, | ||
|
||
"apiReport": { | ||
"enabled": false | ||
}, | ||
|
||
"docModel": { | ||
"enabled": false | ||
}, | ||
|
||
"tsdocMetadata": { | ||
"enabled": false | ||
}, | ||
|
||
"messages": { | ||
"compilerMessageReporting": { | ||
"default": { | ||
"logLevel": "warning" | ||
} | ||
}, | ||
|
||
"extractorMessageReporting": { | ||
"default": { | ||
"logLevel": "warning", | ||
"addToApiReportFile": true | ||
}, | ||
|
||
"ae-missing-release-tag": { | ||
"logLevel": "none" | ||
} | ||
}, | ||
|
||
"tsdocMessageReporting": { | ||
"default": { | ||
"logLevel": "warning" | ||
}, | ||
|
||
"tsdoc-undefined-tag": { | ||
"logLevel": "none" | ||
} | ||
} | ||
} | ||
} |
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.