diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index a87561a8e4146c..f086627de5cfe0 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -24,7 +24,7 @@ If you want to use break point and explore code execution you can use the ["Run
2. Click on the "Run and Debug" icon in the activity bar of the editor.
-3. Click on the "Javascript Debug Terminal" button.
+3. Click on the "JavaScript Debug Terminal" button.
4. It will open a terminal, then go to `packages/playground/xxx` and run `pnpm run dev`.
@@ -79,7 +79,7 @@ Each test can be run under either dev server mode or build mode.
- `pnpm run test-build` runs tests only under build mode.
-- You can also use `pnpm run test-serve -- [match]` or `pnpm run test-build -- [match]` to run tests in a specific playground package, e.g. `pnpm run test-serve -- css` will run tests for both `playground/css` and `playground/css-codesplit` under serve mode.
+- You can also use `pnpm run test-serve -- [match]` or `pnpm run test-build -- [match]` to run tests in a specific playground package, e.g. `pnpm run test-serve -- asset` will run tests for both `playground/asset` and `vite/src/node/__tests__/asset` under serve mode and `vite/src/node/__tests__/**/*` just run in serve mode.
Note package matching is not available for the `pnpm test` script, which always runs all tests.
@@ -229,7 +229,7 @@ The english docs are embedded in the main Vite repo, to allow contributors to wo
1. In order to get all doc files, you first need to clone this repo in your personal account.
2. Keep all the files in `docs/` and remove everything else.
- - You should setup your translation site based on all the files in `docs/` folder as a Vitepress project.
+ - You should setup your translation site based on all the files in `docs/` folder as a VitePress project.
(that said, `package.json` is need).
- Refresh git history by removing `.git` and then `git init`
@@ -238,7 +238,7 @@ The english docs are embedded in the main Vite repo, to allow contributors to wo
- During this stage, you may be translating documents and synchronizing updates at the same time, but don't worry about that, it's very common in translation contribution.
-4. Push your commits to your Github repo. you can setup a netlify preview as well.
-5. Use [Ryu-cho](https://github.com/vuejs-translations/ryu-cho) tool to setup a Github Action, automatically track English docs update later.
+4. Push your commits to your GitHub repo. you can setup a netlify preview as well.
+5. Use [Ryu-cho](https://github.com/vuejs-translations/ryu-cho) tool to setup a GitHub Action, automatically track English docs update later.
We recommend talking with others in Vite Land so you find more contributors for your language to share the maintenance work. Once the translation is done, communicate it to the Vite team so the repo can be moved to the official vitejs org in GitHub.
diff --git a/docs/blog/announcing-vite2.md b/docs/blog/announcing-vite2.md
index 0bf520dfdfcb9a..0007205debba4a 100644
--- a/docs/blog/announcing-vite2.md
+++ b/docs/blog/announcing-vite2.md
@@ -34,7 +34,7 @@ The [programmatic API](https://vitejs.dev/guide/api-javascript.html) has also be
### esbuild Powered Dep Pre-Bundling
-Since Vite is a native ESM dev server, it pre-bundles dependencies to reduce the number browser requests and handle CommonJS to ESM conversion. Previously Vite did this using Rollup, and in 2.0 it now uses `esbuild` which results in 10-100x faster dependency pre-bundling. As a reference, cold-booting a test app with heavy dependencies like React Material UI previously took 28 seconds on an M1-powered Macbook Pro and now takes ~1.5 seconds. Expect similar improvements if you are switching from a traditional bundler based setup.
+Since Vite is a native ESM dev server, it pre-bundles dependencies to reduce the number browser requests and handle CommonJS to ESM conversion. Previously Vite did this using Rollup, and in 2.0 it now uses `esbuild` which results in 10-100x faster dependency pre-bundling. As a reference, cold-booting a test app with heavy dependencies like React Material UI previously took 28 seconds on an M1-powered MacBook Pro and now takes ~1.5 seconds. Expect similar improvements if you are switching from a traditional bundler based setup.
### First-class CSS Support
diff --git a/docs/config/index.md b/docs/config/index.md
index a8d8cb36079f0a..346de1a78f7dc9 100644
--- a/docs/config/index.md
+++ b/docs/config/index.md
@@ -101,7 +101,9 @@ export default defineConfig(async ({ command, mode }) => {
### Environment Variables
-Vite doesn't load `.env` files by default as the files to load can only be determined after evaluating the Vite config, for example, the `root` and `envDir` options affects the loading behaviour. However, you can use the exported `loadEnv` helper to load the specific `.env` file if needed.
+Environmental Variables can be obtained from `process.env` as usual.
+
+Note that Vite doesn't load `.env` files by default as the files to load can only be determined after evaluating the Vite config, for example, the `root` and `envDir` options affects the loading behaviour. However, you can use the exported `loadEnv` helper to load the specific `.env` file if needed.
```js
import { defineConfig, loadEnv } from 'vite'
@@ -156,6 +158,8 @@ export default defineConfig(({ command, mode }) => {
- Starting from `2.0.0-beta.70`, string values will be used as raw expressions, so if defining a string constant, it needs to be explicitly quoted (e.g. with `JSON.stringify`).
+ - To be consistent with [esbuild behavior](https://esbuild.github.io/api/#define), expressions must either be a JSON object (null, boolean, number, string, array, or object) or a single identifier.
+
- Replacements are performed only when the match is surrounded by word boundaries (`\b`).
::: warning
@@ -355,7 +359,7 @@ export default defineConfig(({ command, mode }) => {
- **Type:** `ESBuildOptions | false`
- `ESBuildOptions` extends [ESbuild's own transform options](https://esbuild.github.io/api/#transform-api). The most common use case is customizing JSX:
+ `ESBuildOptions` extends [esbuild's own transform options](https://esbuild.github.io/api/#transform-api). The most common use case is customizing JSX:
```js
export default defineConfig({
@@ -366,9 +370,9 @@ export default defineConfig(({ command, mode }) => {
})
```
- By default, ESBuild is applied to `ts`, `jsx` and `tsx` files. You can customize this with `esbuild.include` and `esbuild.exclude`, which can be a regex, a [picomatch](https://github.com/micromatch/picomatch#globbing-features) pattern, or an array of either.
+ By default, esbuild is applied to `ts`, `jsx` and `tsx` files. You can customize this with `esbuild.include` and `esbuild.exclude`, which can be a regex, a [picomatch](https://github.com/micromatch/picomatch#globbing-features) pattern, or an array of either.
- In addition, you can also use `esbuild.jsxInject` to automatically inject JSX helper imports for every file transformed by ESBuild:
+ In addition, you can also use `esbuild.jsxInject` to automatically inject JSX helper imports for every file transformed by esbuild:
```js
export default defineConfig({
@@ -378,7 +382,7 @@ export default defineConfig(({ command, mode }) => {
})
```
- Set to `false` to disable ESbuild transforms.
+ Set to `false` to disable esbuild transforms.
### assetsInclude
@@ -550,14 +554,12 @@ export default defineConfig(({ command, mode }) => {
### server.hmr
-- **Type:** `boolean | { protocol?: string, host?: string, port?: number | false, path?: string, timeout?: number, overlay?: boolean, clientPort?: number, server?: Server }`
+- **Type:** `boolean | { protocol?: string, host?: string, port?: number, path?: string, timeout?: number, overlay?: boolean, clientPort?: number, server?: Server }`
Disable or configure HMR connection (in cases where the HMR websocket must use a different address from the http server).
Set `server.hmr.overlay` to `false` to disable the server error overlay.
- Set `server.hmr.port` to `false` when connecting to a domain without a port.
-
`clientPort` is an advanced option that overrides the port only on the client side, allowing you to serve the websocket on a different port than the client code looks for it on. Useful if you're using an SSL proxy in front of your dev server.
If specifying `server.hmr.server`, Vite will process HMR connection requests through the provided server. If not in middleware mode, Vite will attempt to process HMR connection requests through the existing server. This can be helpful when using self-signed certificates or when you want to expose Vite over a network on a single port.
@@ -849,7 +851,7 @@ export default defineConfig({
- **Type:** `boolean | 'terser' | 'esbuild'`
- **Default:** `'esbuild'`
- Set to `false` to disable minification, or specify the minifier to use. The default is [Esbuild](https://github.com/evanw/esbuild) which is 20 ~ 40x faster than terser and only 1 ~ 2% worse compression. [Benchmarks](https://github.com/privatenumber/minification-benchmarks)
+ Set to `false` to disable minification, or specify the minifier to use. The default is [esbuild](https://github.com/evanw/esbuild) which is 20 ~ 40x faster than terser and only 1 ~ 2% worse compression. [Benchmarks](https://github.com/privatenumber/minification-benchmarks)
Note the `build.minify` option is not available when using the `'es'` format in lib mode.
diff --git a/docs/guide/api-javascript.md b/docs/guide/api-javascript.md
index ddaa04279737f5..0128be26bd92ba 100644
--- a/docs/guide/api-javascript.md
+++ b/docs/guide/api-javascript.md
@@ -1,6 +1,6 @@
# JavaScript API
-Vite's JavaScript APIs are fully typed, and it's recommended to use TypeScript or enable JS type checking in VSCode to leverage the intellisense and validation.
+Vite's JavaScript APIs are fully typed, and it's recommended to use TypeScript or enable JS type checking in VS Code to leverage the intellisense and validation.
## `createServer`
diff --git a/docs/guide/api-plugin.md b/docs/guide/api-plugin.md
index 228755dd6f85c2..50353765261e34 100644
--- a/docs/guide/api-plugin.md
+++ b/docs/guide/api-plugin.md
@@ -113,7 +113,7 @@ Virtual modules are a useful scheme that allows you to pass build time informati
```js
export default function myPlugin() {
- const virtualModuleId = '@my-virtual-module'
+ const virtualModuleId = 'virtual:my-module'
const resolvedVirtualModuleId = '\0' + virtualModuleId
return {
@@ -135,7 +135,7 @@ export default function myPlugin() {
Which allows importing the module in JavaScript:
```js
-import { msg } from '@my-virtual-module'
+import { msg } from 'virtual:my-module'
console.log(msg)
```
@@ -186,8 +186,10 @@ Vite plugins can also provide hooks that serve Vite-specific purposes. These hoo
const partialConfigPlugin = () => ({
name: 'return-partial',
config: () => ({
- alias: {
- foo: 'bar'
+ resolve: {
+ alias: {
+ foo: 'bar'
+ }
}
})
})
@@ -499,7 +501,7 @@ Since Vite 2.9, we provide some utilities for plugins to help handle the communi
### Server to Client
-On the plugin side, we could use `server.ws.send` to boardcast events to all the clients:
+On the plugin side, we could use `server.ws.send` to broadcast events to all the clients:
```js
// vite.config.js
diff --git a/docs/guide/assets.md b/docs/guide/assets.md
index fd5aa46f49467f..9776dcdd032f35 100644
--- a/docs/guide/assets.md
+++ b/docs/guide/assets.md
@@ -103,8 +103,17 @@ function getImageUrl(name) {
}
```
-During the production build, Vite will perform necessary transforms so that the URLs still point to the correct location even after bundling and asset hashing.
+During the production build, Vite will perform necessary transforms so that the URLs still point to the correct location even after bundling and asset hashing. However, the URL string must be static so it can be analyzed, otherwise the code will be left as is, which can cause runtime errors if `build.target` does not support `import.meta.url`
-::: warning Note: Does not work with SSR
+```js
+// Vite will not transform this
+const imgUrl = new URL(imagePath, import.meta.url).href
+```
+
+::: warning Does not work with SSR
This pattern does not work if you are using Vite for Server-Side Rendering, because `import.meta.url` have different semantics in browsers vs. Node.js. The server bundle also cannot determine the client host URL ahead of time.
:::
+
+::: warning Esbuild target config is necessary
+This pattern needs esbuild target to be set to `es2020` or higher. `vite@2.x` use `es2019` as default target. Set [build-target](https://vitejs.dev/config/#build-target) and [optimizedeps.esbuildoptions.target](https://vitejs.dev/config/#optimizedeps-esbuildoptions) to `es2020` or higher if you intend to use this partten.
+:::
diff --git a/docs/guide/env-and-mode.md b/docs/guide/env-and-mode.md
index d3a6a575bce64c..b2b1264e85a8e4 100644
--- a/docs/guide/env-and-mode.md
+++ b/docs/guide/env-and-mode.md
@@ -37,12 +37,12 @@ Vite uses [dotenv](https://github.com/motdotla/dotenv) to load additional enviro
An env file for a specific mode (e.g. `.env.production`) will take higher priority than a generic one (e.g. `.env`).
-In addition, environment variables that already exist when Vite is executed have the highest priority and will not be overwritten by `.env` files.
+In addition, environment variables that already exist when Vite is executed have the highest priority and will not be overwritten by `.env` files. For example, when running `VITE_SOME_KEY=123 vite build`.
`.env` files are loaded at the start of Vite. Restart the server after making changes.
:::
-Loaded env variables are also exposed to your client source code via `import.meta.env`.
+Loaded env variables are also exposed to your client source code via `import.meta.env` as strings.
To prevent accidentally leaking env variables to the client, only variables prefixed with `VITE_` are exposed to your Vite-processed code. e.g. the following file:
@@ -57,7 +57,7 @@ If you want to customize env variables prefix, see [envPrefix](/config/index#env
:::warning SECURITY NOTES
-- `.env.*.local` files are local-only and can contain sensitive variables. You should add `.local` to your `.gitignore` to avoid them being checked into git.
+- `.env.*.local` files are local-only and can contain sensitive variables. You should add `*.local` to your `.gitignore` to avoid them being checked into git.
- Since any variables exposed to your Vite source code will end up in your client bundle, `VITE_*` variables should _not_ contain any sensitive information.
:::
diff --git a/docs/guide/static-deploy.md b/docs/guide/static-deploy.md
index 43b047dd7f53eb..8c6c219f568a9e 100644
--- a/docs/guide/static-deploy.md
+++ b/docs/guide/static-deploy.md
@@ -299,7 +299,7 @@ Vercel CLI
### Vercel for Git
-1. Push your code to your git repository (GitHub, GitLab, BitBucket).
+1. Push your code to your git repository (GitHub, GitLab, Bitbucket).
2. [Import your Vite project](https://vercel.com/new) into Vercel.
3. Vercel will detect that you are using Vite and will enable the correct settings for your deployment.
4. Your application is deployed! (e.g. [vite-vue-template.vercel.app](https://vite-vue-template.vercel.app/))
diff --git a/docs/guide/why.md b/docs/guide/why.md
index 89ca7698394246..9a24cf64777611 100644
--- a/docs/guide/why.md
+++ b/docs/guide/why.md
@@ -18,7 +18,7 @@ Vite improves the dev server start time by first dividing the modules in an appl
- **Dependencies** are mostly plain JavaScript that do not change often during development. Some large dependencies (e.g. component libraries with hundreds of modules) are also quite expensive to process. Dependencies may also be shipped in various module formats (e.g. ESM or CommonJS).
- Vite [pre-bundles dependencies](./dep-pre-bundling) using [esbuild](https://esbuild.github.io/). Esbuild is written in Go and pre-bundles dependencies 10-100x faster than JavaScript-based bundlers.
+ Vite [pre-bundles dependencies](./dep-pre-bundling) using [esbuild](https://esbuild.github.io/). esbuild is written in Go and pre-bundles dependencies 10-100x faster than JavaScript-based bundlers.
- **Source code** often contains non-plain JavaScript that needs transforming (e.g. JSX, CSS or Vue/Svelte components), and will be edited very often. Also, not all source code needs to be loaded at the same time (e.g. with route-based code-splitting).
diff --git a/package.json b/package.json
index 878fd5c7de506f..de02e27949560c 100644
--- a/package.json
+++ b/package.json
@@ -34,18 +34,18 @@
"ci-docs": "run-s build-vite build-plugin-vue build-docs"
},
"devDependencies": {
- "@microsoft/api-extractor": "^7.19.5",
+ "@microsoft/api-extractor": "^7.21.2",
"@types/fs-extra": "^9.0.13",
"@types/jest": "^27.4.1",
"@types/node": "^16.11.26",
"@types/prompts": "^2.0.14",
"@types/semver": "^7.3.9",
- "@typescript-eslint/eslint-plugin": "^5.16.0",
- "@typescript-eslint/parser": "^5.16.0",
+ "@typescript-eslint/eslint-plugin": "^5.18.0",
+ "@typescript-eslint/parser": "^5.18.0",
"conventional-changelog-cli": "^2.2.2",
"cross-env": "^7.0.3",
"esbuild": "^0.14.27",
- "eslint": "^8.12.0",
+ "eslint": "^8.13.0",
"eslint-define-config": "^1.3.0",
"eslint-plugin-node": "^11.1.0",
"execa": "^5.1.1",
@@ -56,12 +56,12 @@
"node-fetch": "^2.6.6",
"npm-run-all": "^4.1.5",
"picocolors": "^1.0.0",
- "playwright-chromium": "^1.20.1",
- "prettier": "2.6.1",
+ "playwright-chromium": "^1.20.2",
+ "prettier": "2.6.2",
"prompts": "^2.4.2",
"rimraf": "^3.0.2",
"rollup": "^2.59.0",
- "semver": "^7.3.5",
+ "semver": "^7.3.6",
"simple-git-hooks": "^2.7.0",
"sirv": "^2.0.2",
"ts-jest": "^27.1.4",
@@ -85,11 +85,18 @@
"eslint --ext .ts"
]
},
- "packageManager": "pnpm@6.32.3",
+ "packageManager": "pnpm@6.32.6",
"pnpm": {
"overrides": {
"vite": "workspace:*",
"@vitejs/plugin-vue": "workspace:*"
+ },
+ "packageExtensions": {
+ "postcss-load-config": {
+ "peerDependencies": {
+ "postcss": "*"
+ }
+ }
}
}
}
diff --git a/packages/create-vite/CHANGELOG.md b/packages/create-vite/CHANGELOG.md
index b81d7ec6fac49a..cac7f2664ecaed 100644
--- a/packages/create-vite/CHANGELOG.md
+++ b/packages/create-vite/CHANGELOG.md
@@ -1,3 +1,22 @@
+## 2.9.1 (2022-04-13)
+
+* chore: fix term cases (#7553) ([c296130](https://github.com/vitejs/vite/commit/c296130)), closes [#7553](https://github.com/vitejs/vite/issues/7553)
+* chore: update @types/react version (#7655) ([eb57627](https://github.com/vitejs/vite/commit/eb57627)), closes [#7655](https://github.com/vitejs/vite/issues/7655)
+* chore: update vue template setup api doc url (#7628) ([4433df4](https://github.com/vitejs/vite/commit/4433df4)), closes [#7628](https://github.com/vitejs/vite/issues/7628)
+* chore(create-vite-app): upgrade react to 18 (#7597) ([8b21029](https://github.com/vitejs/vite/commit/8b21029)), closes [#7597](https://github.com/vitejs/vite/issues/7597)
+* chore(create-vite): add isolatedModules (#7697) ([8f28350](https://github.com/vitejs/vite/commit/8f28350)), closes [#7697](https://github.com/vitejs/vite/issues/7697)
+
+
+
+## 2.9.0 (2022-03-30)
+
+* chore: add isolatedModules to create-vite > template-vue-ts > tsconfig (#7304) ([21990ea](https://github.com/vitejs/vite/commit/21990ea)), closes [#7304](https://github.com/vitejs/vite/issues/7304)
+* chore(deps): update all non-major dependencies (#7490) ([42c15f6](https://github.com/vitejs/vite/commit/42c15f6)), closes [#7490](https://github.com/vitejs/vite/issues/7490)
+* docs(vue-ts): update note on vue type support in ts (#6165) ([cfc7648](https://github.com/vitejs/vite/commit/cfc7648)), closes [#6165](https://github.com/vitejs/vite/issues/6165)
+* workflow: separate version bumping and publishing on release (#6879) ([fe8ef39](https://github.com/vitejs/vite/commit/fe8ef39)), closes [#6879](https://github.com/vitejs/vite/issues/6879)
+
+
+
# [2.8.0](https://github.com/vitejs/vite/compare/create-vite@2.7.2...create-vite@2.8.0) (2022-02-09)
diff --git a/packages/create-vite/package.json b/packages/create-vite/package.json
index ec8199455ef86f..dcaf3962c987cf 100644
--- a/packages/create-vite/package.json
+++ b/packages/create-vite/package.json
@@ -1,6 +1,6 @@
{
"name": "create-vite",
- "version": "2.8.0",
+ "version": "2.9.1",
"license": "MIT",
"author": "Evan You",
"bin": {
diff --git a/packages/create-vite/template-lit-ts/package.json b/packages/create-vite/template-lit-ts/package.json
index 5c0a7c7948ee58..6a928d05bb9e84 100644
--- a/packages/create-vite/template-lit-ts/package.json
+++ b/packages/create-vite/template-lit-ts/package.json
@@ -19,7 +19,7 @@
"lit": "^2.0.2"
},
"devDependencies": {
- "vite": "^2.8.0",
+ "vite": "^2.9.2",
"typescript": "^4.5.4"
}
}
diff --git a/packages/create-vite/template-lit-ts/tsconfig.json b/packages/create-vite/template-lit-ts/tsconfig.json
index 03ecaf410c88be..2ec691c81c2b38 100644
--- a/packages/create-vite/template-lit-ts/tsconfig.json
+++ b/packages/create-vite/template-lit-ts/tsconfig.json
@@ -11,6 +11,7 @@
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"moduleResolution": "node",
+ "isolatedModules": true,
"allowSyntheticDefaultImports": true,
"experimentalDecorators": true,
"forceConsistentCasingInFileNames": true,
diff --git a/packages/create-vite/template-lit/package.json b/packages/create-vite/template-lit/package.json
index ca3c71428f22c9..7889bec19759ff 100644
--- a/packages/create-vite/template-lit/package.json
+++ b/packages/create-vite/template-lit/package.json
@@ -17,6 +17,6 @@
"lit": "^2.0.2"
},
"devDependencies": {
- "vite": "^2.8.0"
+ "vite": "^2.9.2"
}
}
diff --git a/packages/create-vite/template-preact-ts/package.json b/packages/create-vite/template-preact-ts/package.json
index df1726ba6c4f7b..aaf8aea0372e52 100644
--- a/packages/create-vite/template-preact-ts/package.json
+++ b/packages/create-vite/template-preact-ts/package.json
@@ -13,6 +13,6 @@
"devDependencies": {
"@preact/preset-vite": "^2.1.5",
"typescript": "^4.5.4",
- "vite": "^2.8.0"
+ "vite": "^2.9.2"
}
}
diff --git a/packages/create-vite/template-preact/package.json b/packages/create-vite/template-preact/package.json
index 2865df70374acf..19198fc9e66d67 100644
--- a/packages/create-vite/template-preact/package.json
+++ b/packages/create-vite/template-preact/package.json
@@ -12,6 +12,6 @@
},
"devDependencies": {
"@preact/preset-vite": "^2.1.5",
- "vite": "^2.8.0"
+ "vite": "^2.9.2"
}
}
diff --git a/packages/create-vite/template-react-ts/package.json b/packages/create-vite/template-react-ts/package.json
index 3b1e21b7dbca8c..ea89f3a68d8c45 100644
--- a/packages/create-vite/template-react-ts/package.json
+++ b/packages/create-vite/template-react-ts/package.json
@@ -8,14 +8,14 @@
"preview": "vite preview"
},
"dependencies": {
- "react": "^17.0.2",
- "react-dom": "^17.0.2"
+ "react": "^18.0.0",
+ "react-dom": "^18.0.0"
},
"devDependencies": {
- "@types/react": "^17.0.33",
- "@types/react-dom": "^17.0.10",
- "@vitejs/plugin-react": "^1.0.7",
- "typescript": "^4.5.4",
- "vite": "^2.8.0"
+ "@types/react": "^18.0.0",
+ "@types/react-dom": "^18.0.0",
+ "@vitejs/plugin-react": "^1.3.0",
+ "typescript": "^4.6.3",
+ "vite": "^2.9.2"
}
}
diff --git a/packages/create-vite/template-react-ts/src/main.tsx b/packages/create-vite/template-react-ts/src/main.tsx
index 606a3cf44ec02b..4a1b15096e15b1 100644
--- a/packages/create-vite/template-react-ts/src/main.tsx
+++ b/packages/create-vite/template-react-ts/src/main.tsx
@@ -1,11 +1,10 @@
import React from 'react'
-import ReactDOM from 'react-dom'
-import './index.css'
+import ReactDOM from 'react-dom/client'
import App from './App'
+import './index.css'
-ReactDOM.render(
+ReactDOM.createRoot(document.getElementById('root')!).render(
Recommended IDE setup: - VSCode + VS Code + Volar
diff --git a/packages/create-vite/template-vue/README.md b/packages/create-vite/template-vue/README.md index c0793a82398e08..eea15cef41ea60 100644 --- a/packages/create-vite/template-vue/README.md +++ b/packages/create-vite/template-vue/README.md @@ -4,4 +4,4 @@ This template should help get you started developing with Vue 3 in Vite. The tem ## Recommended IDE Setup -- [VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=johnsoncodehk.volar) +- [VS Code](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=johnsoncodehk.volar) diff --git a/packages/create-vite/template-vue/package.json b/packages/create-vite/template-vue/package.json index 3136fcda2a0bc7..531986717154ee 100644 --- a/packages/create-vite/template-vue/package.json +++ b/packages/create-vite/template-vue/package.json @@ -11,7 +11,7 @@ "vue": "^3.2.25" }, "devDependencies": { - "@vitejs/plugin-vue": "^2.2.0", - "vite": "^2.8.0" + "@vitejs/plugin-vue": "^2.3.1", + "vite": "^2.9.2" } } diff --git a/packages/create-vite/template-vue/src/App.vue b/packages/create-vite/template-vue/src/App.vue index 742233037df99e..09bbb6a561285f 100644 --- a/packages/create-vite/template-vue/src/App.vue +++ b/packages/create-vite/template-vue/src/App.vue @@ -1,6 +1,6 @@ diff --git a/packages/create-vite/template-vue/src/components/HelloWorld.vue b/packages/create-vite/template-vue/src/components/HelloWorld.vue index 48a5ca9095156b..aa607e31e0ad7c 100644 --- a/packages/create-vite/template-vue/src/components/HelloWorld.vue +++ b/packages/create-vite/template-vue/src/components/HelloWorld.vue @@ -13,7 +13,7 @@ const count = ref(0)Recommended IDE setup: - VSCode + VS Code + Volar
diff --git a/packages/playground/assets/__tests__/assets.spec.ts b/packages/playground/assets/__tests__/assets.spec.ts index f53c783c52b606..75c0e57952db24 100644 --- a/packages/playground/assets/__tests__/assets.spec.ts +++ b/packages/playground/assets/__tests__/assets.spec.ts @@ -263,6 +263,7 @@ if (isBuild) { } }) } + describe('css and assets in css in build watch', () => { if (isBuild) { test('css will not be lost and css does not contain undefined', async () => { @@ -271,7 +272,26 @@ describe('css and assets in css in build watch', () => { const cssFile = findAssetFile(/index\.\w+\.css$/, 'foo') expect(cssFile).not.toBe('') expect(cssFile).not.toMatch(/undefined/) - watcher?.close() + }) + + test('import module.css', async () => { + expect(await getColor('#foo')).toBe('red') + editFile( + 'css/foo.module.css', + (code) => code.replace('red', 'blue'), + true + ) + await notifyRebuildComplete(watcher) + await page.reload() + expect(await getColor('#foo')).toBe('blue') + }) + + test('import with raw query', async () => { + expect(await page.textContent('.raw-query')).toBe('foo') + editFile('static/foo.txt', (code) => code.replace('foo', 'zoo'), true) + await notifyRebuildComplete(watcher) + await page.reload() + expect(await page.textContent('.raw-query')).toBe('zoo') }) } }) @@ -287,3 +307,10 @@ if (!isBuild) { await untilUpdated(() => getColor('.import-css'), 'rgb(0, 255, 136)') }) } + +test('html import word boundary', async () => { + expect(await page.textContent('.obj-import-express')).toMatch( + 'ignore object import prop' + ) + expect(await page.textContent('.string-import-express')).toMatch('no load') +}) diff --git a/packages/playground/assets/css/foo.module.css b/packages/playground/assets/css/foo.module.css new file mode 100644 index 00000000000000..196612f252d254 --- /dev/null +++ b/packages/playground/assets/css/foo.module.css @@ -0,0 +1,3 @@ +.foo-module { + color: red; +} diff --git a/packages/playground/assets/index.html b/packages/playground/assets/index.html index 7534ecbe1677bf..6678a2da7c2106 100644 --- a/packages/playground/assets/index.html +++ b/packages/playground/assets/index.html @@ -176,9 +176,28 @@
+
+
Imported Less string:
+Stylus: This should be blue
Stylus additionalData: This should be orange @@ -89,6 +93,12 @@
Inline CSS module:
+ + +CSS with @charset:
+ +@import dependency w/ style enrtrypoints: this should be purple
@@ -105,7 +115,7 @@- Url separation preservation: should have valid background-image + URL separation preservation: should have valid background-image
Inlined import - this should NOT be red.
diff --git a/packages/playground/css/inline.module.css b/packages/playground/css/inline.module.css new file mode 100644 index 00000000000000..9566e21e2cd1af --- /dev/null +++ b/packages/playground/css/inline.module.css @@ -0,0 +1,3 @@ +.apply-color-inline { + color: turquoise; +} diff --git a/packages/playground/css/less.less b/packages/playground/css/less.less index 69ffa830862014..49cbd3c3bb336e 100644 --- a/packages/playground/css/less.less +++ b/packages/playground/css/less.less @@ -1,6 +1,9 @@ @import '@/nested/nested'; @import './nested/css-in-less.less'; +// Test data-uri calls with relative images. +@import './less/components/form.less'; + @color: blue; .less { diff --git a/packages/playground/css/less/components/form.less b/packages/playground/css/less/components/form.less new file mode 100644 index 00000000000000..feaaea94ce1bba --- /dev/null +++ b/packages/playground/css/less/components/form.less @@ -0,0 +1,4 @@ +.form-box-data-uri { + // data-uri() calls with relative paths should be replaced just like urls. + background-image: data-uri('../images/backgrounds/form-select.svg'); +} diff --git a/packages/playground/css/less/images/backgrounds/form-select.svg b/packages/playground/css/less/images/backgrounds/form-select.svg new file mode 100644 index 00000000000000..8aaf69c09e03f4 --- /dev/null +++ b/packages/playground/css/less/images/backgrounds/form-select.svg @@ -0,0 +1,4 @@ + diff --git a/packages/playground/css/main.js b/packages/playground/css/main.js index 6edd840a87c5e7..0d03aafbf0ec7f 100644 --- a/packages/playground/css/main.js +++ b/packages/playground/css/main.js @@ -38,6 +38,12 @@ text( JSON.stringify(composesPathResolvingMod, null, 2) ) +import inlineMod from './inline.module.css?inline' +text('.modules-inline', inlineMod) + +import charset from './charset.css' +text('.charset-css', charset) + import './dep.css' import './glob-dep.css' diff --git a/packages/playground/css/postcss-caching/css.spec.ts b/packages/playground/css/postcss-caching/css.spec.ts index 6c85d127003680..e8ba73154b6bc8 100644 --- a/packages/playground/css/postcss-caching/css.spec.ts +++ b/packages/playground/css/postcss-caching/css.spec.ts @@ -1,9 +1,9 @@ -import { getColor } from '../../testUtils' +import { getColor, ports } from '../../testUtils' import { createServer } from 'vite' import path from 'path' test('postcss config', async () => { - const port = 5005 + const port = ports['css/postcss-caching'] const startServer = async (root) => { const server = await createServer({ root, diff --git a/packages/playground/dynamic-import/__tests__/dynamic-import.spec.ts b/packages/playground/dynamic-import/__tests__/dynamic-import.spec.ts index 9f8276d5e4d855..c7157ef4652ec6 100644 --- a/packages/playground/dynamic-import/__tests__/dynamic-import.spec.ts +++ b/packages/playground/dynamic-import/__tests__/dynamic-import.spec.ts @@ -8,6 +8,10 @@ test('should load literal dynamic import', async () => { test('should load full dynamic import from public', async () => { await page.click('.qux') await untilUpdated(() => page.textContent('.view'), 'Qux view', true) + // No warning should be logged as we are using @vite-ignore + expect( + serverLogs.some((log) => log.includes('cannot be analyzed by vite')) + ).toBe(false) }) test('should load data URL of `blob:`', async () => { diff --git a/packages/playground/dynamic-import/nested/index.js b/packages/playground/dynamic-import/nested/index.js index 1a118ecc79051b..5518c56a35a2cc 100644 --- a/packages/playground/dynamic-import/nested/index.js +++ b/packages/playground/dynamic-import/nested/index.js @@ -35,7 +35,7 @@ document.querySelector('.mxd2').addEventListener('click', async () => { const test = { jss: '../mxd.js' } const ttest = test const view = 'mxd' - const { default: mxdDynamic } = await import(test.jss) + const { default: mxdDynamic } = await import(/*@vite-ignore*/ test.jss) text('.view', mxdStatic === mxdDynamic) }) diff --git a/packages/playground/fs-serve/__tests__/fs-serve.spec.ts b/packages/playground/fs-serve/__tests__/fs-serve.spec.ts index c618186b9bcd64..eba1e441881710 100644 --- a/packages/playground/fs-serve/__tests__/fs-serve.spec.ts +++ b/packages/playground/fs-serve/__tests__/fs-serve.spec.ts @@ -23,6 +23,15 @@ describe('main', () => { expect(await page.textContent('.safe-fetch-status')).toBe('200') }) + test('safe fetch with special characters', async () => { + expect( + await page.textContent('.safe-fetch-subdir-special-characters') + ).toMatch('KEY=safe') + expect( + await page.textContent('.safe-fetch-subdir-special-characters-status') + ).toBe('200') + }) + test('unsafe fetch', async () => { expect(await page.textContent('.unsafe-fetch')).toMatch('403 Restricted') expect(await page.textContent('.unsafe-fetch-status')).toBe('403') @@ -33,6 +42,13 @@ describe('main', () => { expect(await page.textContent('.safe-fs-fetch-status')).toBe('200') }) + test('safe fs fetch with special characters', async () => { + expect(await page.textContent('.safe-fs-fetch-special-characters')).toBe( + stringified + ) + expect(await page.textContent('.safe-fs-fetch-status')).toBe('200') + }) + test('unsafe fs fetch', async () => { expect(await page.textContent('.unsafe-fs-fetch')).toBe('') expect(await page.textContent('.unsafe-fs-fetch-status')).toBe('403') diff --git a/packages/playground/fs-serve/root/src/index.html b/packages/playground/fs-serve/root/src/index.html index 9e4f728a593a91..951e14ad2cce91 100644 --- a/packages/playground/fs-serve/root/src/index.html +++ b/packages/playground/fs-serve/root/src/index.html @@ -11,6 +11,8 @@foo
+<js>
+ + + + + diff --git a/packages/playground/vue-sourcemap/Main.vue b/packages/playground/vue-sourcemap/Main.vue index 04ddf50071ccb3..b9b03596f5aea5 100644 --- a/packages/playground/vue-sourcemap/Main.vue +++ b/packages/playground/vue-sourcemap/Main.vue @@ -1,5 +1,7 @@<js>
+ - const formatSourcemapForSnapshot = (map: any) => { - const m = { ...map } - delete m.file - delete m.names - m.sources = m.sources.map((source) => source.replace(root, '/root')) - return m - } + + + + ", + ], + "version": 3, + } + `) + }) + + test('ts', async () => { + const res = await page.request.get(new URL('./Ts.vue', page.url()).href) + const js = await res.text() + const map = extractSourcemap(js) + expect(formatSourcemapForSnapshot(map)).toMatchInlineSnapshot(` + Object { + "mappings": ";AAKA,QAAQ,IAAI,WAAW;;;;AAIvB,YAAQ,IAAI,UAAU;;;;;;;;uBARpB,oBAAiB,WAAd,MAAU", + "sources": Array [ + "/root/Ts.vue", + ], + "sourcesContent": Array [ + " +<ts>
+ + + + + + ", + ], + "version": 3, + } + `) + }) test('css', async () => { const css = await getStyleTagContentIncluding('.css ') diff --git a/packages/playground/vue-sourcemap/package.json b/packages/playground/vue-sourcemap/package.json index 5672b5e3d9d57d..286940b01efa58 100644 --- a/packages/playground/vue-sourcemap/package.json +++ b/packages/playground/vue-sourcemap/package.json @@ -10,7 +10,6 @@ }, "devDependencies": { "@vitejs/plugin-vue": "workspace:*", - "convert-source-map": "^1.8.0", "less": "^4.1.2", "sass": "^1.43.4" }, diff --git a/packages/playground/vue/Main.vue b/packages/playground/vue/Main.vue index d10ae401f7aa8e..87319acdf6f736 100644 --- a/packages/playground/vue/Main.vue +++ b/packages/playground/vue/Main.vue @@ -20,6 +20,7 @@worker template error match:
+
+ const worker = new Worker(new URL('./worker.js', import.meta.url))
+
+
- new Worker(new Url('./url-worker.js', import.meta.url), { type: 'module' }) + new Worker(new URL('./url-worker.js', import.meta.url), { type: 'module' }) .worker-import-meta-url
- new SharedWorker(new Url('./url-shared-worker.js', import.meta.url), { type: + new SharedWorker(new URL('./url-shared-worker.js', import.meta.url), { type: 'module' }) .shared-worker-import-meta-url
@@ -41,13 +46,13 @@
- new Worker(new Url('./classic-worker.js', import.meta.url)) + new Worker(new URL('./classic-worker.js', import.meta.url)) .classic-worker
- new SharedWorker(new Url('./classic-shared-worker.js', import.meta.url), { + new SharedWorker(new URL('./classic-shared-worker.js', import.meta.url), { type: 'classic' }) .classic-shared-worker
@@ -57,7 +62,9 @@
- worker emit chunk
+ worker emit chunk
+ module and worker:worker in worker file
+ module and worker:module in worker file
.emti-chunk-worker
@@ -68,6 +75,12 @@
++ module and worker:worker in simple file + .module-and-worker-worker +
+
+