From 139a9ee57103659a7f38e42a67e7a8236b20ebb0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 11 May 2021 17:24:25 +0800 Subject: [PATCH 01/30] chore(deps): bump postcss from 8.2.8 to 8.2.10 (#3343) Bumps [postcss](https://github.com/postcss/postcss) from 8.2.8 to 8.2.10. - [Release notes](https://github.com/postcss/postcss/releases) - [Changelog](https://github.com/postcss/postcss/blob/main/CHANGELOG.md) - [Commits](https://github.com/postcss/postcss/compare/8.2.8...8.2.10) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- packages/vite/package.json | 2 +- yarn.lock | 46 ++++++++++++++++---------------------- 2 files changed, 20 insertions(+), 28 deletions(-) diff --git a/packages/vite/package.json b/packages/vite/package.json index a1fe0cb75bb488..a0864960c976bd 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -47,7 +47,7 @@ "//": "READ .github/contributing.md to understand what to put under deps vs. devDeps!", "dependencies": { "esbuild": "^0.11.19", - "postcss": "^8.2.1", + "postcss": "^8.2.10", "resolve": "^1.19.0", "rollup": "^2.38.5" }, diff --git a/yarn.lock b/yarn.lock index 34399246faceae..47203bdbf8e4f5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2511,8 +2511,7 @@ css-color-names@^1.0.1: integrity sha512-/loXYOch1qU1biStIFsHH8SxTmOseh1IJqFvy8IujXOm1h+QjUdDhkzOrR5HG8K8mlxREj0yfi8ewCHx0eMxzA== "css-dep@link:./packages/playground/css/css-dep": - version "0.0.0" - uid "" + version "1.0.0" css-parse@~2.0.0: version "2.0.0" @@ -2705,23 +2704,22 @@ delegate@^3.1.2: "dep-cjs-named-only@link:./packages/playground/optimize-deps/dep-cjs-named-only": version "0.0.0" - uid "" "dep-esbuild-plugin-transform@link:./packages/playground/optimize-deps/dep-esbuild-plugin-transform": version "0.0.0" - uid "" "dep-import-type@link:./packages/playground/ssr-vue/dep-import-type": version "0.0.0" - uid "" "dep-linked-include@link:./packages/playground/optimize-deps/dep-linked-include": version "0.0.0" - uid "" + dependencies: + react "17.0.0" "dep-linked@link:./packages/playground/optimize-deps/dep-linked": version "0.0.0" - uid "" + dependencies: + lodash-es "^4.17.20" depd@~1.1.2: version "1.1.2" @@ -5511,10 +5509,10 @@ ms@^2.1.1: resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== -nanoid@^3.1.20: - version "3.1.22" - resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.1.22.tgz#b35f8fb7d151990a8aebd5aa5015c03cf726f844" - integrity sha512-/2ZUaJX2ANuLtTvqTlgqBQNJoQO398KyJgZloL0PZkC0dpysjncRUPsFe3DUPzz/y3h+u7C46np8RMuvF3jsSQ== +nanoid@^3.1.22: + version "3.1.23" + resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.1.23.tgz#f744086ce7c2bc47ee0a8472574d5c78e4183a81" + integrity sha512-FiB0kzdP0FFVGDKlRLEQ1BgDzU87dy5NnzjeW9YZNt+/c3+q82EQDUwniSAUxp/F0gFNI1ZhKU1FqYsMuqZVnw== nanomatch@^1.2.9: version "1.2.13" @@ -6210,13 +6208,13 @@ postcss-value-parser@^4.0.0, postcss-value-parser@^4.1.0: resolved "https://registry.yarnpkg.com/postcss-value-parser/-/postcss-value-parser-4.1.0.tgz#443f6a20ced6481a2bda4fa8532a6e55d789a2cb" integrity sha512-97DXOFbQJhk71ne5/Mt6cOu6yxsSfM0QGQyl0L25Gca4yGWEGJaig7l7gbCX623VqTBNGLRLaVUCnNkcedlRSQ== -postcss@^8.1.10, postcss@^8.2.1: - version "8.2.8" - resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.2.8.tgz#0b90f9382efda424c4f0f69a2ead6f6830d08ece" - integrity sha512-1F0Xb2T21xET7oQV9eKuctbM9S7BC0fetoHCc4H13z0PT6haiRLP4T0ZY4XWh7iLP0usgqykT6p9B2RtOf4FPw== +postcss@^8.1.10, postcss@^8.2.10: + version "8.2.10" + resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.2.10.tgz#ca7a042aa8aff494b334d0ff3e9e77079f6f702b" + integrity sha512-b/h7CPV7QEdrqIxtAf2j31U5ef05uBDuvoXv6L51Q4rcS1jdlXAVKJv+atCFdUXYl9dyTHGyoMzIepwowRJjFw== dependencies: colorette "^1.2.2" - nanoid "^3.1.20" + nanoid "^3.1.22" source-map "^0.6.1" preact@^10.0.0: @@ -6767,16 +6765,13 @@ requires-port@^1.0.0: integrity sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8= "resolve-browser-field@link:./packages/playground/resolve/browser-field": - version "0.0.0" - uid "" + version "1.0.0" "resolve-custom-condition@link:./packages/playground/resolve/custom-condition": - version "0.0.0" - uid "" + version "1.0.0" "resolve-custom-main-field@link:./packages/playground/resolve/custom-main-field": - version "0.0.0" - uid "" + version "1.0.0" resolve-cwd@^3.0.0: version "3.0.0" @@ -6786,12 +6781,10 @@ resolve-cwd@^3.0.0: resolve-from "^5.0.0" "resolve-exports-env@link:./packages/playground/resolve/exports-env": - version "0.0.0" - uid "" + version "1.0.0" "resolve-exports-path@link:./packages/playground/resolve/exports-path": - version "0.0.0" - uid "" + version "1.0.0" resolve-from@^4.0.0: version "4.0.0" @@ -7866,7 +7859,6 @@ typedarray-to-buffer@^3.1.5: "types@link:./packages/vite/types": version "0.0.0" - uid "" typescript@^4.1.2: version "4.2.3" From bdc1ea3b1c5aaed081f4e567949f73c4c936c5bf Mon Sep 17 00:00:00 2001 From: Ophir LOJKINE Date: Tue, 11 May 2021 13:00:13 +0200 Subject: [PATCH 02/30] docs: fix broken link in error message (#3345) Fixes #3344 --- packages/vite/src/node/server/middlewares/static.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vite/src/node/server/middlewares/static.ts b/packages/vite/src/node/server/middlewares/static.ts index 2a9a0db1918a91..db24efa2a7d27e 100644 --- a/packages/vite/src/node/server/middlewares/static.ts +++ b/packages/vite/src/node/server/middlewares/static.ts @@ -111,7 +111,7 @@ export function ensureServingAccess(url: string, serveRoot: string): void { throw new AccessRestrictedError( `The request url "${url}" is outside of vite dev server root "${serveRoot}". For security concerns, accessing files outside of workspace root is restricted since Vite v2.3.x. - Refer to docs https://vitejs.dev/config/#server-fsserveroot for configurations and more details.`, + Refer to docs https://vitejs.dev/config/#server-fsserve-root for configurations and more details.`, url, serveRoot ) From c6ef6d084c2368f6c73e03cc18bcab05aea9cfa6 Mon Sep 17 00:00:00 2001 From: Nihal Gonsalves Date: Tue, 11 May 2021 21:28:27 +0200 Subject: [PATCH 03/30] fix: bump @rollup/plugin-commonjs to v19, fix #3312 (#3353) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - v18 added the `ignoreDynamicRequires` option as a breaking change. The earlier behaviour matched `true`, so I set it as the default (ref: https://github.com/rollup/plugins/pull/819) - v19 is a breaking change since it now requires Rollup 2.38.0, but we’re already on 2.38.5. (ref: https://github.com/rollup/plugins/pull/658) --- packages/vite/LICENSE.md | 9 ++++++++- packages/vite/package.json | 2 +- packages/vite/src/node/build.ts | 5 ++++- yarn.lock | 36 ++++++++++++++++++++------------- 4 files changed, 35 insertions(+), 17 deletions(-) diff --git a/packages/vite/LICENSE.md b/packages/vite/LICENSE.md index 01dfade61045f4..e76cc51ddbc553 100644 --- a/packages/vite/LICENSE.md +++ b/packages/vite/LICENSE.md @@ -25,7 +25,7 @@ SOFTWARE. # Licenses of bundled dependencies The published Vite artifact additionally contains code with the following licenses: -Apache-2.0, MIT, ISC, BSD-2-Clause, (BSD-3-Clause OR GPL-2.0), BSD-3-Clause, CC0-1.0 +Apache-2.0, MIT, ISC, BSD-2-Clause, (MIT), (BSD-3-Clause OR GPL-2.0), BSD-3-Clause, CC0-1.0 # Bundled dependencies: ## @ampproject/remapping @@ -1565,6 +1565,13 @@ By: motdotla --------------------------------------- +## duplexer +License: (MIT) +By: Raynos, Jake Verbaten +Repository: git://github.com/Raynos/duplexer.git + +--------------------------------------- + ## ee-first License: MIT By: Jonathan Ong, Douglas Christopher Wilson diff --git a/packages/vite/package.json b/packages/vite/package.json index a0864960c976bd..4b69ed5b6a1368 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -57,7 +57,7 @@ "devDependencies": { "@ampproject/remapping": "^1.0.1", "@rollup/plugin-alias": "^3.1.1", - "@rollup/plugin-commonjs": "^17.0.0", + "@rollup/plugin-commonjs": "^19.0.0", "@rollup/plugin-dynamic-import-vars": "^1.1.1", "@rollup/plugin-json": "^4.1.0", "@rollup/plugin-node-resolve": "^11.0.1", diff --git a/packages/vite/src/node/build.ts b/packages/vite/src/node/build.ts index 507c26672298a5..6b04940c342e02 100644 --- a/packages/vite/src/node/build.ts +++ b/packages/vite/src/node/build.ts @@ -258,7 +258,10 @@ export function resolveBuildPlugins( return { pre: [ buildHtmlPlugin(config), - commonjsPlugin(options.commonjsOptions), + commonjsPlugin({ + ignoreDynamicRequires: true, + ...options.commonjsOptions + }), dataURIPlugin(), dynamicImportVars({ warnOnError: true, diff --git a/yarn.lock b/yarn.lock index 47203bdbf8e4f5..a699af1488adf7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -789,10 +789,10 @@ dependencies: slash "^3.0.0" -"@rollup/plugin-commonjs@^17.0.0": - version "17.1.0" - resolved "https://registry.yarnpkg.com/@rollup/plugin-commonjs/-/plugin-commonjs-17.1.0.tgz#757ec88737dffa8aa913eb392fade2e45aef2a2d" - integrity sha512-PoMdXCw0ZyvjpCMT5aV4nkL0QywxP29sODQsSGeDpr/oI49Qq9tRtAsb/LbYbDzFlOydVEqHmmZWFtXJEAX9ew== +"@rollup/plugin-commonjs@^19.0.0": + version "19.0.0" + resolved "https://registry.yarnpkg.com/@rollup/plugin-commonjs/-/plugin-commonjs-19.0.0.tgz#8c3e71f9a66908e60d70cc1be205834ef3e45f71" + integrity sha512-adTpD6ATGbehdaQoZQ6ipDFhdjqsTgpOAhFiPwl+dzre4pPshsecptDPyEFb61JMJ1+mGljktaC4jI8ARMSNyw== dependencies: "@rollup/pluginutils" "^3.1.0" commondir "^1.0.1" @@ -2511,7 +2511,8 @@ css-color-names@^1.0.1: integrity sha512-/loXYOch1qU1biStIFsHH8SxTmOseh1IJqFvy8IujXOm1h+QjUdDhkzOrR5HG8K8mlxREj0yfi8ewCHx0eMxzA== "css-dep@link:./packages/playground/css/css-dep": - version "1.0.0" + version "0.0.0" + uid "" css-parse@~2.0.0: version "2.0.0" @@ -2704,22 +2705,23 @@ delegate@^3.1.2: "dep-cjs-named-only@link:./packages/playground/optimize-deps/dep-cjs-named-only": version "0.0.0" + uid "" "dep-esbuild-plugin-transform@link:./packages/playground/optimize-deps/dep-esbuild-plugin-transform": version "0.0.0" + uid "" "dep-import-type@link:./packages/playground/ssr-vue/dep-import-type": version "0.0.0" + uid "" "dep-linked-include@link:./packages/playground/optimize-deps/dep-linked-include": version "0.0.0" - dependencies: - react "17.0.0" + uid "" "dep-linked@link:./packages/playground/optimize-deps/dep-linked": version "0.0.0" - dependencies: - lodash-es "^4.17.20" + uid "" depd@~1.1.2: version "1.1.2" @@ -6765,13 +6767,16 @@ requires-port@^1.0.0: integrity sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8= "resolve-browser-field@link:./packages/playground/resolve/browser-field": - version "1.0.0" + version "0.0.0" + uid "" "resolve-custom-condition@link:./packages/playground/resolve/custom-condition": - version "1.0.0" + version "0.0.0" + uid "" "resolve-custom-main-field@link:./packages/playground/resolve/custom-main-field": - version "1.0.0" + version "0.0.0" + uid "" resolve-cwd@^3.0.0: version "3.0.0" @@ -6781,10 +6786,12 @@ resolve-cwd@^3.0.0: resolve-from "^5.0.0" "resolve-exports-env@link:./packages/playground/resolve/exports-env": - version "1.0.0" + version "0.0.0" + uid "" "resolve-exports-path@link:./packages/playground/resolve/exports-path": - version "1.0.0" + version "0.0.0" + uid "" resolve-from@^4.0.0: version "4.0.0" @@ -7859,6 +7866,7 @@ typedarray-to-buffer@^3.1.5: "types@link:./packages/vite/types": version "0.0.0" + uid "" typescript@^4.1.2: version "4.2.3" From c1e4b4e01d8e74079ac923b35de97d5a3e6bf781 Mon Sep 17 00:00:00 2001 From: Jeff Yang <32727188+ydcjeff@users.noreply.github.com> Date: Wed, 12 May 2021 02:13:26 +0630 Subject: [PATCH 04/30] chore(docs): indent in `build.assetsInlineLimit` note (#3361) --- docs/config/index.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/config/index.md b/docs/config/index.md index 85412bd93f9847..2ccf06d7f8cd62 100644 --- a/docs/config/index.md +++ b/docs/config/index.md @@ -478,9 +478,9 @@ export default async ({ command, mode }) => { Imported or referenced assets that are smaller than this threshold will be inlined as base64 URLs to avoid extra http requests. Set to `0` to disable inlining altogether. - :::tip Note -Assets will **always** be inlined, regardless of file size, and `build.assetsInlineLimit` will be ignored if you specify `build.lib` -::: + ::: tip Note + Assets will **always** be inlined, regardless of file size, and `build.assetsInlineLimit` will be ignored if you specify `build.lib` + ::: ### build.cssCodeSplit From deb465ba412312ccae2d5b767de327d6f8562e7e Mon Sep 17 00:00:00 2001 From: Alex Kozack Date: Wed, 12 May 2021 08:43:50 +0300 Subject: [PATCH 05/30] fix: normalize url in `ensureServingAccess` (#3350) --- packages/vite/src/node/server/middlewares/static.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/vite/src/node/server/middlewares/static.ts b/packages/vite/src/node/server/middlewares/static.ts index db24efa2a7d27e..7b363e44be131d 100644 --- a/packages/vite/src/node/server/middlewares/static.ts +++ b/packages/vite/src/node/server/middlewares/static.ts @@ -2,7 +2,7 @@ import os from 'os' import path from 'path' import sirv, { Options } from 'sirv' import { Connect } from 'types/connect' -import { ResolvedConfig } from '../..' +import { normalizePath, ResolvedConfig } from '../..' import { FS_PREFIX } from '../../constants' import { cleanUrl, fsPathFromId, isImportRequest } from '../../utils' import { AccessRestrictedError } from './error' @@ -107,12 +107,13 @@ export function serveRawFsMiddleware( } export function ensureServingAccess(url: string, serveRoot: string): void { - if (!url.startsWith(serveRoot + path.posix.sep)) { + const normalizedUrl = normalizePath(url) + if (!normalizedUrl.startsWith(serveRoot + path.posix.sep)) { throw new AccessRestrictedError( - `The request url "${url}" is outside of vite dev server root "${serveRoot}". + `The request url "${normalizedUrl}" is outside of vite dev server root "${serveRoot}". For security concerns, accessing files outside of workspace root is restricted since Vite v2.3.x. Refer to docs https://vitejs.dev/config/#server-fsserve-root for configurations and more details.`, - url, + normalizedUrl, serveRoot ) } From 42b35ac567b02b8142a7a51df320d7deb2ec4ac1 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Wed, 12 May 2021 16:14:52 +0800 Subject: [PATCH 06/30] =?UTF-8?q?fix:=20use=20the=20closest=20package.json?= =?UTF-8?q?=20as=20root=20when=20workspace=20not=20found=20fo=E2=80=A6=20(?= =?UTF-8?q?#3374)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/vite/src/node/server/searchRoot.ts | 23 ++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/packages/vite/src/node/server/searchRoot.ts b/packages/vite/src/node/server/searchRoot.ts index ea868c661dc3cd..623cfd579f9faa 100644 --- a/packages/vite/src/node/server/searchRoot.ts +++ b/packages/vite/src/node/server/searchRoot.ts @@ -34,9 +34,30 @@ function hasRootFile(root: string): boolean { return ROOT_FILES.some((file) => fs.existsSync(join(root, file))) } +function hasPackageJSON(root: string) { + const path = join(root, 'package.json') + return fs.existsSync(path) +} + +/** + * Search up for the nearest `package.json` + */ +export function searchForPackageRoot(current: string, root = current): string { + if (hasPackageJSON(current)) return current + + const dir = dirname(current) + // reach the fs root + if (!dir || dir === current) return root + + return searchForPackageRoot(dir, root) +} + +/** + * Search up for the nearest workspace root + */ export function searchForWorkspaceRoot( current: string, - root = current + root = searchForPackageRoot(current) ): string { if (hasRootFile(current)) return current if (hasWorkspacePackageJSON(current)) return current From 5433a655534cd4c716c2eba2f89f20bfa328e812 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Wed, 12 May 2021 16:39:41 +0800 Subject: [PATCH 07/30] fix: disable fsServe restrictions by default (#3377) --- docs/config/index.md | 24 ++++++++++- packages/vite/src/node/logger.ts | 9 +++++ packages/vite/src/node/server/index.ts | 20 +++++++++- .../src/node/server/middlewares/static.ts | 40 ++++++++++++++----- .../vite/src/node/server/transformRequest.ts | 2 +- 5 files changed, 81 insertions(+), 14 deletions(-) diff --git a/docs/config/index.md b/docs/config/index.md index 2ccf06d7f8cd62..86c80ab63205ee 100644 --- a/docs/config/index.md +++ b/docs/config/index.md @@ -430,17 +430,39 @@ export default async ({ command, mode }) => { File system watcher options to pass on to [chokidar](https://github.com/paulmillr/chokidar#api). +### server.fsServe.strict + +- **Experimental** +- **Type:** `boolean` +- **Default:** `false` (will change to `true` in future versions) + + Restrict serving files outside of workspace root. + ### server.fsServe.root +- **Experimental** - **Type:** `string` - Restrict files that could be served via `/@fs/`. Accessing files outside this directory will result in a 403. + Restrict files that could be served via `/@fs/`. When `server.fsServe.strict` is set to `true`, accessing files outside this directory 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). - contains `workspaces` field in `package.json` - contains one of the following file - `pnpm-workspace.yaml` + Accepts a path to specify the custom workspace root. Could be a absolute path or a path relative to [project root](/guide/#index-html-and-project-root). For example + + ```js + export default { + server: { + fsServe: { + // Allow serving files from one level up to the project root + root: '..' + } + } + } + ``` + ## Build Options ### build.target diff --git a/packages/vite/src/node/logger.ts b/packages/vite/src/node/logger.ts index 8724195aab7eb9..cfd0524da801fd 100644 --- a/packages/vite/src/node/logger.ts +++ b/packages/vite/src/node/logger.ts @@ -9,6 +9,7 @@ export type LogLevel = LogType | 'silent' export interface Logger { info(msg: string, options?: LogOptions): void warn(msg: string, options?: LogOptions): void + warnOnce(msg: string, options?: LogOptions): void error(msg: string, options?: LogOptions): void clearScreen(type: LogType): void hasWarned: boolean @@ -87,6 +88,8 @@ export function createLogger( } } + const warnedMessages = new Set() + const logger: Logger = { hasWarned: false, info(msg, opts) { @@ -96,6 +99,12 @@ export function createLogger( logger.hasWarned = true output('warn', msg, opts) }, + warnOnce(msg, opts) { + if (warnedMessages.has(msg)) return + logger.hasWarned = true + output('warn', msg, opts) + warnedMessages.add(msg) + }, error(msg, opts) { logger.hasWarned = true output('error', msg, opts) diff --git a/packages/vite/src/node/server/index.ts b/packages/vite/src/node/server/index.ts index 8383629d198e63..a3f37885b614d8 100644 --- a/packages/vite/src/node/server/index.ts +++ b/packages/vite/src/node/server/index.ts @@ -132,11 +132,22 @@ export interface ResolvedServerOptions extends ServerOptions { } export interface FileSystemServeOptions { + /** + * Strictly restrict file accessing outside of allowing paths. + * + * Default to false at this moment, will enabled by default in the future versions. + * @expiremental + * @default false + */ + strict?: boolean + /** * Restrict accessing files outside this directory will result in a 403. * * Accepts absolute path or a path relative to project root. * Will try to search up for workspace root by default. + * + * @expiremental */ root?: string } @@ -692,9 +703,14 @@ export function resolveServerOptions( raw?: ServerOptions ): ResolvedServerOptions { const server = raw || {} - const serverRoot = normalizePath( + const fsServeRoot = normalizePath( path.resolve(root, server.fsServe?.root || searchForWorkspaceRoot(root)) ) - server.fsServe = { root: serverRoot } + // TODO: make strict by default + const fsServeStrict = server.fsServe?.strict ?? false + server.fsServe = { + root: fsServeRoot, + strict: fsServeStrict + } return server as ResolvedServerOptions } diff --git a/packages/vite/src/node/server/middlewares/static.ts b/packages/vite/src/node/server/middlewares/static.ts index 7b363e44be131d..e243957618e75b 100644 --- a/packages/vite/src/node/server/middlewares/static.ts +++ b/packages/vite/src/node/server/middlewares/static.ts @@ -2,8 +2,10 @@ import os from 'os' import path from 'path' import sirv, { Options } from 'sirv' import { Connect } from 'types/connect' +import { FileSystemServeOptions } from '..' import { normalizePath, ResolvedConfig } from '../..' import { FS_PREFIX } from '../../constants' +import { Logger } from '../../logger' import { cleanUrl, fsPathFromId, isImportRequest } from '../../utils' import { AccessRestrictedError } from './error' @@ -92,7 +94,8 @@ export function serveRawFsMiddleware( // restrict files outside of `fsServe.root` ensureServingAccess( path.resolve(fsPathFromId(url)), - config.server.fsServe.root + config.server.fsServe, + config.logger ) url = url.slice(FS_PREFIX.length) @@ -106,15 +109,32 @@ export function serveRawFsMiddleware( } } -export function ensureServingAccess(url: string, serveRoot: string): void { +export function ensureServingAccess( + url: string, + { root, strict }: Required, + logger: Logger +): void { + // TODO: early return, should remove once we polished the restriction logic + if (!strict) return + const normalizedUrl = normalizePath(url) - if (!normalizedUrl.startsWith(serveRoot + path.posix.sep)) { - throw new AccessRestrictedError( - `The request url "${normalizedUrl}" is outside of vite dev server root "${serveRoot}". - For security concerns, accessing files outside of workspace root is restricted since Vite v2.3.x. - Refer to docs https://vitejs.dev/config/#server-fsserve-root for configurations and more details.`, - normalizedUrl, - serveRoot - ) + if (!normalizedUrl.startsWith(root + path.posix.sep)) { + if (strict) { + throw new AccessRestrictedError( + `The request url "${normalizedUrl}" is outside of vite dev server root "${root}". + For security concerns, accessing files outside of workspace root is restricted since Vite v2.3.x. + Refer to docs https://vitejs.dev/config/#server-fsserve-root for configurations and more details.`, + normalizedUrl, + root + ) + } else { + // TODO: warn for potential unrestricted access + logger.warnOnce( + `For security concerns, accessing files outside of workspace root will ` + + `be restricted by default in the future version of Vite. ` + + `Refer to [] for more` + ) + logger.warnOnce(`Unrestricted file system access to "${normalizedUrl}"`) + } } } diff --git a/packages/vite/src/node/server/transformRequest.ts b/packages/vite/src/node/server/transformRequest.ts index 7aa784d700f1e2..8138a0ca306ce6 100644 --- a/packages/vite/src/node/server/transformRequest.ts +++ b/packages/vite/src/node/server/transformRequest.ts @@ -75,7 +75,7 @@ export async function transformRequest( // as string try { if (!options.ssr) { - ensureServingAccess(file, config.server.fsServe.root) + ensureServingAccess(file, config.server.fsServe, config.logger) } code = await fs.readFile(file, 'utf-8') isDebug && debugLoad(`${timeFrom(loadStart)} [fs] ${prettyUrl}`) From 1af39949b8bad8e25038879bbdf070ff819fdf4d Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Wed, 12 May 2021 17:00:22 +0800 Subject: [PATCH 08/30] release: v2.3.1 --- packages/vite/CHANGELOG.md | 12 ++++++++++++ packages/vite/package.json | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/vite/CHANGELOG.md b/packages/vite/CHANGELOG.md index d83ada4a70104d..247d9fc6b906ef 100644 --- a/packages/vite/CHANGELOG.md +++ b/packages/vite/CHANGELOG.md @@ -1,3 +1,15 @@ +## [2.3.1](https://github.com/vitejs/vite/compare/v2.3.0...v2.3.1) (2021-05-12) + + +### Bug Fixes + +* bump @rollup/plugin-commonjs to v19, fix [#3312](https://github.com/vitejs/vite/issues/3312) ([#3353](https://github.com/vitejs/vite/issues/3353)) ([c6ef6d0](https://github.com/vitejs/vite/commit/c6ef6d084c2368f6c73e03cc18bcab05aea9cfa6)) +* disable fsServe restrictions by default ([#3377](https://github.com/vitejs/vite/issues/3377)) ([5433a65](https://github.com/vitejs/vite/commit/5433a655534cd4c716c2eba2f89f20bfa328e812)) +* normalize url in `ensureServingAccess` ([#3350](https://github.com/vitejs/vite/issues/3350)) ([deb465b](https://github.com/vitejs/vite/commit/deb465ba412312ccae2d5b767de327d6f8562e7e)) +* use the closest package.json as root when workspace not found fo… ([#3374](https://github.com/vitejs/vite/issues/3374)) ([42b35ac](https://github.com/vitejs/vite/commit/42b35ac567b02b8142a7a51df320d7deb2ec4ac1)) + + + # [2.3.0](https://github.com/vitejs/vite/compare/v2.2.4...v2.3.0) (2021-05-11) ## BREAKING CHANGES diff --git a/packages/vite/package.json b/packages/vite/package.json index 4b69ed5b6a1368..a90f64de81ec49 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -1,6 +1,6 @@ { "name": "vite", - "version": "2.3.0", + "version": "2.3.1", "license": "MIT", "author": "Evan You", "description": "Native-ESM powered web dev build tool", From df46c0d9af709a03e6964a7f33565039bc1aba3e Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Wed, 12 May 2021 17:01:42 +0800 Subject: [PATCH 09/30] docs: update changelog --- packages/vite/CHANGELOG.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/vite/CHANGELOG.md b/packages/vite/CHANGELOG.md index 247d9fc6b906ef..edc96d22a4d410 100644 --- a/packages/vite/CHANGELOG.md +++ b/packages/vite/CHANGELOG.md @@ -1,5 +1,21 @@ ## [2.3.1](https://github.com/vitejs/vite/compare/v2.3.0...v2.3.1) (2021-05-12) +### Notable Changes + +We introduced a security fix in v2.3.0 to restrict file access outside of the workspace root. We received reports of issues with symlinks and monorepo setups, so we are marking this feature as experimental and disabling it by default to avoid disruption in the ecosystem. + +A new experimental option `server.fsServe.strict` was added defaulting to `false`. This **disables the restrictions by default**. The `fsServe` restrictions are going to be enabled by default in a future version, once the issues are been resolved and the logic becomes more robust. You can opt-in to this security change using (experimental) + +```js +// vite.config.js +export default { + server: { + fsServe: { + strict: true + } + } +} +``` ### Bug Fixes From aee0928636f4b0d0bf287e3ac0e0790e55a9c984 Mon Sep 17 00:00:00 2001 From: underfin Date: Thu, 13 May 2021 00:17:08 +0800 Subject: [PATCH 10/30] deps: bump esbuild to 0.11.20, fix #3247 (#3385) --- packages/vite/package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/vite/package.json b/packages/vite/package.json index a90f64de81ec49..4004ebbb17096f 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -46,7 +46,7 @@ }, "//": "READ .github/contributing.md to understand what to put under deps vs. devDeps!", "dependencies": { - "esbuild": "^0.11.19", + "esbuild": "^0.11.20", "postcss": "^8.2.10", "resolve": "^1.19.0", "rollup": "^2.38.5" diff --git a/yarn.lock b/yarn.lock index a699af1488adf7..5cb92d8a856082 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2908,10 +2908,10 @@ es-to-primitive@^1.2.1: is-date-object "^1.0.1" is-symbol "^1.0.2" -esbuild@^0.11.19: - version "0.11.19" - resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.11.19.tgz#59289d9c6ee3f45d0db289a662c31473da25c199" - integrity sha512-X2h8UThAwKLxmc1OChHVegIScphS/qU9cUB5vCEV2T0A024E8Ptpg9xssXXcs+j1uEgXrDJZuVRzx2JsmGzq7A== +esbuild@^0.11.20: + version "0.11.20" + resolved "https://registry.npmjs.org/esbuild/-/esbuild-0.11.20.tgz#7cefa1aee8b372c184e42457885f7ce5d3e62a1e" + integrity sha512-QOZrVpN/Yz74xfat0H6euSgn3RnwLevY1mJTEXneukz1ln9qB+ieaerRMzSeETpz/UJWsBMzRVR/andBht5WKw== escalade@^3.1.1: version "3.1.1" From d36e10ed99fe765a5f25268bdf8252fe0b026701 Mon Sep 17 00:00:00 2001 From: Shinigami Date: Wed, 12 May 2021 19:13:44 +0200 Subject: [PATCH 11/30] chore: change prettier version to exact (#3386) --- docs/.vitepress/config.js | 3 +- docs/config/index.md | 17 +++++----- docs/guide/api-plugin.md | 13 +++---- docs/guide/build.md | 2 +- docs/guide/ssr.md | 2 +- docs/guide/using-plugins.md | 8 ++--- package.json | 2 +- packages/create-app/index.js | 3 +- .../template-lit-element-ts/package.json | 2 +- .../template-lit-element/package.json | 2 +- .../template-preact-ts/package.json | 2 +- .../create-app/template-preact/package.json | 2 +- .../create-app/template-react-ts/package.json | 2 +- .../create-app/template-react/package.json | 2 +- .../template-svelte-ts/package.json | 2 +- .../create-app/template-svelte/package.json | 2 +- .../template-vanilla-ts/package.json | 2 +- .../create-app/template-vanilla/package.json | 2 +- .../create-app/template-vue-ts/package.json | 2 +- packages/create-app/template-vue/package.json | 2 +- .../frontend/entrypoints/global.css | 5 +-- .../backend-integration/references.css | 4 +-- .../playground/css-codesplit-cjs/main.css | 4 +-- packages/playground/dynamic-import/mxd.json | 2 +- .../playground/multiple-entrypoints/deps.json | 28 ++++++++++++++- .../multiple-entrypoints/reference.scss | 4 ++- .../playground/ssr-vue/src/pages/Home.vue | 2 +- packages/playground/vue/Main.vue | 2 +- packages/plugin-react-refresh/README.md | 11 +++--- packages/plugin-vue/src/main.ts | 3 +- packages/plugin-vue/src/utils/query.ts | 7 ++-- packages/vite/client.d.ts | 8 ++--- packages/vite/src/client/client.ts | 8 +++-- packages/vite/src/node/build.ts | 13 +++---- packages/vite/src/node/config.ts | 5 ++- packages/vite/src/node/optimizer/scan.ts | 10 +++--- packages/vite/src/node/plugins/css.ts | 12 +++---- .../src/node/plugins/dynamicImportPolyfill.ts | 2 +- packages/vite/src/node/plugins/html.ts | 7 ++-- .../vite/src/node/plugins/importAnalysis.ts | 34 ++++++++----------- .../src/node/plugins/importAnalysisBuild.ts | 33 +++++++++--------- packages/vite/src/node/ssr/ssrStacktrace.ts | 2 +- scripts/jestPerTestSetup.ts | 3 +- scripts/verifyCommit.js | 3 +- yarn.lock | 8 ++--- 45 files changed, 156 insertions(+), 138 deletions(-) diff --git a/docs/.vitepress/config.js b/docs/.vitepress/config.js index 68688c807b1662..36d995496ecfb5 100644 --- a/docs/.vitepress/config.js +++ b/docs/.vitepress/config.js @@ -57,8 +57,7 @@ module.exports = { }, { text: 'Changelog', - link: - 'https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md' + link: 'https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md' } ] }, diff --git a/docs/config/index.md b/docs/config/index.md index 86c80ab63205ee..41b0bfe04a85b7 100644 --- a/docs/config/index.md +++ b/docs/config/index.md @@ -74,10 +74,10 @@ If the config needs to call async function, it can export a async function inste ```js export default async ({ command, mode }) => { - const data = await asyncFunction(); + const data = await asyncFunction() return { // build specific config - } + } } ``` @@ -331,7 +331,7 @@ export default async ({ command, mode }) => { 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. - + This can be set via the CLI using `--host 0.0.0.0` or `--host`. ### server.port @@ -444,8 +444,9 @@ export default async ({ command, mode }) => { - **Type:** `string` Restrict files that could be served via `/@fs/`. When `server.fsServe.strict` is set to `true`, accessing files outside this directory 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). + - contains `workspaces` field in `package.json` - contains one of the following file - `pnpm-workspace.yaml` @@ -456,8 +457,8 @@ export default async ({ command, mode }) => { export default { server: { fsServe: { - // Allow serving files from one level up to the project root - root: '..' + // Allow serving files from one level up to the project root + root: '..' } } } @@ -499,7 +500,7 @@ export default async ({ command, mode }) => { - **Default:** `4096` (4kb) Imported or referenced assets that are smaller than this threshold will be inlined as base64 URLs to avoid extra http requests. Set to `0` to disable inlining altogether. - + ::: tip Note Assets will **always** be inlined, regardless of file size, and `build.assetsInlineLimit` will be ignored if you specify `build.lib` ::: @@ -593,7 +594,7 @@ export default async ({ command, mode }) => { - **Default:** `500` Limit for chunk size warnings (in kbs). - + ### build.watch - **Type:** [`WatcherOptions`](https://rollupjs.org/guide/en/#watch-options)`| null` diff --git a/docs/guide/api-plugin.md b/docs/guide/api-plugin.md index dd96508d5307b8..879e3a2aa0e4f9 100644 --- a/docs/guide/api-plugin.md +++ b/docs/guide/api-plugin.md @@ -35,11 +35,11 @@ import vitePlugin from 'vite-plugin-feature' import rollupPlugin from 'rollup-plugin-feature' export default { - plugins: [ vitePlugin(), rollupPlugin() ] + plugins: [vitePlugin(), rollupPlugin()] } ``` -Falsy plugins will be ignored, which can be used to easily activate or deactivate plugins. +Falsy plugins will be ignored, which can be used to easily activate or deactivate plugins. `plugins` also accept presets including several plugins as a single element. This is useful for complex features (like framework integration) that are implemented using several plugins. The array will be flattened internally. @@ -49,10 +49,7 @@ import frameworkRefresh from 'vite-plugin-framework-refresh' import frameworkDevtools from 'vite-plugin-framework-devtools' export default function framework(config) { - return [ - frameworkRefresh(config), - frameworkDevTools(config) - ] + return [frameworkRefresh(config), frameworkDevTools(config)] } ``` @@ -61,9 +58,7 @@ export default function framework(config) { import framework from 'vite-plugin-framework' export default { - plugins: [ - framework() - ] + plugins: [framework()] } ``` diff --git a/docs/guide/build.md b/docs/guide/build.md index 7dd46ab435b9fa..dd1acfedc6db40 100644 --- a/docs/guide/build.md +++ b/docs/guide/build.md @@ -92,7 +92,7 @@ module.exports = { } ``` -If you specify a different root, remember that `__dirname` will still be the folder of your vite.config.js file when resolving the input paths. Therfore, you will need to add your `root` entry to the arguments for `resolve`. +If you specify a different root, remember that `__dirname` will still be the folder of your vite.config.js file when resolving the input paths. Therfore, you will need to add your `root` entry to the arguments for `resolve`. ## Library Mode diff --git a/docs/guide/ssr.md b/docs/guide/ssr.md index 452ddd902ba469..6aedaf9f55a556 100644 --- a/docs/guide/ssr.md +++ b/docs/guide/ssr.md @@ -243,4 +243,4 @@ export function mySSRPlugin() { ## 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'`. \ No newline at end of file +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'`. diff --git a/docs/guide/using-plugins.md b/docs/guide/using-plugins.md index 0eabf821ff6fb1..79b9b8a66188da 100644 --- a/docs/guide/using-plugins.md +++ b/docs/guide/using-plugins.md @@ -53,8 +53,8 @@ export default { plugins: [ { ...image(), - enforce: 'pre', - }, + enforce: 'pre' + } ] } ``` @@ -73,8 +73,8 @@ export default { plugins: [ { ...typescript2(), - apply: 'build', - }, + apply: 'build' + } ] } ``` diff --git a/package.json b/package.json index 6f134ffbd374a3..b0924b6f7afa97 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "node-fetch": "^2.6.1", "npm-run-all": "^4.1.5", "playwright-chromium": "^1.7.0", - "prettier": "^2.2.1", + "prettier": "2.3.0", "rimraf": "^3.0.2", "semver": "^7.3.4", "sirv": "^1.0.10", diff --git a/packages/create-app/index.js b/packages/create-app/index.js index dc9b752432958e..1cbfb075635d78 100755 --- a/packages/create-app/index.js +++ b/packages/create-app/index.js @@ -273,7 +273,8 @@ function copy(src, dest) { } async function getValidPackageName(projectName) { - const packageNameRegExp = /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/ + const packageNameRegExp = + /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/ if (packageNameRegExp.test(projectName)) { return projectName } else { diff --git a/packages/create-app/template-lit-element-ts/package.json b/packages/create-app/template-lit-element-ts/package.json index ee1ad19c500f95..b6cb14f43fda71 100644 --- a/packages/create-app/template-lit-element-ts/package.json +++ b/packages/create-app/template-lit-element-ts/package.json @@ -21,4 +21,4 @@ "vite": "^2.3.0", "typescript": "^4.1.3" } -} \ No newline at end of file +} diff --git a/packages/create-app/template-lit-element/package.json b/packages/create-app/template-lit-element/package.json index 52749d237a6ab6..eaa91339695cea 100644 --- a/packages/create-app/template-lit-element/package.json +++ b/packages/create-app/template-lit-element/package.json @@ -18,4 +18,4 @@ "devDependencies": { "vite": "^2.3.0" } -} \ No newline at end of file +} diff --git a/packages/create-app/template-preact-ts/package.json b/packages/create-app/template-preact-ts/package.json index ad8fe72d2d7196..eb28f12b75a0f4 100644 --- a/packages/create-app/template-preact-ts/package.json +++ b/packages/create-app/template-preact-ts/package.json @@ -14,4 +14,4 @@ "typescript": "^4.1.3", "vite": "^2.3.0" } -} \ No newline at end of file +} diff --git a/packages/create-app/template-preact/package.json b/packages/create-app/template-preact/package.json index aea8892802497f..0becc082e85313 100644 --- a/packages/create-app/template-preact/package.json +++ b/packages/create-app/template-preact/package.json @@ -13,4 +13,4 @@ "@preact/preset-vite": "^2.0.0", "vite": "^2.3.0" } -} \ No newline at end of file +} diff --git a/packages/create-app/template-react-ts/package.json b/packages/create-app/template-react-ts/package.json index 650302ebcf305c..14f9b4fde90b2b 100644 --- a/packages/create-app/template-react-ts/package.json +++ b/packages/create-app/template-react-ts/package.json @@ -17,4 +17,4 @@ "typescript": "^4.1.2", "vite": "^2.3.0" } -} \ No newline at end of file +} diff --git a/packages/create-app/template-react/package.json b/packages/create-app/template-react/package.json index 286f318af7acb6..49d37ec2b3a5f3 100644 --- a/packages/create-app/template-react/package.json +++ b/packages/create-app/template-react/package.json @@ -14,4 +14,4 @@ "@vitejs/plugin-react-refresh": "^1.3.1", "vite": "^2.3.0" } -} \ No newline at end of file +} diff --git a/packages/create-app/template-svelte-ts/package.json b/packages/create-app/template-svelte-ts/package.json index f5e791eed62ab5..8d73ce7dbabceb 100644 --- a/packages/create-app/template-svelte-ts/package.json +++ b/packages/create-app/template-svelte-ts/package.json @@ -13,4 +13,4 @@ "typescript": "^4.2.4", "vite": "^2.3.0" } -} \ No newline at end of file +} diff --git a/packages/create-app/template-svelte/package.json b/packages/create-app/template-svelte/package.json index 7b184ea1f91e2d..aab7129c930879 100644 --- a/packages/create-app/template-svelte/package.json +++ b/packages/create-app/template-svelte/package.json @@ -11,4 +11,4 @@ "svelte": "^3.37.0", "vite": "^2.3.0" } -} \ No newline at end of file +} diff --git a/packages/create-app/template-vanilla-ts/package.json b/packages/create-app/template-vanilla-ts/package.json index f62df8df9e8287..b168339e5c9f31 100644 --- a/packages/create-app/template-vanilla-ts/package.json +++ b/packages/create-app/template-vanilla-ts/package.json @@ -10,4 +10,4 @@ "typescript": "^4.2.3", "vite": "^2.3.0" } -} \ No newline at end of file +} diff --git a/packages/create-app/template-vanilla/package.json b/packages/create-app/template-vanilla/package.json index cc44042642523f..096c8504a00d89 100644 --- a/packages/create-app/template-vanilla/package.json +++ b/packages/create-app/template-vanilla/package.json @@ -9,4 +9,4 @@ "devDependencies": { "vite": "^2.3.0" } -} \ No newline at end of file +} diff --git a/packages/create-app/template-vue-ts/package.json b/packages/create-app/template-vue-ts/package.json index 5dfb0806338a3d..8c3110ed37bc04 100644 --- a/packages/create-app/template-vue-ts/package.json +++ b/packages/create-app/template-vue-ts/package.json @@ -16,4 +16,4 @@ "vite": "^2.3.0", "vue-tsc": "^0.0.24" } -} \ No newline at end of file +} diff --git a/packages/create-app/template-vue/package.json b/packages/create-app/template-vue/package.json index e2c30dc7ce7dd8..035f26563680d5 100644 --- a/packages/create-app/template-vue/package.json +++ b/packages/create-app/template-vue/package.json @@ -14,4 +14,4 @@ "@vue/compiler-sfc": "^3.0.5", "vite": "^2.3.0" } -} \ No newline at end of file +} diff --git a/packages/playground/backend-integration/frontend/entrypoints/global.css b/packages/playground/backend-integration/frontend/entrypoints/global.css index 3ea5728368521d..a120a71974e083 100644 --- a/packages/playground/backend-integration/frontend/entrypoints/global.css +++ b/packages/playground/backend-integration/frontend/entrypoints/global.css @@ -1,7 +1,8 @@ @import '~/styles/background.css'; @import '../../references.css'; -html, body { +html, +body { font-family: sans-serif; line-height: 2.4rem; } @@ -13,7 +14,7 @@ body { } ul { - padding: 0 .4em; + padding: 0 0.4em; margin: 0; } diff --git a/packages/playground/backend-integration/references.css b/packages/playground/backend-integration/references.css index 3600be7cbb2f6f..262bf59c724f39 100644 --- a/packages/playground/backend-integration/references.css +++ b/packages/playground/backend-integration/references.css @@ -1,8 +1,8 @@ .asset-reference { display: grid; grid-template-areas: - "summary preview ." - "url url url"; + 'summary preview .' + 'url url url'; } .asset-url { diff --git a/packages/playground/css-codesplit-cjs/main.css b/packages/playground/css-codesplit-cjs/main.css index 24aec3a5671d8f..adc68fa6a4dfa0 100644 --- a/packages/playground/css-codesplit-cjs/main.css +++ b/packages/playground/css-codesplit-cjs/main.css @@ -1,3 +1,3 @@ -h1 { +h1 { color: red; -} \ No newline at end of file +} diff --git a/packages/playground/dynamic-import/mxd.json b/packages/playground/dynamic-import/mxd.json index 9e26dfeeb6e641..0967ef424bce67 100644 --- a/packages/playground/dynamic-import/mxd.json +++ b/packages/playground/dynamic-import/mxd.json @@ -1 +1 @@ -{} \ No newline at end of file +{} diff --git a/packages/playground/multiple-entrypoints/deps.json b/packages/playground/multiple-entrypoints/deps.json index e5b880c83bc21b..cbf49c4172be3b 100644 --- a/packages/playground/multiple-entrypoints/deps.json +++ b/packages/playground/multiple-entrypoints/deps.json @@ -1 +1,27 @@ -{"a0":"./a0.js","a1":"./a1.js","a2":"./a2.js","a3":"./a3.js","a4":"./a4.js","a5":"./a5.js","a6":"./a6.js","a7":"./a7.js","a8":"./a8.js","a9":"./a9.js","a10":"./a10.js","a11":"./a11.js","a12":"./a12.js","a13":"./a13.js","a14":"./a14.js","a15":"./a15.js","a16":"./a16.js","a17":"./a17.js","a18":"./a18.js","a19":"./a19.js","a20":"./a20.js","a21":"./a21.js","a22":"./a22.js","a23":"./a23.js","a24":"./a24.js"} \ No newline at end of file +{ + "a0": "./a0.js", + "a1": "./a1.js", + "a2": "./a2.js", + "a3": "./a3.js", + "a4": "./a4.js", + "a5": "./a5.js", + "a6": "./a6.js", + "a7": "./a7.js", + "a8": "./a8.js", + "a9": "./a9.js", + "a10": "./a10.js", + "a11": "./a11.js", + "a12": "./a12.js", + "a13": "./a13.js", + "a14": "./a14.js", + "a15": "./a15.js", + "a16": "./a16.js", + "a17": "./a17.js", + "a18": "./a18.js", + "a19": "./a19.js", + "a20": "./a20.js", + "a21": "./a21.js", + "a22": "./a22.js", + "a23": "./a23.js", + "a24": "./a24.js" +} diff --git a/packages/playground/multiple-entrypoints/reference.scss b/packages/playground/multiple-entrypoints/reference.scss index e1367353e07e07..481c1db6c3a424 100644 --- a/packages/playground/multiple-entrypoints/reference.scss +++ b/packages/playground/multiple-entrypoints/reference.scss @@ -1 +1,3 @@ -.content { color: red; } \ No newline at end of file +.content { + color: red; +} diff --git a/packages/playground/ssr-vue/src/pages/Home.vue b/packages/playground/ssr-vue/src/pages/Home.vue index 827bfd82ba7f7f..cd4b3d7680d71b 100644 --- a/packages/playground/ssr-vue/src/pages/Home.vue +++ b/packages/playground/ssr-vue/src/pages/Home.vue @@ -7,7 +7,7 @@

msg from virtual module: {{ foo.msg }}

- + diff --git a/packages/playground/legacy/main.js b/packages/playground/legacy/main.js index 631f589eb541d8..18db0a9b7b84c7 100644 --- a/packages/playground/legacy/main.js +++ b/packages/playground/legacy/main.js @@ -15,3 +15,9 @@ if (import.meta.env.LEGACY) { } document.getElementById('env').textContent = `is legacy: ${isLegacy}` + +// Iterators + +document.getElementById('iterators').textContent = [...new Set(['hello'])].join( + '' +) diff --git a/packages/plugin-legacy/index.js b/packages/plugin-legacy/index.js index 1b449c963dda4f..cb21e5f63ec42a 100644 --- a/packages/plugin-legacy/index.js +++ b/packages/plugin-legacy/index.js @@ -263,7 +263,7 @@ function viteLegacyPlugin(options = {}) { targets, modules: false, bugfixes: true, - loose: true, + loose: false, useBuiltIns: needPolyfills ? 'usage' : false, corejs: needPolyfills ? { version: 3, proposals: false } From 8c9cf45391d893fe018da07126716e25ade1939c Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Mon, 17 May 2021 22:15:37 +0800 Subject: [PATCH 27/30] release: v2.3.3 --- packages/vite/CHANGELOG.md | 13 +++++++++++++ packages/vite/package.json | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/vite/CHANGELOG.md b/packages/vite/CHANGELOG.md index 24119b115415c8..d78a4e5404d989 100644 --- a/packages/vite/CHANGELOG.md +++ b/packages/vite/CHANGELOG.md @@ -1,3 +1,16 @@ +## [2.3.3](https://github.com/vitejs/vite/compare/v2.3.2...v2.3.3) (2021-05-17) + + +### Bug Fixes + +* ignore ids that start with \0 in plugin asset, fix [#3424](https://github.com/vitejs/vite/issues/3424) ([#3436](https://github.com/vitejs/vite/issues/3436)) ([f6cfe30](https://github.com/vitejs/vite/commit/f6cfe30abfc5179262aea807173d7591fd4dc876)) +* restore dynamic-import-polyfill ([#3434](https://github.com/vitejs/vite/issues/3434)) ([4112c5d](https://github.com/vitejs/vite/commit/4112c5d103673b83c50d446096086617dfaac5a3)) +* sass importer can't be undefined (fix: [#3390](https://github.com/vitejs/vite/issues/3390)) ([#3395](https://github.com/vitejs/vite/issues/3395)) ([30ff5a2](https://github.com/vitejs/vite/commit/30ff5a235d2a832cb45a761a03c5947460417b40)) +* skip fs fallback for out of root urls, fix [#3364](https://github.com/vitejs/vite/issues/3364) ([#3431](https://github.com/vitejs/vite/issues/3431)) ([19dae99](https://github.com/vitejs/vite/commit/19dae997f91607424af2d0e159ae2570463bbcb3)) +* warn about dynamic import polyfill only during build ([#3446](https://github.com/vitejs/vite/issues/3446)) ([5fe0550](https://github.com/vitejs/vite/commit/5fe05507dd28bbd863469628bc61b45a04f938bd)) + + + ## [2.3.2](https://github.com/vitejs/vite/compare/v2.3.1...v2.3.2) (2021-05-12) diff --git a/packages/vite/package.json b/packages/vite/package.json index 52e286630d99b3..57bd385defbb3f 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -1,6 +1,6 @@ { "name": "vite", - "version": "2.3.2", + "version": "2.3.3", "license": "MIT", "author": "Evan You", "description": "Native-ESM powered web dev build tool", From c5fecad0388fef734e591e5139847c304d48a542 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Mon, 17 May 2021 22:17:04 +0800 Subject: [PATCH 28/30] release: plugin-legacy@1.4.0 --- packages/plugin-legacy/CHANGELOG.md | 10 ++++++++++ packages/plugin-legacy/package.json | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/plugin-legacy/CHANGELOG.md b/packages/plugin-legacy/CHANGELOG.md index c7b87774dd3f4c..326f2903e20ef1 100644 --- a/packages/plugin-legacy/CHANGELOG.md +++ b/packages/plugin-legacy/CHANGELOG.md @@ -1,3 +1,13 @@ +# [1.4.0](https://github.com/vitejs/vite/compare/plugin-legacy@1.3.4...plugin-legacy@1.4.0) (2021-05-17) + + +### Bug Fixes + +* **plugin-legacy:** turn off babel loose mode ([#3406](https://github.com/vitejs/vite/issues/3406)) ([5348c02](https://github.com/vitejs/vite/commit/5348c02f58bde36c412dbfe36c3ad37772bf83e5)) +* restore dynamic-import-polyfill ([#3434](https://github.com/vitejs/vite/issues/3434)) ([4112c5d](https://github.com/vitejs/vite/commit/4112c5d103673b83c50d446096086617dfaac5a3)) + + + ## [1.3.4](https://github.com/vitejs/vite/compare/plugin-legacy@1.3.3...plugin-legacy@1.3.4) (2021-05-11) diff --git a/packages/plugin-legacy/package.json b/packages/plugin-legacy/package.json index 43973c58cbfcac..a984a46d038b39 100644 --- a/packages/plugin-legacy/package.json +++ b/packages/plugin-legacy/package.json @@ -1,6 +1,6 @@ { "name": "@vitejs/plugin-legacy", - "version": "1.3.4", + "version": "1.4.0", "license": "MIT", "author": "Evan You", "files": [ From e1dd7b029f5a6f15551904ea906804af30594b11 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Mon, 17 May 2021 22:21:54 +0800 Subject: [PATCH 29/30] chore(create-app): update vite version --- packages/create-app/template-lit-element-ts/package.json | 4 ++-- packages/create-app/template-lit-element/package.json | 4 ++-- packages/create-app/template-preact-ts/package.json | 4 ++-- packages/create-app/template-preact/package.json | 4 ++-- packages/create-app/template-react-ts/package.json | 4 ++-- packages/create-app/template-react/package.json | 4 ++-- packages/create-app/template-svelte-ts/package.json | 4 ++-- packages/create-app/template-svelte/package.json | 4 ++-- packages/create-app/template-vanilla-ts/package.json | 4 ++-- packages/create-app/template-vanilla/package.json | 4 ++-- packages/create-app/template-vue-ts/package.json | 4 ++-- packages/create-app/template-vue/package.json | 4 ++-- 12 files changed, 24 insertions(+), 24 deletions(-) diff --git a/packages/create-app/template-lit-element-ts/package.json b/packages/create-app/template-lit-element-ts/package.json index ef7a6c0155aa28..63f34edabc4ac0 100644 --- a/packages/create-app/template-lit-element-ts/package.json +++ b/packages/create-app/template-lit-element-ts/package.json @@ -18,7 +18,7 @@ "lit-element": "^2.4.0" }, "devDependencies": { - "vite": "^2.3.0", + "vite": "^2.3.3", "typescript": "^4.1.3" } -} +} \ No newline at end of file diff --git a/packages/create-app/template-lit-element/package.json b/packages/create-app/template-lit-element/package.json index 37fe533f1343f1..34f58807e351e7 100644 --- a/packages/create-app/template-lit-element/package.json +++ b/packages/create-app/template-lit-element/package.json @@ -16,6 +16,6 @@ "lit-element": "^2.4.0" }, "devDependencies": { - "vite": "^2.3.0" + "vite": "^2.3.3" } -} +} \ No newline at end of file diff --git a/packages/create-app/template-preact-ts/package.json b/packages/create-app/template-preact-ts/package.json index eb28f12b75a0f4..a2a7e121b94559 100644 --- a/packages/create-app/template-preact-ts/package.json +++ b/packages/create-app/template-preact-ts/package.json @@ -12,6 +12,6 @@ "devDependencies": { "@preact/preset-vite": "^2.0.0", "typescript": "^4.1.3", - "vite": "^2.3.0" + "vite": "^2.3.3" } -} +} \ No newline at end of file diff --git a/packages/create-app/template-preact/package.json b/packages/create-app/template-preact/package.json index 0becc082e85313..b0958012c89121 100644 --- a/packages/create-app/template-preact/package.json +++ b/packages/create-app/template-preact/package.json @@ -11,6 +11,6 @@ }, "devDependencies": { "@preact/preset-vite": "^2.0.0", - "vite": "^2.3.0" + "vite": "^2.3.3" } -} +} \ No newline at end of file diff --git a/packages/create-app/template-react-ts/package.json b/packages/create-app/template-react-ts/package.json index 14f9b4fde90b2b..d2365fd559a153 100644 --- a/packages/create-app/template-react-ts/package.json +++ b/packages/create-app/template-react-ts/package.json @@ -15,6 +15,6 @@ "@types/react-dom": "^17.0.0", "@vitejs/plugin-react-refresh": "^1.3.1", "typescript": "^4.1.2", - "vite": "^2.3.0" + "vite": "^2.3.3" } -} +} \ No newline at end of file diff --git a/packages/create-app/template-react/package.json b/packages/create-app/template-react/package.json index 49d37ec2b3a5f3..400762ce24fccc 100644 --- a/packages/create-app/template-react/package.json +++ b/packages/create-app/template-react/package.json @@ -12,6 +12,6 @@ }, "devDependencies": { "@vitejs/plugin-react-refresh": "^1.3.1", - "vite": "^2.3.0" + "vite": "^2.3.3" } -} +} \ No newline at end of file diff --git a/packages/create-app/template-svelte-ts/package.json b/packages/create-app/template-svelte-ts/package.json index 8d73ce7dbabceb..9eb9ee046a16eb 100644 --- a/packages/create-app/template-svelte-ts/package.json +++ b/packages/create-app/template-svelte-ts/package.json @@ -11,6 +11,6 @@ "svelte": "^3.37.0", "svelte-preprocess": "^4.7.2", "typescript": "^4.2.4", - "vite": "^2.3.0" + "vite": "^2.3.3" } -} +} \ No newline at end of file diff --git a/packages/create-app/template-svelte/package.json b/packages/create-app/template-svelte/package.json index aab7129c930879..f1e49fd3572371 100644 --- a/packages/create-app/template-svelte/package.json +++ b/packages/create-app/template-svelte/package.json @@ -9,6 +9,6 @@ "devDependencies": { "@sveltejs/vite-plugin-svelte": "^1.0.0-next.7", "svelte": "^3.37.0", - "vite": "^2.3.0" + "vite": "^2.3.3" } -} +} \ No newline at end of file diff --git a/packages/create-app/template-vanilla-ts/package.json b/packages/create-app/template-vanilla-ts/package.json index b168339e5c9f31..2d523c1443dd1f 100644 --- a/packages/create-app/template-vanilla-ts/package.json +++ b/packages/create-app/template-vanilla-ts/package.json @@ -8,6 +8,6 @@ }, "devDependencies": { "typescript": "^4.2.3", - "vite": "^2.3.0" + "vite": "^2.3.3" } -} +} \ No newline at end of file diff --git a/packages/create-app/template-vanilla/package.json b/packages/create-app/template-vanilla/package.json index 096c8504a00d89..7c7af0a29bc8ab 100644 --- a/packages/create-app/template-vanilla/package.json +++ b/packages/create-app/template-vanilla/package.json @@ -7,6 +7,6 @@ "serve": "vite preview" }, "devDependencies": { - "vite": "^2.3.0" + "vite": "^2.3.3" } -} +} \ No newline at end of file diff --git a/packages/create-app/template-vue-ts/package.json b/packages/create-app/template-vue-ts/package.json index 8c3110ed37bc04..73c167334943a1 100644 --- a/packages/create-app/template-vue-ts/package.json +++ b/packages/create-app/template-vue-ts/package.json @@ -13,7 +13,7 @@ "@vitejs/plugin-vue": "^1.2.2", "@vue/compiler-sfc": "^3.0.5", "typescript": "^4.1.3", - "vite": "^2.3.0", + "vite": "^2.3.3", "vue-tsc": "^0.0.24" } -} +} \ No newline at end of file diff --git a/packages/create-app/template-vue/package.json b/packages/create-app/template-vue/package.json index 035f26563680d5..918e8b3d942b9d 100644 --- a/packages/create-app/template-vue/package.json +++ b/packages/create-app/template-vue/package.json @@ -12,6 +12,6 @@ "devDependencies": { "@vitejs/plugin-vue": "^1.2.2", "@vue/compiler-sfc": "^3.0.5", - "vite": "^2.3.0" + "vite": "^2.3.3" } -} +} \ No newline at end of file From d1d7106424953ba32a78d68ab62a1e557d6ad19f Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Mon, 17 May 2021 22:22:04 +0800 Subject: [PATCH 30/30] release: create-app@2.3.1 --- packages/create-app/CHANGELOG.md | 9 +++++++++ packages/create-app/package.json | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/create-app/CHANGELOG.md b/packages/create-app/CHANGELOG.md index 700b7e5f6d49b6..0bacf2b0ead8de 100644 --- a/packages/create-app/CHANGELOG.md +++ b/packages/create-app/CHANGELOG.md @@ -1,3 +1,12 @@ +## [2.3.1](https://github.com/vitejs/vite/compare/create-app@2.3.0...create-app@2.3.1) (2021-05-17) + + +### Bug Fixes + +* **create-app:** lit-element templates package.json ([#3435](https://github.com/vitejs/vite/issues/3435)) ([74986d3](https://github.com/vitejs/vite/commit/74986d3d053aabe7ec3de20c987e9df309c684b2)) + + + # [2.3.0](https://github.com/vitejs/vite/compare/create-app@2.2.5...create-app@2.3.0) (2021-05-11) diff --git a/packages/create-app/package.json b/packages/create-app/package.json index f7a8f245d7819e..eea22e51689be3 100644 --- a/packages/create-app/package.json +++ b/packages/create-app/package.json @@ -1,6 +1,6 @@ { "name": "@vitejs/create-app", - "version": "2.3.0", + "version": "2.3.1", "license": "MIT", "author": "Evan You", "bin": {