Skip to content

Commit

Permalink
Merge branch 'main' into pr/sheremet-va/14208
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy committed Sep 11, 2023
2 parents 5fe4dc9 + eda0d0a commit 1139d04
Show file tree
Hide file tree
Showing 60 changed files with 1,008 additions and 530 deletions.
20 changes: 20 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,26 @@ We already have many config options, and we should avoid fixing an issue by addi
- has workaround using existing options
- can be addressed with a plugin instead

## Release

If you have publish access, the steps below explain how to cut a release for a package. There are two phases for the release step: "Release" and "Publish".

"Release" is done locally to generate the changelogs and git tags:

1. Make sure the git remote for https://github.com/vitejs/vite is set as `origin`.
2. In the `vite` project root `main` branch, run `git pull` and `pnpm i` to get it up-to-date.
3. Run `pnpm release` and follow the prompts to cut a release for a package. It will generate the changelog, a git release tag, and push them to `origin`. You can run with the `--dry` flag to test it out.
4. When the command finishes, it will provide a link to https://github.com/vitejs/vite/actions/workflows/publish.yml.
5. Click the link to visit the page, and follow the next steps below.

"Publish" is done on GitHub Actions to publish the package to npm:

1. Shortly in the workflows page, a new workflow will appear for the released package and is waiting for approval to publish to npm.
2. Click on the workflow to open its page.
3. Click on the "Review deployments" button in the yellow box, a popup will appear.
4. Check "Release" and click "Approve and deploy".
5. The package will start publishing to npm.

## Docs Translation Contribution

