Skip to content

Commit

Permalink
chore: merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev committed Jun 17, 2022
2 parents 50e0923 + f586b14 commit 6ab220f
Show file tree
Hide file tree
Showing 289 changed files with 4,669 additions and 2,927 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.cjs
Expand Up @@ -155,7 +155,7 @@ module.exports = defineConfig({
}
},
{
files: ['*.js'],
files: ['playground/**', '*.js'],
rules: {
'@typescript-eslint/explicit-module-boundary-types': 'off'
}
Expand Down
10 changes: 2 additions & 8 deletions .github/renovate.json5
Expand Up @@ -19,15 +19,9 @@
"typescript",

// breaking changes
"cac", // `cac:v6.7.10+` has breaking changes
"react-router", // `react-router:v6.0.0+` has breaking changes
"react-router-dom", // `react-router-dom:v6.0.0+` has breaking changes
"source-map", // `source-map:v0.7.0+` needs more investigation
"dotenv-expand", // `dotenv-expand:6.0.0+` has breaking changes (#6858)

// ESM Only => https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c#how-can-i-move-my-commonjs-project-to-esm
"node-fetch",
"periscopic",
"strip-ansi"
"kill-port", // `kill-port:^2.0.0 has perf issues (#8392)
"miniflare" // `miniflare:v2.0.0+` only supports node 16.7
]
}
27 changes: 20 additions & 7 deletions .github/workflows/ci.yml
Expand Up @@ -4,6 +4,8 @@ env:
# 7 GiB by default on GitHub, setting to 6 GiB
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
NODE_OPTIONS: --max-old-space-size=6144
# install playwright binary manually (because pnpm only runs install script once)
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "1"

on:
push:
Expand Down Expand Up @@ -38,10 +40,6 @@ jobs:
node_version: 16
fail-fast: false

env:
# Install playwright's binray under node_modules so it will be cached together
PLAYWRIGHT_BROWSERS_PATH: "0"

name: "Build&Test: node-${{ matrix.node_version }}, ${{ matrix.os }}"
steps:
- name: Checkout
Expand All @@ -59,8 +57,25 @@ jobs:
- name: Install deps
run: pnpm install

# Install playwright's binary under custom directory to cache
- name: Set Playwright path (non-windows)
if: runner.os != 'Windows'
run: echo "PLAYWRIGHT_BROWSERS_PATH=$HOME/.cache/playwright-bin" >> $GITHUB_ENV
- name: Set Playwright path (windows)
if: runner.os == 'Windows'
run: echo "PLAYWRIGHT_BROWSERS_PATH=$HOME\.cache\playwright-bin" >> $env:GITHUB_ENV

- name: Cache Playwright's binary
uses: actions/cache@v3
with:
# Playwright removes unused browsers automatically
# So does not need to add playwright version to key
key: ${{ runner.os }}-playwright-bin-v1
path: ${{ env.PLAYWRIGHT_BROWSERS_PATH }}

- name: Install Playwright
run: pnpm playwright install
# does not need to explictly set chromium after https://github.com/microsoft/playwright/issues/14862 is solved
run: pnpm playwright install chromium

- name: Build
run: pnpm run build
Expand Down Expand Up @@ -97,8 +112,6 @@ jobs:

- name: Install deps
run: pnpm install
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "1"

