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 1ed902b + f586b14 commit abb74a2
Show file tree
Hide file tree
Showing 121 changed files with 1,709 additions and 1,437 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ node_modules
playground-temp
temp
TODOs.md
.eslintcache
4 changes: 1 addition & 3 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
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
8 changes: 2 additions & 6 deletions docs/config/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,10 @@ const func = () => {
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
6 changes: 6 additions & 0 deletions docs/guide/features.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
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 Down Expand Up @@ -50,7 +50,7 @@
"@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",
Expand All @@ -61,34 +61,34 @@
"@typescript-eslint/parser": "^5.27.1",
"conventional-changelog-cli": "^2.2.2",
"cross-env": "^7.0.3",
"esbuild": "^0.14.38",
"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": "^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.2.1",
"prettier": "2.6.2",
"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",
"vitepress": "^1.0.0-alpha.2",
"vitest": "^0.14.2",
"vue": "^3.2.37"
},
Expand All @@ -98,16 +98,16 @@
},
"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.2.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/create-vite/__tests__/cli.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { join } from 'path'
import type { ExecaSyncReturnValue, SyncOptions } from 'execa'
import { commandSync } from 'execa'
import { execaCommandSync } from 'execa'
import { mkdirpSync, readdirSync, remove, writeFileSync } from 'fs-extra'
import { afterEach, beforeAll, expect, test } from 'vitest'

Expand All @@ -13,7 +13,7 @@ const run = (
args: string[],
options: SyncOptions<string> = {}
): ExecaSyncReturnValue<string> => {
return commandSync(`node ${CLI_PATH} ${args.join(' ')}`, options)
return execaCommandSync(`node ${CLI_PATH} ${args.join(' ')}`, options)
}

// Helper to create a non-empty directory
Expand Down
2 changes: 1 addition & 1 deletion packages/create-vite/template-preact-ts/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ import { render } from 'preact'
import { App } from './app'
import './index.css'

render(<App />, document.getElementById('app')!)
render(<App />, document.getElementById('app') as HTMLElement)
6 changes: 3 additions & 3 deletions packages/plugin-legacy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
},
"homepage": "https://github.com/vitejs/vite/tree/main/packages/plugin-legacy#readme",
"dependencies": {
"@babel/standalone": "^7.18.4",
"@babel/standalone": "^7.18.5",
"core-js": "^3.22.8",
"magic-string": "^0.26.2",
"regenerator-runtime": "^0.13.9",
Expand All @@ -46,7 +46,7 @@
"vite": "^3.0.0-alpha"
},
"devDependencies": {
"vite": "workspace:*",
"@babel/core": "^7.18.2"
"@babel/core": "^7.18.5",
"vite": "workspace:*"
}
}
10 changes: 5 additions & 5 deletions packages/plugin-legacy/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] {
config.build,
'es',
opts,
options.externalSystemJS
true
)
return
}
Expand Down Expand Up @@ -566,7 +566,7 @@ async function buildPolyfillChunk(
buildOptions: BuildOptions,
format: 'iife' | 'es',
rollupOutputOptions: NormalizedOutputOptions,
externalSystemJS?: boolean
excludeSystemJS?: boolean
) {
let { minify, assetsDir } = buildOptions
minify = minify ? 'terser' : false
Expand All @@ -575,7 +575,7 @@ async function buildPolyfillChunk(
root: path.dirname(fileURLToPath(import.meta.url)),
configFile: false,
logLevel: 'error',
plugins: [polyfillsPlugin(imports, externalSystemJS)],
plugins: [polyfillsPlugin(imports, excludeSystemJS)],
build: {
write: false,
target: false,
Expand Down Expand Up @@ -614,7 +614,7 @@ const polyfillId = '\0vite/legacy-polyfills'

function polyfillsPlugin(
imports: Set<string>,
externalSystemJS?: boolean
excludeSystemJS?: boolean
): Plugin {
return {
name: 'vite:legacy-polyfills',
Expand All @@ -627,7 +627,7 @@ function polyfillsPlugin(
if (id === polyfillId) {
return (
[...imports].map((i) => `import "${i}";`).join('') +
(externalSystemJS ? '' : `import "systemjs/dist/s.min.js";`)
(excludeSystemJS ? '' : `import "systemjs/dist/s.min.js";`)
)
}
}
Expand Down
3 changes: 1 addition & 2 deletions packages/plugin-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,11 @@
},
"homepage": "https://github.com/vitejs/vite/tree/main/packages/plugin-react#readme",
"dependencies": {
"@babel/core": "^7.18.2",
"@babel/core": "^7.18.5",
"@babel/plugin-transform-react-jsx": "^7.17.12",
"@babel/plugin-transform-react-jsx-development": "^7.16.7",
"@babel/plugin-transform-react-jsx-self": "^7.17.12",
"@babel/plugin-transform-react-jsx-source": "^7.16.7",
"@rollup/pluginutils": "^4.2.1",
"react-refresh": "^0.13.0"
},
"peerDependencies": {
Expand Down
3 changes: 1 addition & 2 deletions packages/plugin-react/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import path from 'path'
import type { ParserOptions, TransformOptions, types as t } from '@babel/core'
import * as babel from '@babel/core'
import { createFilter } from '@rollup/pluginutils'
import { normalizePath } from 'vite'
import { createFilter, normalizePath } from 'vite'
import type { Plugin, PluginOption, ResolvedConfig } from 'vite'
import {
addRefreshWrapper,
Expand Down
Loading

0 comments on commit abb74a2

Please sign in to comment.