To add a new language to the Vite docs, see [`vite-docs-template`](https://github.com/tony19/vite-docs-template/blob/main/.github/CONTRIBUTING.md).
2 changes: 1 addition & 1 deletion docs/config/server-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Configure custom proxy rules for the dev server. Expects an object of `{ key: op

Note that if you are using non-relative [`base`](/config/shared-options.md#base), you must prefix each key with that `base`.

Extends [`http-proxy`](https://github.com/http-party/node-http-proxy#options). Additional options are [here](https://github.com/vitejs/vite/blob/main/packages/vite/src/node/server/middlewares/proxy.ts#L13).
Extends [`http-proxy`](https://github.com/http-party/node-http-proxy#options). Additional options are [here](https://github.com/vitejs/vite/blob/main/packages/vite/src/node/server/middlewares/proxy.ts#L12).

In some cases, you might also want to configure the underlying dev server (e.g. to add custom middlewares to the internal [connect](https://github.com/senchalabs/connect) app). In order to do that, you need to write your own [plugin](/guide/using-plugins.html) and use [configureServer](/guide/api-plugin.html#configureserver) function.

Expand Down
10 changes: 10 additions & 0 deletions docs/guide/api-javascript.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const __dirname = fileURLToPath(new URL('.', import.meta.url))
await server.listen()
server.printUrls()
server.bindCLIShortcuts({ print: true })
})()
```

Expand Down Expand Up @@ -139,6 +140,10 @@ interface ViteDevServer {
* Stop the server.
*/
close(): Promise<void>
/**
* Bind CLI shortcuts
*/
bindCLIShortcuts(options?: BindCLIShortcutsOptions<ViteDevServer>): void
}
```
Expand Down Expand Up @@ -196,6 +201,7 @@ import { preview } from 'vite'
})
previewServer.printUrls()
previewServer.bindCLIShortcuts({ print: true })
})()
```

Expand Down Expand Up @@ -229,6 +235,10 @@ interface PreviewServer {
* Print server urls
*/
printUrls(): void
/**
* Bind CLI shortcuts
*/
bindCLIShortcuts(options?: BindCLIShortcutsOptions<PreviewServer>): void
}
```

Expand Down
4 changes: 4 additions & 0 deletions docs/guide/api-plugin.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
outline: [2, 3]
---

# Plugin API

Vite plugins extends Rollup's well-designed plugin interface with a few extra Vite-specific options. As a result, you can write a Vite plugin once and have it work for both dev and build.
Expand Down
4 changes: 4 additions & 0 deletions docs/guide/features.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
outline: [2, 3]
---

# Features

At the very basic level, developing using Vite is not that much different from using a static file server. However, Vite provides many enhancements over native ESM imports to support various features that are typically seen in bundler-based setups.
Expand Down
10 changes: 7 additions & 3 deletions docs/guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,17 @@ $ yarn create vite
$ pnpm create vite
```

```bash [Bun]
$ bunx create-vite
```

:::

Then follow the prompts!

You can also directly specify the project name and the template you want to use via additional command line options. For example, to scaffold a Vite + Vue project, run:

```bash
# npm 6.x
npm create vite@latest my-vue-app --template vue

# npm 7+, extra double-dash is needed:
npm create vite@latest my-vue-app -- --template vue

Expand All @@ -77,6 +78,9 @@ yarn create vite my-vue-app --template vue

# pnpm
pnpm create vite my-vue-app --template vue

# bun
bunx create-vite my-vue-app --template vue
```

See [create-vite](https://github.com/vitejs/vite/tree/main/packages/create-vite) for more details on each supported template: `vanilla`, `vanilla-ts`, `vue`, `vue-ts`, `react`, `react-ts`, `react-swc`, `react-swc-ts`, `preact`, `preact-ts`, `lit`, `lit-ts`, `svelte`, `svelte-ts`, `solid`, `solid-ts`, `qwik`, `qwik-ts`.
Expand Down
23 changes: 12 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,11 @@
"ci-docs": "run-s build docs-build"
},
"devDependencies": {
"@babel/types": "^7.22.5",
"@babel/types": "^7.22.17",
"@microsoft/api-extractor": "^7.36.3",
"@rollup/plugin-typescript": "^11.1.2",
"@types/babel__core": "^7.20.1",
"@types/babel__preset-env": "^7.9.2",
"@types/babel__standalone": "^7.1.4",
"@types/convert-source-map": "^2.0.0",
"@types/cross-spawn": "^6.0.2",
"@types/debug": "^4.1.8",
Expand All @@ -58,28 +57,25 @@
"@types/micromatch": "^4.0.2",
"@types/node": "^18.17.3",
"@types/picomatch": "^2.3.0",
"@types/resolve": "^1.20.2",
"@types/sass": "~1.43.1",
"@types/stylus": "^0.48.38",
"@types/ws": "^8.5.5",
"@typescript-eslint/eslint-plugin": "^6.2.1",
"@typescript-eslint/parser": "^6.2.1",
"@vitejs/release-scripts": "^1.2.1",
"@vitejs/release-scripts": "^1.3.0",
"conventional-changelog-cli": "^3.0.0",
"eslint": "^8.46.0",
"eslint-define-config": "^1.23.0",
"eslint-plugin-import": "^2.28.0",
"eslint-plugin-n": "^16.0.1",
"eslint-plugin-regexp": "^1.15.0",
"execa": "^8.0.1",
"fast-glob": "^3.3.1",
"fs-extra": "^11.1.1",
"lint-staged": "^14.0.1",
"npm-run-all": "^4.1.5",
"picocolors": "^1.0.0",
"playwright-chromium": "^1.36.2",
"prettier": "3.0.1",
"resolve": "^1.22.4",
"rimraf": "^5.0.1",
"rollup": "^3.28.0",
"simple-git-hooks": "^2.9.0",
Expand Down Expand Up @@ -119,17 +115,22 @@
"peerDependencies": {
"acorn": "*"
}
},
"postcss-load-config": {
"peerDependencies": {
"postcss": "*"
}
}
},
"patchedDependencies": {
"[email protected]": "patches/[email protected]",
"[email protected]": "patches/[email protected]",
"[email protected]": "patches/[email protected]"
},
"peerDependencyRules": {
"allowedVersions": {
"vite": "*"
},
"ignoreMissing": [
"@algolia/client-search",
"postcss",
"search-insights"
]
}
},
"stackblitz": {
Expand Down
14 changes: 10 additions & 4 deletions packages/create-vite/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# create-vite
# create-vite <a href="https://npmjs.com/package/create-vite"><img src="https://img.shields.io/npm/v/create-vite" alt="npm package"></a>

## Scaffolding Your First Vite Project

Expand All @@ -23,14 +23,17 @@ With PNPM:
$ pnpm create vite
```

With Bun:

```bash
$ bunx create-vite
```

Then follow the prompts!

You can also directly specify the project name and the template you want to use via additional command line options. For example, to scaffold a Vite + Vue project, run:

```bash
# npm 6.x
npm create vite@latest my-vue-app --template vue

# npm 7+, extra double-dash is needed:
npm create vite@latest my-vue-app -- --template vue

Expand All @@ -39,6 +42,9 @@ yarn create vite my-vue-app --template vue

# pnpm
pnpm create vite my-vue-app --template vue

# Bun
bunx create-vite my-vue-app --template vue
```

Currently supported template presets include:
Expand Down
2 changes: 1 addition & 1 deletion packages/create-vite/template-svelte-ts/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
"checkJs": true,
"isolatedModules": true
},
"include": ["src/**/*.d.ts", "src/**/*.ts", "src/**/*.js", "src/**/*.svelte"],
"include": ["src/**/*.ts", "src/**/*.js", "src/**/*.svelte"],
"references": [{ "path": "./tsconfig.node.json" }]
}
2 changes: 1 addition & 1 deletion packages/create-vite/template-vue-ts/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"],
"references": [{ "path": "./tsconfig.node.json" }]
}
2 changes: 1 addition & 1 deletion packages/plugin-legacy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ npm add -D terser
- **Type:** `boolean | string[]`
- **Default:** `false`

Defaults to `false`. Enabling this option will generate a separate polyfills chunk for the modern build (targeting browsers with [native ESM support](https://caniuse.com/es6-module)).
Defaults to `false`. Enabling this option will generate a separate polyfills chunk for the modern build (targeting [browsers that support widely-available features](#browsers-that-supports-esm-but-does-not-support-widely-available-features)).

Set to a list of strings to explicitly control which polyfills to include. See [Polyfill Specifiers](#polyfill-specifiers) for details.

Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-legacy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"homepage": "https://github.com/vitejs/vite/tree/main/packages/plugin-legacy#readme",
"funding": "https://github.com/vitejs/vite?sponsor=1",
"dependencies": {
"@babel/core": "^7.22.9",
"@babel/core": "^7.22.17",
"@babel/preset-env": "^7.22.9",
"browserslist": "^4.21.10",
"core-js": "^3.32.0",
Expand Down
20 changes: 20 additions & 0 deletions packages/vite/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
## 5.0.0-beta.1 (2023-09-08)

* perf: reduce one if judgment (#14329) ([09ba7c6](https://github.com/vitejs/vite/commit/09ba7c6)), closes [#14329](https://github.com/vitejs/vite/issues/14329)
* perf: replace startsWith with === (#14300) ([75cd29c](https://github.com/vitejs/vite/commit/75cd29c)), closes [#14300](https://github.com/vitejs/vite/issues/14300)
* fix: add source map to Web Workers (fix #14216) (#14217) ([6f86de3](https://github.com/vitejs/vite/commit/6f86de3)), closes [#14216](https://github.com/vitejs/vite/issues/14216) [#14217](https://github.com/vitejs/vite/issues/14217)
* fix: handle sourcemap correctly when multiple line import exists (#14232) ([627159d](https://github.com/vitejs/vite/commit/627159d)), closes [#14232](https://github.com/vitejs/vite/issues/14232)
* fix: include `vite/types/*` in exports field (#14296) ([66a97be](https://github.com/vitejs/vite/commit/66a97be)), closes [#14296](https://github.com/vitejs/vite/issues/14296)
* fix: use string manipulation instead of regex to inject esbuild helpers (#14094) ([91a18c2](https://github.com/vitejs/vite/commit/91a18c2)), closes [#14094](https://github.com/vitejs/vite/issues/14094)
* fix(cli): convert special base (#14283) ([34826aa](https://github.com/vitejs/vite/commit/34826aa)), closes [#14283](https://github.com/vitejs/vite/issues/14283)
* fix(css): remove pure css chunk sourcemap (#14290) ([2b80089](https://github.com/vitejs/vite/commit/2b80089)), closes [#14290](https://github.com/vitejs/vite/issues/14290)
* fix(css): reset render cache on renderStart (#14326) ([19bf0f1](https://github.com/vitejs/vite/commit/19bf0f1)), closes [#14326](https://github.com/vitejs/vite/issues/14326)
* fix(css): spread lightningcss options (#14313) ([80c6608](https://github.com/vitejs/vite/commit/80c6608)), closes [#14313](https://github.com/vitejs/vite/issues/14313)
* fix(optimizer): define crawlDeps after scanProcessing and optimizationResult are complete (fix #1428 ([c5f6558](https://github.com/vitejs/vite/commit/c5f6558)), closes [#14284](https://github.com/vitejs/vite/issues/14284) [#14285](https://github.com/vitejs/vite/issues/14285)
* fix(vite): precisely check if files are in dirs (#14241) ([245d186](https://github.com/vitejs/vite/commit/245d186)), closes [#14241](https://github.com/vitejs/vite/issues/14241)
* fix!: update node types peer dep range (#14280) ([8f87e86](https://github.com/vitejs/vite/commit/8f87e86)), closes [#14280](https://github.com/vitejs/vite/issues/14280)
* feat: export `server.bindCLIShortcuts` (#13675) ([1a2e5e6](https://github.com/vitejs/vite/commit/1a2e5e6)), closes [#13675](https://github.com/vitejs/vite/issues/13675)
* revert: "fix(css): spread lightningcss options (#14024)" (#14209) ([5778365](https://github.com/vitejs/vite/commit/5778365)), closes [#14024](https://github.com/vitejs/vite/issues/14024) [#14209](https://github.com/vitejs/vite/issues/14209)



## 5.0.0-beta.0 (2023-08-24)

* feat!: allow path containing . to fallback to index.html (#14142) ([1ae4cbd](https://github.com/vitejs/vite/commit/1ae4cbd)), closes [#14142](https://github.com/vitejs/vite/issues/14142)
Expand Down
2 changes: 2 additions & 0 deletions packages/vite/api-extractor.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

"mainEntryPointFilePath": "./temp/node/index.d.ts",

"bundledPackages": ["lightningcss"],

"dtsRollup": {
"enabled": true,
"untrimmedFilePath": "",
Expand Down
11 changes: 7 additions & 4 deletions packages/vite/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vite",
"version": "5.0.0-beta.0",
"version": "5.0.0-beta.1",
"type": "module",
"license": "MIT",
"author": "Evan You",
Expand Down Expand Up @@ -28,6 +28,9 @@
"types": "./client.d.ts"
},
"./dist/client/*": "./dist/client/*",
"./types/*": {
"types": "./types/*"
},
"./package.json": "./package.json"
},
"files": [
Expand Down Expand Up @@ -57,7 +60,7 @@
"build-types": "run-s build-types-temp build-types-pre-patch build-types-roll build-types-post-patch build-types-check",
"build-types-temp": "tsc --emitDeclarationOnly --outDir temp/node -p src/node",
"build-types-pre-patch": "tsx scripts/prePatchTypes.ts",
"build-types-roll": "api-extractor run && rimraf temp",
"build-types-roll": "tsx scripts/api-extractor.ts run && rimraf temp",
"build-types-post-patch": "tsx scripts/postPatchTypes.ts",
"build-types-check": "tsx scripts/checkBuiltTypes.ts && tsc --project tsconfig.check.json",
"typecheck": "tsc --noEmit",
Expand All @@ -77,7 +80,7 @@
"devDependencies": {
"@ampproject/remapping": "^2.2.1",
"@babel/parser": "^7.22.7",
"@babel/types": "^7.22.5",
"@babel/types": "^7.22.17",
"@jridgewell/trace-mapping": "^0.3.18",
"@rollup/plugin-alias": "^4.0.4",
"@rollup/plugin-commonjs": "^25.0.3",
Expand Down Expand Up @@ -136,7 +139,7 @@
"ws": "^8.13.0"
},
"peerDependencies": {
"@types/node": ">= 14",
"@types/node": "^18.0.0 || >=20.0.0",
"less": "*",
"lightningcss": "^1.21.0",
"sass": "*",
Expand Down
25 changes: 25 additions & 0 deletions packages/vite/scripts/api-extractor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Extractor, ExtractorConfig } from '@microsoft/api-extractor'

const result = Extractor.invoke(
ExtractorConfig.loadFileAndPrepare('./api-extractor.json'),
{
messageCallback: (message) => {
const ignore = () => {
// @ts-expect-error TS requires to use the const enum, which is not available as the named export in tsx
message.logLevel = 'none'
}
if (message.sourceFilePath?.includes('lightningcss')) {
ignore()
}
if (message.messageId === 'ae-forgotten-export') {
if (message.sourceFilePath?.endsWith('/src/types/lightningcss.d.ts')) {
// We only expose LightningCSS types via prefixed types to avoid
// having confusing name like "Targets" in Vite types
ignore()
}
}
},
},
)

if (!result.succeeded) process.exit(1)
4 changes: 1 addition & 3 deletions packages/vite/scripts/checkBuiltTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ const distDir = resolve(dir, '../dist')
const pkgJson = JSON.parse(
readFileSync(resolve(dir, '../package.json'), 'utf-8'),
)
const deps = new Set(
Object.keys(Object.assign(pkgJson.dependencies, pkgJson.peerDependencies)),
)
const deps = new Set(Object.keys(pkgJson.dependencies))

type SpecifierError = {
loc: SourceLocation | null | undefined
Expand Down
Loading

0 comments on commit 1139d04

Please sign in to comment.