- name: Build
run: pnpm run build
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -13,3 +13,4 @@ node_modules
playground-temp
temp
TODOs.md
.eslintcache
4 changes: 1 addition & 3 deletions docs/.vitepress/config.ts
Expand Up @@ -14,9 +14,7 @@ export default defineConfig({
logo: '/logo.svg',

editLink: {
repo: 'vitejs/vite',
branch: 'main',
dir: 'docs',
pattern: 'https://github.com/vitejs/vite/edit/main/docs/:path',
text: 'Suggest changes to this page'
},

Expand Down
6 changes: 6 additions & 0 deletions docs/config/build-options.md
Expand Up @@ -147,6 +147,12 @@ Set to `false` to disable minification, or specify the minifier to use. The defa

Note the `build.minify` option is not available when using the `'es'` format in lib mode.

Terser must be installed when it is set to `'terser'`.

```sh
npm add -D terser
```

## build.terserOptions

- **Type:** `TerserOptions`
Expand Down
18 changes: 7 additions & 11 deletions docs/config/index.md
Expand Up @@ -24,14 +24,14 @@ vite --config my-config.js
```

::: tip NOTE
Vite will replace `__filename`, `__dirname`, and `import.meta.url` in config files and its deps. Using these as variable names or passing as a parameter to a function with string double quote (example `console.log`) will result in an error:
Vite will inject `__filename`, `__dirname` in config files and its deps. Declaring these variables at top level will result in an error:

```js
const __filename = "value"
// will be transformed to
const "path/vite.config.js" = "value"
const __filename = 'value' // SyntaxError: Identifier '__filename' has already been declared

console.log("import.meta.url") // break error on build
const func = () => {
const __filename = 'value' // no error
}
```

:::
Expand All @@ -41,14 +41,10 @@ console.log("import.meta.url") // break error on build
Since Vite ships with TypeScript typings, you can leverage your IDE's intellisense with jsdoc type hints:

```js
/**
* @type {import('vite').UserConfig}
*/
const config = {
/** @type {import('vite').UserConfig} */
export default {
// ...
}

export default config
```

Alternatively, you can use the `defineConfig` helper which should provide intellisense without the need for jsdoc annotations:
Expand Down
2 changes: 1 addition & 1 deletion docs/config/server-options.md
Expand Up @@ -3,7 +3,7 @@
## server.host

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

Specify which IP addresses the server should listen on.
Set this to `0.0.0.0` or `true` to listen on all addresses, including LAN and public addresses.
Expand Down
2 changes: 1 addition & 1 deletion docs/config/worker-options.md
Expand Up @@ -11,7 +11,7 @@ Output format for worker bundle.

- **Type:** [`(Plugin | Plugin[])[]`](./shared-options#plugins)

Vite plugins that apply to worker bundle
Vite plugins that apply to worker bundle. Note that [config.plugins](./shared-options#plugins) does not apply to workers, it should be configured here instead.

## worker.rollupOptions

Expand Down
4 changes: 4 additions & 0 deletions docs/guide/api-plugin.md
Expand Up @@ -517,6 +517,10 @@ normalizePath('foo\\bar') // 'foo/bar'
normalizePath('foo/bar') // 'foo/bar'
```
## Filtering, include/exclude pattern
Vite exposes [`@rollup/pluginutils`'s `createFilter`](https://github.com/rollup/plugins/tree/master/packages/pluginutils#createfilter) function to encourage Vite specific plugins and integrations to use the standard include/exclude filtering pattern, which is also used in Vite core itself.
## Client-server Communication
Since Vite 2.9, we provide some utilities for plugins to help handle the communication with clients.
Expand Down
8 changes: 7 additions & 1 deletion docs/guide/features.md
Expand Up @@ -34,7 +34,7 @@ Vite only performs transpilation on `.ts` files and does **NOT** perform type ch

Vite uses [esbuild](https://github.com/evanw/esbuild) to transpile TypeScript into JavaScript which is about 20~30x faster than vanilla `tsc`, and HMR updates can reflect in the browser in under 50ms.

Use the [Type-Only Imports and Export](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export) syntax to avoid potential problems like type-only imports being incorrectly bundled. for example:
Use the [Type-Only Imports and Export](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export) syntax to avoid potential problems like type-only imports being incorrectly bundled, for example:

```ts
import type { T } from 'only/types'
Expand Down Expand Up @@ -511,6 +511,12 @@ By default, the worker script will be emitted as a separate chunk in the product
import MyWorker from './worker?worker&inline'
```

If you wish to retrieve the worker as a URL, add the `url` query:

```js
import MyWorker from './worker?worker&url'
```

See [Worker Options](/config/#worker-options) for details on configuring the bundling of all workers.

## Build Optimizations
Expand Down
12 changes: 12 additions & 0 deletions docs/guide/migration.md
Expand Up @@ -31,6 +31,8 @@ A small fraction of users will now require using [@vitejs/plugin-legacy](https:/

Vite's default dev server port is now 5173. You can use [`server.port`](../config/server-options.md#server-port) to set it to 3000.

Vite's default dev server host is now `localhost`. You can use [`server.host`](../config/server-options.md#server-host) to set it to `127.0.0.1`.

Vite optimizes dependencies with esbuild to both convert CJS-only deps to ESM and to reduce the number of modules the browser needs to request. In v3, the default strategy to discover and batch dependencies has changed. Vite no longer pre-scans user code with esbuild to get an initial list of dependencies on cold start. Instead, it delays the first dependency optimization run until every imported user module on load is processed.

To get back the v2 strategy, you can use [`optimizeDeps.devScan`](../config/dep-optimization-options.md#optimizedepsdevscan).
Expand All @@ -50,6 +52,10 @@ If using ESM for SSR isn't possible in your project, you can set `ssr.format: 'c
## General Changes

- JS file extensions in SSR and lib mode now use a valid extension (`js`, `mjs`, or `cjs`) for output JS entries and chunks based on their format and the package type.
- Terser is now an optional dependency. If you are using `build.minify: 'terser'`, you need to install it.
```shell
npm add -D terser
```

### `import.meta.glob`

Expand Down Expand Up @@ -93,6 +99,8 @@ There are some changes which only affects plugin/tool creators.
- `printHttpServerUrls` is removed
- `server.app`, `server.transformWithEsbuild` are removed
- `import.meta.hot.acceptDeps` is removed
- [[#6901] fix: sequential injection of tags in transformIndexHtml](https://github.com/vitejs/vite/pull/6901)
- `transformIndexHtml` now gets the correct content modified by earlier plugins, so the order of the injected tags now works as expected.
- [[#7995] chore: do not fixStacktrace](https://github.com/vitejs/vite/pull/7995)
- `ssrLoadModule`'s `fixStacktrace` option's default is now `false`
- [[#8178] feat!: migrate to ESM](https://github.com/vitejs/vite/pull/8178)
Expand All @@ -105,8 +113,12 @@ Also there are other breaking changes which only affect few users.
- Transpile to ES5 is now necessary even if the user code only includes ES5.
- [[#7877] fix: vite client types](https://github.com/vitejs/vite/pull/7877)
- `/// <reference lib="dom" />` is removed from `vite/client.d.ts`. `{ "lib": ["dom"] }` or `{ "lib": ["webworker"] }` is necessary in `tsconfig.json`.
- [[#8090] feat: preserve process env vars in lib build](https://github.com/vitejs/vite/pull/8090)
- `process.env.*` is now preserved in library mode
- [[#8280] feat: non-blocking esbuild optimization at build time](https://github.com/vitejs/vite/pull/8280)
- `server.force` option was removed in favor of `force` option.
- [[#8550] fix: dont handle sigterm in middleware mode](https://github.com/vitejs/vite/pull/8550)
- When running in middleware mode, Vite no longer kills process on `SIGTERM`.

## Migration from v1

Expand Down
11 changes: 8 additions & 3 deletions docs/guide/static-deploy.md
Expand Up @@ -266,12 +266,17 @@ You can also deploy to a [custom domain](http://surge.sh/help/adding-a-custom-do

# creates a new app with a specified name
$ heroku apps:create example
```

6. Set buildpacks. We use `heroku/nodejs` to build the project and `heroku-buildpack-static` to serve it.

# set buildpack for static sites
$ heroku buildpacks:set https://github.com/heroku/heroku-buildpack-static.git
```bash
# set buildpacks
$ heroku buildpacks:set heroku/nodejs
$ heroku buildpacks:add https://github.com/heroku/heroku-buildpack-static.git
```

6. Deploy your site:
7. Deploy your site:

```bash
# publish site
Expand Down
48 changes: 24 additions & 24 deletions package.json
Expand Up @@ -14,8 +14,8 @@
],
"scripts": {
"preinstall": "npx only-allow pnpm",
"format": "prettier --write .",
"lint": "eslint packages/*/{src,types,__tests__}/** playground/**/__tests__/**/*.ts scripts/**",
"format": "prettier --write --cache .",
"lint": "eslint --cache packages/*/{src,types,__tests__}/** playground/**/__tests__/**/*.ts scripts/**",
"typecheck": "tsc -p scripts --noEmit && tsc -p playground --noEmit",
"test": "run-s test-unit test-serve test-build",
"test-serve": "vitest run -c vitest.config.e2e.ts",
Expand All @@ -35,8 +35,8 @@
},
"devDependencies": {
"@babel/types": "^7.18.4",
"@microsoft/api-extractor": "^7.24.2",
"@rollup/plugin-typescript": "^8.3.2",
"@microsoft/api-extractor": "^7.25.0",
"@rollup/plugin-typescript": "^8.3.3",
"@types/babel__core": "^7.1.19",
"@types/babel__standalone": "^7.1.4",
"@types/convert-source-map": "^1.5.2",
Expand All @@ -50,67 +50,67 @@
"@types/micromatch": "^4.0.2",
"@types/mime": "^2.0.3",
"@types/minimist": "^1.2.2",
"@types/node": "^17.0.31",
"@types/node": "^17.0.42",
"@types/prompts": "^2.4.0",
"@types/resolve": "^1.20.2",
"@types/sass": "~1.43.1",
"@types/semver": "^7.3.9",
"@types/stylus": "^0.48.38",
"@types/ws": "^8.5.3",
"@typescript-eslint/eslint-plugin": "^5.27.0",
"@typescript-eslint/parser": "^5.27.0",
"@typescript-eslint/eslint-plugin": "^5.27.1",
"@typescript-eslint/parser": "^5.27.1",
"conventional-changelog-cli": "^2.2.2",
"cross-env": "^7.0.3",
"esbuild": "^0.14.38",
"eslint": "^8.16.0",
"eslint-define-config": "^1.5.0",
"esbuild": "^0.14.43",
"eslint": "^8.17.0",
"eslint-define-config": "^1.5.1",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-node": "^11.1.0",
"esno": "^0.16.3",
"execa": "^5.1.1",
"execa": "^6.1.0",
"fs-extra": "^10.1.0",
"kill-port": "^1.6.1",
"lint-staged": "^12.4.3",
"lint-staged": "^13.0.1",
"minimist": "^1.2.6",
"node-fetch": "^2.6.7",
"node-fetch": "^3.2.6",
"npm-run-all": "^4.1.5",
"picocolors": "^1.0.0",
"playwright-chromium": "^1.22.2",
"pnpm": "^7.1.7",
"prettier": "2.6.2",
"pnpm": "^7.2.1",
"prettier": "2.7.0",
"prompts": "^2.4.2",
"rimraf": "^3.0.2",
"rollup": "^2.72.1",
"rollup": "^2.75.6",
"semver": "^7.3.7",
"simple-git-hooks": "^2.8.0",
"sirv": "^2.0.2",
"tslib": "^2.4.0",
"typescript": "^4.6.4",
"unbuild": "^0.7.4",
"vite": "workspace:*",
"vitepress": "1.0.0-draft.8",
"vitest": "^0.13.0",
"vue": "^3.2.36"
"vitepress": "^1.0.0-alpha.2",
"vitest": "^0.14.2",
"vue": "^3.2.37"
},
"simple-git-hooks": {
"pre-commit": "pnpm exec lint-staged --concurrent false",
"commit-msg": "pnpm exec esno scripts/verifyCommit.ts $1"
},
"lint-staged": {
"*": [
"prettier --write --ignore-unknown"
"prettier --write --cache --ignore-unknown"
],
"packages/*/{src,types}/**/*.ts": [
"eslint --fix"
"eslint --cache --fix"
],
"packages/**/*.d.ts": [
"eslint --fix"
"eslint --cache --fix"
],
"playground/**/__tests__/**/*.ts": [
"eslint --fix"
"eslint --cache --fix"
]
},
"packageManager": "pnpm@7.1.7",
"packageManager": "pnpm@7.2.1",
"pnpm": {
"overrides": {
"vite": "workspace:*",
Expand Down
2 changes: 2 additions & 0 deletions packages/create-vite/README.md
Expand Up @@ -56,6 +56,8 @@ Currently supported template presets include:
- `svelte`
- `svelte-ts`

You can use `.` for the project name to scaffold in the current directory.

## Community Templates

create-vite is a tool to quickly start a project from a basic template for popular frameworks. Check out Awesome Vite for [community maintained templates](https://github.com/vitejs/awesome-vite#templates) that include other tools or target different frameworks. You can use a tool like [degit](https://github.com/Rich-Harris/degit) to scaffold your project with one of the templates.
Expand Down

0 comments on commit 6ab220f

Please sign in to comment.