Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinigami92 committed Nov 1, 2021
2 parents ac20369 + 852c984 commit d5afd44
Show file tree
Hide file tree
Showing 131 changed files with 4,816 additions and 1,732 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/ci.yml
Expand Up @@ -23,9 +23,9 @@ jobs:
node_version: [12, 14, 16]
include:
- os: macos-latest
node_version: 14
node_version: 16
- os: windows-latest
node_version: 14
node_version: 16
fail-fast: false

name: "Build&Test: node-${{ matrix.node_version }}, ${{ matrix.os }}"
Expand All @@ -34,9 +34,9 @@ jobs:
uses: actions/checkout@v2

- name: Install pnpm
uses: pnpm/action-setup@v2.0.1
uses: pnpm/action-setup@v2
with:
version: 6.15.1
version: 6

- name: Set node version to ${{ matrix.node_version }}
uses: actions/setup-node@v2
Expand Down Expand Up @@ -64,21 +64,21 @@ jobs:

lint:
runs-on: ubuntu-latest
name: "Lint: node-14, ubuntu-latest"
name: "Lint: node-16, ubuntu-latest"
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Install pnpm
uses: pnpm/action-setup@v2.0.1
uses: pnpm/action-setup@v2
with:
version: 6.15.1
version: 6

- name: Set node version to 14
- name: Set node version to 16
uses: actions/setup-node@v2
with:
node-version: 14
node-version: 16
cache: "pnpm"

- name: Install deps
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/issue-close-require.yml
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: need reproduction
uses: actions-cool/issues-helper@v2.4.3
uses: actions-cool/issues-helper@v2
with:
actions: "close-issues"
token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/issue-labeled.yml
Expand Up @@ -10,7 +10,7 @@ jobs:
steps:
- name: contribution welcome
if: github.event.label.name == 'contribution welcome' || github.event.label.name == 'help wanted'
uses: actions-cool/issues-helper@v2.4.3
uses: actions-cool/issues-helper@v2
with:
actions: "create-comment, remove-labels"
token: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -21,7 +21,7 @@ jobs:

- name: remove pending
if: github.event.label.name == 'enhancement' || github.event.label.name == 'bug' || (contains(github.event.label.name, 'pending triage') == false && startsWith(github.event.label.name, 'bug:') == true)
uses: actions-cool/issues-helper@v2.4.3
uses: actions-cool/issues-helper@v2
with:
actions: "remove-labels"
token: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -30,7 +30,7 @@ jobs:

- name: need reproduction
if: github.event.label.name == 'need reproduction'
uses: actions-cool/issues-helper@v2.4.3
uses: actions-cool/issues-helper@v2
with:
actions: "create-comment, remove-labels"
token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
14 changes: 14 additions & 0 deletions CONTRIBUTING.md
Expand Up @@ -15,6 +15,20 @@ To development and test the core `vite` package:
- Run `pnpm link vite` in another Vite project to use the locally built Vite;
- Use the `vite` binary anywhere.

If your project has `vite` as a nested dependency, you can customize the dependency resolution instead depending on the package manager used. For pnpm, add this in your project's root `package.json`:

```json
{
"pnpm": {
"overrides": {
"vite": "link:../path/to/vite/packages/vite"
}
}
}
```

And re-run `pnpm install` to link the package.

## Running Tests

Each package under `packages/playground/` contains a `__tests__` directory. The tests are run using [Jest](https://jestjs.io/) + [Playwright](https://playwright.dev/) with custom integrations to make writing tests simple. The detailed setup is inside `jest.config.js` and `scripts/jest*` files.
Expand Down
19 changes: 13 additions & 6 deletions docs/config/index.md
Expand Up @@ -367,11 +367,11 @@ export default defineConfig(async ({ command, mode }) => {

### server.host

- **Type:** `string`
- **Type:** `string | boolean`
- **Default:** `'127.0.0.1'`

Specify which IP addresses the server should listen on.
Set this to `0.0.0.0` to listen on all addresses, including LAN and public addresses.
Set this to `0.0.0.0` or `true` to listen on all addresses, including LAN and public addresses.

This can be set via the CLI using `--host 0.0.0.0` or `--host`.

Expand Down Expand Up @@ -542,18 +542,16 @@ createServer()

### server.fs.strict

- **Experimental**
- **Type:** `boolean`
- **Default:** `false` (will change to `true` in future versions)
- **Default:** `true` (enabled by default since Vite 2.7)

Restrict serving files outside of workspace root.

### server.fs.allow

- **Experimental**
- **Type:** `string[]`

Restrict files that could be served via `/@fs/`. When `server.fs.strict` is set to `true`, accessing files outside this directory list will result in a 403.
Restrict files that could be served via `/@fs/`. When `server.fs.strict` is set to `true`, accessing files outside this directory list that aren't imported from an allowed file will result in a 403.

Vite will search for the root of the potential workspace and use it as default. A valid workspace met the following conditions, otherwise will fallback to the [project root](/guide/#index-html-and-project-root).

Expand Down Expand Up @@ -593,6 +591,15 @@ createServer()
})
```

### server.fs.deny

- **Experimental**
- **Type:** `string[]`

Blocklist for sensitive files being restricted to be served by Vite dev server.

Default to `['.env', '.env.*', '*.{pem,crt}']`.

### server.origin

- **Type:** `string`
Expand Down
1 change: 1 addition & 0 deletions docs/guide/api-hmr.md
Expand Up @@ -18,6 +18,7 @@ interface ImportMeta {
accept(dep: string, cb: (mod: any) => void): void
accept(deps: string[], cb: (mods: any[]) => void): void

prune(cb: () => void): void
dispose(cb: (data: any) => void): void
decline(): void
invalidate(): void
Expand Down
6 changes: 4 additions & 2 deletions docs/guide/env-and-mode.md
Expand Up @@ -53,13 +53,15 @@ If you want to customize env variables prefix, see [envPrefix](/config/index#env
- Since any variables exposed to your Vite source code will end up in your client bundle, `VITE_*` variables should _not_ contain any sensitive information.
:::

### IntelliSense
### IntelliSense for TypeScript

By default, Vite provides type definition for `import.meta.env`. While you can define more custom env variables in `.env.[mode]` files, you may want to get TypeScript IntelliSense for user-defined env variables which prefixed with `VITE_`.
By default, Vite provides type definition for `import.meta.env` in [`vite/client.d.ts`](https://github.com/vitejs/vite/blob/main/packages/vite/client.d.ts). While you can define more custom env variables in `.env.[mode]` files, you may want to get TypeScript IntelliSense for user-defined env variables which prefixed with `VITE_`.

To achieve, you can create an `env.d.ts` in `src` directory, then augment `ImportMetaEnv` like this:

```typescript
/// <reference types="vite/client" />

interface ImportMetaEnv extends Readonly<Record<string, string>> {
readonly VITE_APP_TITLE: string
// more env variables...
Expand Down
1 change: 1 addition & 0 deletions docs/guide/features.md
Expand Up @@ -295,6 +295,7 @@ Note that:
- This is a Vite-only feature and is not a web or ES standard.
- The glob patterns are treated like import specifiers: they must be either relative (start with `./`) or absolute (start with `/`, resolved relative to project root).
- The glob matching is done via `fast-glob` - check out its documentation for [supported glob patterns](https://github.com/mrmlnc/fast-glob#pattern-syntax).
- You should also be aware that glob imports do not accept variables, you need to directly pass the string pattern.

## WebAssembly

Expand Down
16 changes: 8 additions & 8 deletions docs/guide/index.md
Expand Up @@ -26,14 +26,14 @@ You can try Vite online on [StackBlitz](https://vite.new/). It runs the Vite-bas

The supported template presets are:

| JavaScript | TypeScript |
| :---: | :---: |
| JavaScript | TypeScript |
| :---------------------------------: | :---------------------------------------: |
| [vanilla](https://vite.new/vanilla) | [vanilla-ts](https://vite.new/vanilla-ts) |
| [vue](https://vite.new/vue) | [vue-ts](https://vite.new/vue-ts) |
| [react](https://vite.new/react) | [react-ts](https://vite.new/react-ts) |
| [preact](https://vite.new/preact) | [preact-ts](https://vite.new/preact-ts) |
| [lit](https://vite.new/lit) | [lit-ts](https://vite.new/lit-ts) |
| [svelte](https://vite.new/svelte) | [svelte-ts](https://vite.new/svelte-ts) |
| [vue](https://vite.new/vue) | [vue-ts](https://vite.new/vue-ts) |
| [react](https://vite.new/react) | [react-ts](https://vite.new/react-ts) |
| [preact](https://vite.new/preact) | [preact-ts](https://vite.new/preact-ts) |
| [lit](https://vite.new/lit) | [lit-ts](https://vite.new/lit-ts) |
| [svelte](https://vite.new/svelte) | [svelte-ts](https://vite.new/svelte-ts) |

## Scaffolding Your First Vite Project

Expand Down Expand Up @@ -120,7 +120,7 @@ In a project where Vite is installed, you can use the `vite` binary in your npm
"scripts": {
"dev": "vite", // start dev server
"build": "vite build", // build for production
"serve": "vite preview" // locally preview production build
"preview": "vite preview" // locally preview production build
}
}
```
Expand Down
12 changes: 9 additions & 3 deletions docs/guide/ssr.md
Expand Up @@ -227,7 +227,7 @@ If you have configured aliases that redirects one package to another, you may wa
## SSR-specific Plugin Logic
Some frameworks such as Vue or Svelte compiles components into different formats based on client vs. SSR. To support conditional transforms, Vite passes an additional `ssr` argument to the following plugin hooks:
Some frameworks such as Vue or Svelte compiles components into different formats based on client vs. SSR. To support conditional transforms, Vite passes an additional `ssr` property in the `options` object of the following plugin hooks:
- `resolveId`
- `load`
Expand All @@ -239,15 +239,21 @@ Some frameworks such as Vue or Svelte compiles components into different formats
export function mySSRPlugin() {
return {
name: 'my-ssr',
transform(code, id, ssr) {
if (ssr) {
transform(code, id, options) {
if (options?.ssr) {
// perform ssr-specific transform...
}
}
}
}
```
The options object in `load` and `transform` is optional, rollup is not currently using this object but may extend these hooks with additional metadata in the future.
::: note
Before Vite 2.7, this was informed to plugin hooks with a positional `ssr` param instead of using the `options` object. All major frameworks and plugins are updated but you may find outdated posts using the previous API.
:::
## SSR Target
The default target for the SSR build is a node environment, but you can also run the server in a Web Worker. Packages entry resolution is different for each platform. You can configure the target to be Web Worker using the `ssr.target` set to `'webworker'`.
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/static-deploy.md
Expand Up @@ -10,7 +10,7 @@ The following guides are based on some shared assumptions:
{
"scripts": {
"build": "vite build",
"serve": "vite preview"
"preview": "vite preview"
}
}
```
Expand Down
12 changes: 6 additions & 6 deletions package.json
Expand Up @@ -33,17 +33,17 @@
"@types/jest": "^27.0.2",
"@types/node": "^15.12.2",
"@types/semver": "^7.3.8",
"@typescript-eslint/eslint-plugin": "^4.32.0",
"@typescript-eslint/parser": "^4.32.0",
"@typescript-eslint/eslint-plugin": "^5.2.0",
"@typescript-eslint/parser": "^5.2.0",
"chalk": "^4.1.2",
"conventional-changelog-cli": "^2.1.1",
"cross-env": "^7.0.3",
"eslint": "^7.32.0",
"eslint-define-config": "^1.1.1",
"eslint": "^8.1.0",
"eslint-define-config": "^1.1.2",
"eslint-plugin-node": "^11.1.0",
"execa": "^5.1.1",
"fs-extra": "^10.0.0",
"jest": "^27.2.4",
"jest": "^27.3.1",
"lint-staged": "^11.2.0",
"minimist": "^1.2.5",
"node-fetch": "^2.6.5",
Expand All @@ -54,7 +54,7 @@
"rimraf": "^3.0.2",
"semver": "^7.3.5",
"sirv": "^1.0.17",
"ts-jest": "^27.0.5",
"ts-jest": "^27.0.7",
"ts-node": "^10.1.0",
"typescript": "~4.4.3",
"vitepress": "^0.19.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/create-vite/package.json
Expand Up @@ -31,6 +31,6 @@
"dependencies": {
"kolorist": "^1.5.0",
"minimist": "^1.2.5",
"prompts": "^2.4.1"
"prompts": "^2.4.2"
}
}
6 changes: 3 additions & 3 deletions packages/create-vite/template-lit-ts/package.json
Expand Up @@ -15,10 +15,10 @@
"build": "tsc && vite build"
},
"dependencies": {
"lit": "^2.0.0"
"lit": "^2.0.2"
},
"devDependencies": {
"vite": "^2.6.4",
"typescript": "^4.3.2"
"vite": "^2.6.13",
"typescript": "^4.4.4"
}
}
4 changes: 2 additions & 2 deletions packages/create-vite/template-lit/package.json
Expand Up @@ -13,9 +13,9 @@
"build": "vite build"
},
"dependencies": {
"lit": "^2.0.0"
"lit": "^2.0.2"
},
"devDependencies": {
"vite": "^2.6.4"
"vite": "^2.6.13"
}
}
10 changes: 5 additions & 5 deletions packages/create-vite/template-preact-ts/package.json
Expand Up @@ -4,14 +4,14 @@
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"serve": "vite preview"
"preview": "vite preview"
},
"dependencies": {
"preact": "^10.5.13"
"preact": "^10.5.15"
},
"devDependencies": {
"@preact/preset-vite": "^2.0.0",
"typescript": "^4.3.2",
"vite": "^2.6.4"
"@preact/preset-vite": "^2.1.5",
"typescript": "^4.4.4",
"vite": "^2.6.13"
}
}
8 changes: 4 additions & 4 deletions packages/create-vite/template-preact/package.json
Expand Up @@ -4,13 +4,13 @@
"scripts": {
"dev": "vite",
"build": "vite build",
"serve": "vite preview"
"preview": "vite preview"
},
"dependencies": {
"preact": "^10.5.13"
"preact": "^10.5.15"
},
"devDependencies": {
"@preact/preset-vite": "^2.0.0",
"vite": "^2.6.4"
"@preact/preset-vite": "^2.1.5",
"vite": "^2.6.13"
}
}
16 changes: 8 additions & 8 deletions packages/create-vite/template-react-ts/package.json
Expand Up @@ -4,17 +4,17 @@
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"serve": "vite preview"
"preview": "vite preview"
},
"dependencies": {
"react": "^17.0.0",
"react-dom": "^17.0.0"
"react": "^17.0.2",
"react-dom": "^17.0.2"
},
"devDependencies": {
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
"@vitejs/plugin-react": "^1.0.0",
"typescript": "^4.3.2",
"vite": "^2.6.4"
"@types/react": "^17.0.33",
"@types/react-dom": "^17.0.10",
"@vitejs/plugin-react": "^1.0.7",
"typescript": "^4.4.4",
"vite": "^2.6.13"
}
}

0 comments on commit d5afd44

Please sign in to comment.