From a74bd7ba9947be193bccf636b8918bd1f59e89ae Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Sat, 2 Apr 2022 00:33:21 +0800 Subject: [PATCH 001/175] docs: update release notes (#7563) --- packages/vite/CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/vite/CHANGELOG.md b/packages/vite/CHANGELOG.md index ac0df4435282b1..0f91a004602caa 100644 --- a/packages/vite/CHANGELOG.md +++ b/packages/vite/CHANGELOG.md @@ -21,7 +21,7 @@ Vite now supports CSS sourcemaps [#7173](https://github.com/vitejs/vite/issues/7 ### Avoid splitting vendor chunks by default -Vite's default chunking strategy was a good fit for most SPAs, but it wasn't ideal in some other use cases. Vite doesn't have enough context to make the best decision here, so in Vite 2.9 the previous chunking strategy is now opt-in [#6534](https://github.com/vitejs/vite/issues/6534) and Vite will no longer split vendor libs in a separate chunk. +Vite's default chunking strategy was a good fit for most SPAs, but it wasn't ideal in some other use cases. Vite doesn't have enough context to make the best decision here, so in Vite 2.9 the previous chunking strategy is now [opt-in](https://vitejs.dev/guide/build.html#chunking-strategy) [#6534](https://github.com/vitejs/vite/issues/6534) and Vite will no longer split vendor libs in a separate chunk. ### Web Workers enhancements @@ -37,6 +37,9 @@ const examples = import.meta.globEager('./examples/*.html', { as: 'raw' }) The `{ assert: { type: 'raw' }}` syntax introduced in v2.8 has been deprecated. See [#7017](https://github.com/vitejs/vite/issues/7017) for more information. +### `envDir` changes + +The `envDir` now correctly loads `.env` files in the specified directory only (defaults to `root`). Previously, it would load files above the directory, which imposed security issues. If you had relied on the previous behaviour, make sure you move your `.env` files to the correct directory, or configure the `envDir` option. ### New tools for Plugin and Framework Authors From 5d6ea8efc36bfdcd8b70afa8e82026ad1ccc0a77 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Sat, 2 Apr 2022 22:59:08 +0800 Subject: [PATCH 002/175] fix(resolver): skip known ESM entries when resolving a `require` call (#7582) --- .../resolve/__tests__/resolve.spec.ts | 10 ++++++-- packages/playground/resolve/index.html | 20 ++++++++++++---- packages/playground/resolve/package.json | 3 ++- .../dep.cjs | 0 .../index.cjs | 8 +++++++ .../package.json | 2 +- .../require-pkg-with-esm-entries/index.cjs | 9 +++++++ .../require-pkg-with-esm-entries/package.json | 9 +++++++ .../require-pkg-with-module-field/index.cjs | 8 ------- packages/playground/resolve/vite.config.js | 5 +++- packages/vite/src/node/constants.ts | 15 ++++++++++++ packages/vite/src/node/plugins/resolve.ts | 6 +++++ pnpm-lock.yaml | 24 ++++++++++++++++--- 13 files changed, 99 insertions(+), 20 deletions(-) rename packages/playground/resolve/{require-pkg-with-module-field => require-pkg-with-browser-and-module-field}/dep.cjs (100%) create mode 100644 packages/playground/resolve/require-pkg-with-browser-and-module-field/index.cjs rename packages/playground/resolve/{require-pkg-with-module-field => require-pkg-with-browser-and-module-field}/package.json (68%) create mode 100644 packages/playground/resolve/require-pkg-with-esm-entries/index.cjs create mode 100644 packages/playground/resolve/require-pkg-with-esm-entries/package.json delete mode 100644 packages/playground/resolve/require-pkg-with-module-field/index.cjs diff --git a/packages/playground/resolve/__tests__/resolve.spec.ts b/packages/playground/resolve/__tests__/resolve.spec.ts index 2deb2fab7f8d40..46f8f6138b39a4 100644 --- a/packages/playground/resolve/__tests__/resolve.spec.ts +++ b/packages/playground/resolve/__tests__/resolve.spec.ts @@ -61,8 +61,14 @@ test('dont add extension to directory name (./dir-with-ext.js/index.js)', async expect(await page.textContent('.dir-with-ext')).toMatch('[success]') }) -test('do not resolve to the `module` field if the importer is a `require` call', async () => { - expect(await page.textContent('.require-pkg-with-module-field')).toMatch( +test('resolve to the `browser` field instead of `module` when the importer is a `require` call', async () => { + expect( + await page.textContent('.require-pkg-with-browser-and-module-field') + ).toMatch('[success]') +}) + +test('resolve to the `main` field instead of `module` when the importer is a `require` call', async () => { + expect(await page.textContent('.require-pkg-with-esm-entries')).toMatch( '[success]' ) }) diff --git a/packages/playground/resolve/index.html b/packages/playground/resolve/index.html index 1920ebb675d24c..2478c89b495f49 100644 --- a/packages/playground/resolve/index.html +++ b/packages/playground/resolve/index.html @@ -58,8 +58,17 @@

Resolve file name containing dot

Browser Field

fail

-

Don't resolve to the `module` field if the importer is a `require` call

-

fail

+

+ Resolve to the `browser` field instead of `module` when the importer is a + `require` call +

+

fail

+ +

+ Resolve to the `main` field instead of `module` when the importer is a + `require` call +

+

fail

CSS Entry

@@ -185,8 +194,11 @@

resolve package that contains # in path

text('.browser', main) } - import { msg as requireButWithModuleFieldMsg } from 'require-pkg-with-module-field' - text('.require-pkg-with-module-field', requireButWithModuleFieldMsg) + import { msg as requireBrowserMsg } from 'require-pkg-with-browser-and-module-field' + text('.require-pkg-with-browser-and-module-field', requireBrowserMsg) + + import { msg as requireMainMsg } from 'require-pkg-with-esm-entries' + text('.require-pkg-with-esm-entries', requireMainMsg) import { msg as customExtMsg } from './custom-ext' text('.custom-ext', customExtMsg) diff --git a/packages/playground/resolve/package.json b/packages/playground/resolve/package.json index dda4476bc6ae82..4b8d497b3dbb27 100644 --- a/packages/playground/resolve/package.json +++ b/packages/playground/resolve/package.json @@ -12,7 +12,8 @@ "@babel/runtime": "^7.16.0", "es5-ext": "0.10.53", "normalize.css": "^8.0.1", - "require-pkg-with-module-field": "link:./require-pkg-with-module-field", + "require-pkg-with-browser-and-module-field": "link:./require-pkg-with-browser-and-module-field", + "require-pkg-with-esm-entries": "link:./require-pkg-with-esm-entries", "resolve-browser-field": "link:./browser-field", "resolve-custom-condition": "link:./custom-condition", "resolve-custom-main-field": "link:./custom-main-field", diff --git a/packages/playground/resolve/require-pkg-with-module-field/dep.cjs b/packages/playground/resolve/require-pkg-with-browser-and-module-field/dep.cjs similarity index 100% rename from packages/playground/resolve/require-pkg-with-module-field/dep.cjs rename to packages/playground/resolve/require-pkg-with-browser-and-module-field/dep.cjs diff --git a/packages/playground/resolve/require-pkg-with-browser-and-module-field/index.cjs b/packages/playground/resolve/require-pkg-with-browser-and-module-field/index.cjs new file mode 100644 index 00000000000000..86d3360ab38dcb --- /dev/null +++ b/packages/playground/resolve/require-pkg-with-browser-and-module-field/index.cjs @@ -0,0 +1,8 @@ +const dep = require('./dep.cjs') + +const msg = + dep === '1.111222233334444555566e+21' + ? '[success] require-pkg-with-browser-and-module-field' + : '[failed] require-pkg-with-browser-and-module-field' + +exports.msg = msg diff --git a/packages/playground/resolve/require-pkg-with-module-field/package.json b/packages/playground/resolve/require-pkg-with-browser-and-module-field/package.json similarity index 68% rename from packages/playground/resolve/require-pkg-with-module-field/package.json rename to packages/playground/resolve/require-pkg-with-browser-and-module-field/package.json index e409343a7567d5..2a0419b331c407 100644 --- a/packages/playground/resolve/require-pkg-with-module-field/package.json +++ b/packages/playground/resolve/require-pkg-with-browser-and-module-field/package.json @@ -1,5 +1,5 @@ { - "name": "require-pkg-with-module-field", + "name": "require-pkg-with-browser-and-module-field", "private": true, "version": "1.0.0", "main": "./index.cjs", diff --git a/packages/playground/resolve/require-pkg-with-esm-entries/index.cjs b/packages/playground/resolve/require-pkg-with-esm-entries/index.cjs new file mode 100644 index 00000000000000..55958fbdba26ee --- /dev/null +++ b/packages/playground/resolve/require-pkg-with-esm-entries/index.cjs @@ -0,0 +1,9 @@ +const fromEvent = require('callbag-from-event') + +const msg = + // should be the exported function instead of the ES Module record (`{ default: ... }`) + typeof fromEvent === 'function' + ? '[success] require-pkg-with-esm-entries' + : '[failed] require-pkg-with-esm-entries' + +exports.msg = msg diff --git a/packages/playground/resolve/require-pkg-with-esm-entries/package.json b/packages/playground/resolve/require-pkg-with-esm-entries/package.json new file mode 100644 index 00000000000000..b845364bb6f19a --- /dev/null +++ b/packages/playground/resolve/require-pkg-with-esm-entries/package.json @@ -0,0 +1,9 @@ +{ + "name": "require-pkg-with-esm-entries", + "private": true, + "version": "1.0.0", + "main": "./index.cjs", + "dependencies": { + "callbag-from-event": "1.3.0" + } +} diff --git a/packages/playground/resolve/require-pkg-with-module-field/index.cjs b/packages/playground/resolve/require-pkg-with-module-field/index.cjs deleted file mode 100644 index da215f306d1ac1..00000000000000 --- a/packages/playground/resolve/require-pkg-with-module-field/index.cjs +++ /dev/null @@ -1,8 +0,0 @@ -const dep = require('./dep.cjs') - -const msg = - dep === '1.111222233334444555566e+21' - ? '[success] require-pkg-with-module-field' - : '[failed] require-pkg-with-module-field' - -exports.msg = msg diff --git a/packages/playground/resolve/vite.config.js b/packages/playground/resolve/vite.config.js index 0550d1ecf6f044..c1282f4ffc789d 100644 --- a/packages/playground/resolve/vite.config.js +++ b/packages/playground/resolve/vite.config.js @@ -42,6 +42,9 @@ module.exports = { } ], optimizeDeps: { - include: ['require-pkg-with-module-field'] + include: [ + 'require-pkg-with-browser-and-module-field', + 'require-pkg-with-esm-entries' + ] } } diff --git a/packages/vite/src/node/constants.ts b/packages/vite/src/node/constants.ts index 9612cd8c96460d..1741bf2dd7a94b 100644 --- a/packages/vite/src/node/constants.ts +++ b/packages/vite/src/node/constants.ts @@ -6,6 +6,21 @@ export const DEFAULT_MAIN_FIELDS = [ 'jsnext' ] +/** + * A non-exhaustive list of known-to-be-ES-module entry names. + * From + */ +export const KNOWN_ESM_MAIN_FIELDS = [ + 'module', + 'jsnext:main', + 'jsnext', + 'esnext', + 'es2015', + 'es2020', + 'fesm2015', + 'fesm2020' +] + export const DEFAULT_EXTENSIONS = [ '.mjs', '.js', diff --git a/packages/vite/src/node/plugins/resolve.ts b/packages/vite/src/node/plugins/resolve.ts index 1b59503a9d43ed..10e2989af1114f 100644 --- a/packages/vite/src/node/plugins/resolve.ts +++ b/packages/vite/src/node/plugins/resolve.ts @@ -7,6 +7,7 @@ import { SPECIAL_QUERY_RE, DEFAULT_EXTENSIONS, DEFAULT_MAIN_FIELDS, + KNOWN_ESM_MAIN_FIELDS, OPTIMIZABLE_ENTRY_RE, DEP_VERSION_RE } from '../constants' @@ -777,6 +778,11 @@ export function resolvePackageEntry( if (!entryPoint || entryPoint.endsWith('.mjs')) { for (const field of options.mainFields || DEFAULT_MAIN_FIELDS) { + // If the initiator is a `require` call, don't use the ESM entries + if (options.isRequire && KNOWN_ESM_MAIN_FIELDS.includes(field)) { + continue + } + if (typeof data[field] === 'string') { entryPoint = data[field] break diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 461ca065e2e18d..209425cc19d89e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -461,7 +461,8 @@ importers: '@babel/runtime': ^7.16.0 es5-ext: 0.10.53 normalize.css: ^8.0.1 - require-pkg-with-module-field: link:./require-pkg-with-module-field + require-pkg-with-browser-and-module-field: link:./require-pkg-with-browser-and-module-field + require-pkg-with-esm-entries: link:./require-pkg-with-esm-entries resolve-browser-field: link:./browser-field resolve-custom-condition: link:./custom-condition resolve-custom-main-field: link:./custom-main-field @@ -472,7 +473,8 @@ importers: '@babel/runtime': 7.16.5 es5-ext: 0.10.53 normalize.css: 8.0.1 - require-pkg-with-module-field: link:require-pkg-with-module-field + require-pkg-with-browser-and-module-field: link:require-pkg-with-browser-and-module-field + require-pkg-with-esm-entries: link:require-pkg-with-esm-entries resolve-browser-field: link:browser-field resolve-custom-condition: link:custom-condition resolve-custom-main-field: link:custom-main-field @@ -504,12 +506,18 @@ importers: packages/playground/resolve/inline-package: specifiers: {} - packages/playground/resolve/require-pkg-with-module-field: + packages/playground/resolve/require-pkg-with-browser-and-module-field: specifiers: bignumber.js: 9.0.2 dependencies: bignumber.js: 9.0.2 + packages/playground/resolve/require-pkg-with-esm-entries: + specifiers: + callbag-from-event: 1.3.0 + dependencies: + callbag-from-event: 1.3.0 + packages/playground/ssr-deps: specifiers: bcrypt: ^5.0.1 @@ -3476,6 +3484,16 @@ packages: get-intrinsic: 1.1.1 dev: true + /callbag-from-event/1.3.0: + resolution: {integrity: sha512-cAu82hKKFmMtKTmd50p/nlMfs1oKz+PGUZmmwhbzPbw4YtjNgTKg6pXjpcQprhBQdrqg/v8pHcAS8Qs6X7r8fw==} + dependencies: + callbag: 1.5.0 + dev: false + + /callbag/1.5.0: + resolution: {integrity: sha512-PH3id0HEb/cNS+BehYlF4Z5wzjKAIUao6ab2hWtMs2bi6aW+0PXl0jymqwnFyT2cQO2h30ggUgpQlmzOpAIKNg==} + dev: false + /callsites/3.1.0: resolution: {integrity: sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==} engines: {node: '>=6'} From f26b14a0d8f4c909cb8cf3188684333b488c0714 Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Mon, 4 Apr 2022 02:38:35 +0800 Subject: [PATCH 003/175] docs(legacy): note works in build only (#7596) --- packages/plugin-legacy/README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/plugin-legacy/README.md b/packages/plugin-legacy/README.md index ec7e630c87755a..36da971c6a17c2 100644 --- a/packages/plugin-legacy/README.md +++ b/packages/plugin-legacy/README.md @@ -1,8 +1,6 @@ # @vitejs/plugin-legacy [![npm](https://img.shields.io/npm/v/@vitejs/plugin-legacy.svg)](https://npmjs.com/package/@vitejs/plugin-legacy) -**Note: this plugin requires `vite@^2.0.0`**. - -Vite's default browser support baseline is [Native ESM](https://caniuse.com/es6-module). This plugin provides support for legacy browsers that do not support native ESM. +Vite's default browser support baseline is [Native ESM](https://caniuse.com/es6-module). This plugin provides support for legacy browsers that do not support native ESM when building for production. By default, this plugin will: From 212d4548eeb366289c6c6fa6f86f94b261ed81f4 Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Mon, 4 Apr 2022 03:21:46 +0800 Subject: [PATCH 004/175] fix: detect env hmr (#7595) --- packages/vite/src/node/server/hmr.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/vite/src/node/server/hmr.ts b/packages/vite/src/node/server/hmr.ts index fc18b0aa91c5cb..07d664cbd39f50 100644 --- a/packages/vite/src/node/server/hmr.ts +++ b/packages/vite/src/node/server/hmr.ts @@ -44,6 +44,7 @@ export async function handleHMRUpdate( ): Promise { const { ws, config, moduleGraph } = server const shortFile = getShortName(file, config.root) + const fileName = path.basename(file) const isConfig = file === config.configFile const isConfigDependency = config.configFileDependencies.some( @@ -51,7 +52,7 @@ export async function handleHMRUpdate( ) const isEnv = config.inlineConfig.envFile !== false && - (file === '.env' || file.startsWith('.env.')) + (fileName === '.env' || fileName.startsWith('.env.')) if (isConfig || isConfigDependency || isEnv) { // auto restart server debugHmr(`[config change] ${colors.dim(shortFile)}`) From b6205871ac680b82bc6fb1399e091dd46ef2b6aa Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Mon, 4 Apr 2022 12:39:46 +0800 Subject: [PATCH 005/175] fix: update ws types (#7605) --- packages/vite/src/node/server/ws.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/vite/src/node/server/ws.ts b/packages/vite/src/node/server/ws.ts index a01d0bd3225571..6d4e66ec1a22ae 100644 --- a/packages/vite/src/node/server/ws.ts +++ b/packages/vite/src/node/server/ws.ts @@ -5,6 +5,7 @@ import type { ServerOptions as HttpsServerOptions } from 'https' import { createServer as createHttpsServer } from 'https' import type { ServerOptions, WebSocket as WebSocketRaw } from 'ws' import { WebSocketServer as WebSocketServerRaw } from 'ws' +import type { WebSocket as WebSocketTypes } from 'types/ws' import type { CustomPayload, ErrorPayload, HMRPayload } from 'types/hmrPayload' import type { InferCustomEventPayload } from 'types/customEvent' import type { ResolvedConfig } from '..' @@ -38,7 +39,7 @@ export interface WebSocketServer { /** * Handle custom event emitted by `import.meta.hot.send` */ - on: WebSocketServerRaw['on'] & { + on: WebSocketTypes.Server['on'] & { ( event: T, listener: WebSocketCustomListener> @@ -47,7 +48,7 @@ export interface WebSocketServer { /** * Unregister event listener. */ - off: WebSocketServerRaw['off'] & { + off: WebSocketTypes.Server['off'] & { (event: string, listener: Function): void } } @@ -65,7 +66,7 @@ export interface WebSocketClient { * The raw WebSocket instance * @advanced */ - socket: WebSocketRaw + socket: WebSocketTypes } const wsServerEvents = [ From cf59005a79dd7227f3ad63280761060ba224ce09 Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Mon, 4 Apr 2022 12:42:43 +0800 Subject: [PATCH 006/175] fix: use correct proxy config in preview (#7604) --- packages/vite/src/node/preview.ts | 5 +++-- packages/vite/src/node/server/index.ts | 2 +- packages/vite/src/node/server/middlewares/proxy.ts | 5 ++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/vite/src/node/preview.ts b/packages/vite/src/node/preview.ts index 56dee04e2e2e07..c00f62a9cb8f0c 100644 --- a/packages/vite/src/node/preview.ts +++ b/packages/vite/src/node/preview.ts @@ -78,8 +78,9 @@ export async function preview( } // proxy - if (config.preview.proxy) { - app.use(proxyMiddleware(httpServer, config)) + const { proxy } = config.preview + if (proxy) { + app.use(proxyMiddleware(httpServer, proxy, config)) } app.use(compression()) diff --git a/packages/vite/src/node/server/index.ts b/packages/vite/src/node/server/index.ts index 996b7601e84786..de80ac1147ff0f 100644 --- a/packages/vite/src/node/server/index.ts +++ b/packages/vite/src/node/server/index.ts @@ -516,7 +516,7 @@ export async function createServer( // proxy const { proxy } = serverConfig if (proxy) { - middlewares.use(proxyMiddleware(httpServer, config)) + middlewares.use(proxyMiddleware(httpServer, proxy, config)) } // base diff --git a/packages/vite/src/node/server/middlewares/proxy.ts b/packages/vite/src/node/server/middlewares/proxy.ts index aa1100f13d5229..97de98a8331a7a 100644 --- a/packages/vite/src/node/server/middlewares/proxy.ts +++ b/packages/vite/src/node/server/middlewares/proxy.ts @@ -5,7 +5,7 @@ import { HMR_HEADER } from '../ws' import type { Connect } from 'types/connect' import type { HttpProxy } from 'types/http-proxy' import colors from 'picocolors' -import type { ResolvedConfig } from '../..' +import type { CommonServerOptions, ResolvedConfig } from '../..' const debug = createDebugger('vite:proxy') @@ -30,10 +30,9 @@ export interface ProxyOptions extends HttpProxy.ServerOptions { export function proxyMiddleware( httpServer: http.Server | null, + options: NonNullable, config: ResolvedConfig ): Connect.NextHandleFunction { - const options = config.server.proxy! - // lazy require only when proxy is used const proxies: Record = {} From 45b9273d3731605db7c32206a596e4e193d15a39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Mon, 4 Apr 2022 19:21:02 +0900 Subject: [PATCH 007/175] fix(css): include inline css module in bundle (#7591) --- packages/playground/css/__tests__/css.spec.ts | 5 +++++ packages/playground/css/index.html | 3 +++ packages/playground/css/inline.module.css | 3 +++ packages/playground/css/main.js | 3 +++ packages/vite/src/node/plugins/css.ts | 21 ++++++++++++------- 5 files changed, 28 insertions(+), 7 deletions(-) create mode 100644 packages/playground/css/inline.module.css diff --git a/packages/playground/css/__tests__/css.spec.ts b/packages/playground/css/__tests__/css.spec.ts index ddb5c8c69d0e48..a476826e2023cc 100644 --- a/packages/playground/css/__tests__/css.spec.ts +++ b/packages/playground/css/__tests__/css.spec.ts @@ -242,6 +242,11 @@ test('css modules w/ sass', async () => { await untilUpdated(() => getColor(imported), 'blue') }) +test('inline css modules', async () => { + const css = await page.textContent('.modules-inline') + expect(css).toMatch(/\.inline-module__apply-color-inline___[\w-]{5}/) +}) + test('@import dependency w/ style entry', async () => { expect(await getColor('.css-dep')).toBe('purple') }) diff --git a/packages/playground/css/index.html b/packages/playground/css/index.html index d08bc232752e8b..52d6bffef134e6 100644 --- a/packages/playground/css/index.html +++ b/packages/playground/css/index.html @@ -89,6 +89,9 @@

CSS


 
+  

Inline CSS module:

+

+
   

@import dependency w/ style enrtrypoints: this should be purple

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/main.js b/packages/playground/css/main.js index 6edd840a87c5e7..564b3a56677dbd 100644 --- a/packages/playground/css/main.js +++ b/packages/playground/css/main.js @@ -38,6 +38,9 @@ text( JSON.stringify(composesPathResolvingMod, null, 2) ) +import inlineMod from './inline.module.css?inline' +text('.modules-inline', inlineMod) + import './dep.css' import './glob-dep.css' diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index c60430f40eca71..e2ce47851b7818 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -358,14 +358,21 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin { styles.set(id, css) } + let code: string + if (usedRE.test(id)) { + if (inlined) { + code = `export default ${JSON.stringify( + await minifyCSS(css, config) + )}` + } else { + code = modulesCode || `export default ${JSON.stringify(css)}` + } + } else { + code = `export default ''` + } + return { - code: - modulesCode || - (usedRE.test(id) - ? `export default ${JSON.stringify( - inlined ? await minifyCSS(css, config) : css - )}` - : `export default ''`), + code, map: { mappings: '' }, // avoid the css module from being tree-shaken so that we can retrieve // it in renderChunk() From 8b21029f9dcd1a63e8b58f3d54cef12c53ebef53 Mon Sep 17 00:00:00 2001 From: Shahriar Shojib Date: Mon, 4 Apr 2022 16:24:42 +0600 Subject: [PATCH 008/175] chore(create-vite-app): upgrade react to 18 (#7597) Co-authored-by: Alec Larson <1925840+aleclarson@users.noreply.github.com> --- .../create-vite/template-react-ts/package.json | 14 +++++++------- .../create-vite/template-react-ts/src/main.tsx | 9 ++++----- packages/create-vite/template-react/package.json | 10 ++++++---- packages/create-vite/template-react/src/main.jsx | 9 ++++----- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/packages/create-vite/template-react-ts/package.json b/packages/create-vite/template-react-ts/package.json index 00f99c8669d660..c08d472dca7477 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.9.0" + "@types/react": "^17.0.43", + "@types/react-dom": "^17.0.14", + "@vitejs/plugin-react": "^1.3.0", + "typescript": "^4.6.3", + "vite": "^2.9.1" } } 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( - , - document.getElementById('root') + ) diff --git a/packages/create-vite/template-react/package.json b/packages/create-vite/template-react/package.json index f6a93540f0d3ee..ac105bd8796ace 100644 --- a/packages/create-vite/template-react/package.json +++ b/packages/create-vite/template-react/package.json @@ -8,11 +8,13 @@ "preview": "vite preview" }, "dependencies": { - "react": "^17.0.2", - "react-dom": "^17.0.2" + "react": "^18.0.0", + "react-dom": "^18.0.0" }, "devDependencies": { - "@vitejs/plugin-react": "^1.0.7", - "vite": "^2.9.0" + "@types/react": "^17.0.43", + "@types/react-dom": "^17.0.14", + "@vitejs/plugin-react": "^1.3.0", + "vite": "^2.9.1" } } diff --git a/packages/create-vite/template-react/src/main.jsx b/packages/create-vite/template-react/src/main.jsx index 606a3cf44ec02b..9af0bb638e42c0 100644 --- a/packages/create-vite/template-react/src/main.jsx +++ b/packages/create-vite/template-react/src/main.jsx @@ -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( - , - document.getElementById('root') + ) From 2dc0e804826355333e2467f93bed422c5473aa59 Mon Sep 17 00:00:00 2001 From: Axe Date: Mon, 4 Apr 2022 09:52:03 -0600 Subject: [PATCH 009/175] fix: build should also respect esbuild=false config (#7602) --- packages/vite/src/node/build.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vite/src/node/build.ts b/packages/vite/src/node/build.ts index d898b090fcdf6c..3541cc377dc411 100644 --- a/packages/vite/src/node/build.ts +++ b/packages/vite/src/node/build.ts @@ -319,7 +319,7 @@ export function resolveBuildPlugins(config: ResolvedConfig): { ], post: [ buildImportAnalysisPlugin(config), - buildEsbuildPlugin(config), + ...(config.esbuild !== false ? [buildEsbuildPlugin(config)] : []), ...(options.minify ? [terserPlugin(config)] : []), ...(options.manifest ? [manifestPlugin(config)] : []), ...(options.ssrManifest ? [ssrManifestPlugin(config)] : []), From 57e791482868a49fb216d57cf758b21aac92cdbf Mon Sep 17 00:00:00 2001 From: Rom Date: Mon, 4 Apr 2022 20:17:10 +0200 Subject: [PATCH 010/175] fix: fix HMR propagation when imports not analyzed (#7561) --- packages/playground/hmr/__tests__/hmr.spec.ts | 34 +++++++++++++++++++ packages/playground/hmr/dynamic-import/dep.ts | 2 ++ .../playground/hmr/dynamic-import/index.html | 2 ++ .../playground/hmr/dynamic-import/index.ts | 12 +++++++ .../vite/src/node/plugins/importAnalysis.ts | 17 +++++++--- packages/vite/src/node/server/hmr.ts | 7 ++++ packages/vite/src/node/server/moduleGraph.ts | 2 +- 7 files changed, 70 insertions(+), 6 deletions(-) create mode 100644 packages/playground/hmr/dynamic-import/dep.ts create mode 100644 packages/playground/hmr/dynamic-import/index.html create mode 100644 packages/playground/hmr/dynamic-import/index.ts diff --git a/packages/playground/hmr/__tests__/hmr.spec.ts b/packages/playground/hmr/__tests__/hmr.spec.ts index 6ddc2345ae4fb4..7325c9fe47943a 100644 --- a/packages/playground/hmr/__tests__/hmr.spec.ts +++ b/packages/playground/hmr/__tests__/hmr.spec.ts @@ -160,4 +160,38 @@ if (!isBuild) { expect(textprev).not.toMatch('direct') expect(textpost).not.toMatch('direct') }) + + test('not loaded dynamic import', async () => { + await page.goto(viteTestUrl + '/dynamic-import/index.html') + + let btn = await page.$('button') + expect(await btn.textContent()).toBe('Counter 0') + await btn.click() + expect(await btn.textContent()).toBe('Counter 1') + + // Modifying `index.ts` triggers a page reload, as expected + editFile('dynamic-import/index.ts', (code) => code) + await page.waitForNavigation() + btn = await page.$('button') + expect(await btn.textContent()).toBe('Counter 0') + + await btn.click() + expect(await btn.textContent()).toBe('Counter 1') + + // #7561 + // `dep.ts` defines `import.module.hot.accept` and has not been loaded. + // Therefore, modifying it has no effect (doesn't trigger a page reload). + // (Note that, a dynamic import that is never loaded and that does not + // define `accept.module.hot.accept` may wrongfully trigger a full page + // reload, see discussion at #7561.) + editFile('dynamic-import/dep.ts', (code) => code) + try { + await page.waitForNavigation({ timeout: 1000 }) + } catch (err) { + const errMsg = 'page.waitForNavigation: Timeout 1000ms exceeded.' + expect(err.message.slice(0, errMsg.length)).toBe(errMsg) + } + btn = await page.$('button') + expect(await btn.textContent()).toBe('Counter 1') + }) } diff --git a/packages/playground/hmr/dynamic-import/dep.ts b/packages/playground/hmr/dynamic-import/dep.ts new file mode 100644 index 00000000000000..aca649f226f770 --- /dev/null +++ b/packages/playground/hmr/dynamic-import/dep.ts @@ -0,0 +1,2 @@ +// This file is never loaded +import.meta.hot.accept(() => {}) diff --git a/packages/playground/hmr/dynamic-import/index.html b/packages/playground/hmr/dynamic-import/index.html new file mode 100644 index 00000000000000..f5290ad4f1e507 --- /dev/null +++ b/packages/playground/hmr/dynamic-import/index.html @@ -0,0 +1,2 @@ + + diff --git a/packages/playground/hmr/dynamic-import/index.ts b/packages/playground/hmr/dynamic-import/index.ts new file mode 100644 index 00000000000000..0230140278989f --- /dev/null +++ b/packages/playground/hmr/dynamic-import/index.ts @@ -0,0 +1,12 @@ +const btn = document.querySelector('button') +let count = 0 +const update = () => { + btn.textContent = `Counter ${count}` +} +btn.onclick = () => { + count++ + update() +} +function neverCalled() { + import('./dep') +} diff --git a/packages/vite/src/node/plugins/importAnalysis.ts b/packages/vite/src/node/plugins/importAnalysis.ts index f6d6c410411712..31e9cd76faa8a0 100644 --- a/packages/vite/src/node/plugins/importAnalysis.ts +++ b/packages/vite/src/node/plugins/importAnalysis.ts @@ -122,6 +122,12 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin { }, async transform(source, importer, options) { + // In a real app `server` is always defined, but it is undefined when + // running src/node/server/__tests__/pluginContainer.spec.ts + if (!server) { + return null + } + const ssr = options?.ssr === true const prettyImporter = prettifyUrl(importer, root) @@ -159,7 +165,13 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin { ) } + const { moduleGraph } = server + // since we are already in the transform phase of the importer, it must + // have been loaded so its entry is guaranteed in the module graph. + const importerModule = moduleGraph.getModuleById(importer)! + if (!imports.length) { + importerModule.isSelfAccepting = false isDebug && debug( `${timeFrom(start)} ${colors.dim(`[no imports] ${prettyImporter}`)}` @@ -173,11 +185,6 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin { let needQueryInjectHelper = false let s: MagicString | undefined const str = () => s || (s = new MagicString(source)) - // vite-only server context - const { moduleGraph } = server - // since we are already in the transform phase of the importer, it must - // have been loaded so its entry is guaranteed in the module graph. - const importerModule = moduleGraph.getModuleById(importer)! const importedUrls = new Set() const staticImportedUrls = new Set() const acceptedUrls = new Set<{ diff --git a/packages/vite/src/node/server/hmr.ts b/packages/vite/src/node/server/hmr.ts index 07d664cbd39f50..8d33554706dee2 100644 --- a/packages/vite/src/node/server/hmr.ts +++ b/packages/vite/src/node/server/hmr.ts @@ -226,6 +226,13 @@ function propagateUpdate( }>, currentChain: ModuleNode[] = [node] ): boolean /* hasDeadEnd */ { + // #7561 + // if the imports of `node` have not been analyzed, then `node` has not + // been loaded in the browser and we should stop propagation. + if (node.id && node.isSelfAccepting === undefined) { + return false + } + if (node.isSelfAccepting) { boundaries.add({ boundary: node, diff --git a/packages/vite/src/node/server/moduleGraph.ts b/packages/vite/src/node/server/moduleGraph.ts index 44e76deef98b6f..e470fafb05d8fd 100644 --- a/packages/vite/src/node/server/moduleGraph.ts +++ b/packages/vite/src/node/server/moduleGraph.ts @@ -27,7 +27,7 @@ export class ModuleNode { importers = new Set() importedModules = new Set() acceptedHmrDeps = new Set() - isSelfAccepting = false + isSelfAccepting?: boolean transformResult: TransformResult | null = null ssrTransformResult: TransformResult | null = null ssrModule: Record | null = null From fc51a15e1e08b88e1bd8ed5335188d79fccf713b Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 4 Apr 2022 20:31:44 +0200 Subject: [PATCH 011/175] chore(deps): update all non-major dependencies (#7603) Co-authored-by: bluwy --- package.json | 12 +- packages/plugin-react/package.json | 2 +- packages/plugin-react/src/fast-refresh.ts | 9 +- packages/plugin-react/src/index.ts | 2 +- packages/vite/package.json | 10 +- pnpm-lock.yaml | 184 ++++++++++++---------- 6 files changed, 125 insertions(+), 94 deletions(-) diff --git a/package.json b/package.json index f6166c2985a30c..27445e0d25cb29 100644 --- a/package.json +++ b/package.json @@ -34,14 +34,14 @@ "ci-docs": "run-s build-vite build-plugin-vue build-docs" }, "devDependencies": { - "@microsoft/api-extractor": "^7.19.5", + "@microsoft/api-extractor": "^7.20.0", "@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.17.0", + "@typescript-eslint/parser": "^5.17.0", "conventional-changelog-cli": "^2.2.2", "cross-env": "^7.0.3", "esbuild": "^0.14.27", @@ -56,8 +56,8 @@ "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", @@ -85,7 +85,7 @@ "eslint --ext .ts" ] }, - "packageManager": "pnpm@6.32.3", + "packageManager": "pnpm@6.32.4", "pnpm": { "overrides": { "vite": "workspace:*", diff --git a/packages/plugin-react/package.json b/packages/plugin-react/package.json index 8313fc5a81d648..e0230a4a61cd30 100644 --- a/packages/plugin-react/package.json +++ b/packages/plugin-react/package.json @@ -39,7 +39,7 @@ "@babel/plugin-transform-react-jsx-self": "^7.16.7", "@babel/plugin-transform-react-jsx-source": "^7.16.7", "@rollup/pluginutils": "^4.2.0", - "react-refresh": "^0.11.0", + "react-refresh": "^0.12.0", "resolve": "^1.22.0" } } diff --git a/packages/plugin-react/src/fast-refresh.ts b/packages/plugin-react/src/fast-refresh.ts index 70562bbbdfc5b7..4672e26f6264e3 100644 --- a/packages/plugin-react/src/fast-refresh.ts +++ b/packages/plugin-react/src/fast-refresh.ts @@ -1,10 +1,15 @@ import type { types as t } from '@babel/core' import fs from 'fs' +import path from 'path' export const runtimePublicPath = '/@react-refresh' -const runtimeFilePath = require.resolve( - 'react-refresh/cjs/react-refresh-runtime.development.js' +const reactRefreshDir = path.dirname( + require.resolve('react-refresh/package.json') +) +const runtimeFilePath = path.join( + reactRefreshDir, + 'cjs/react-refresh-runtime.development.js' ) export const runtimeCode = ` diff --git a/packages/plugin-react/src/index.ts b/packages/plugin-react/src/index.ts index 76f6c6c2a799f3..cefab59d94fe53 100644 --- a/packages/plugin-react/src/index.ts +++ b/packages/plugin-react/src/index.ts @@ -176,7 +176,7 @@ export default function viteReact(opts: Options = {}): PluginOption[] { if (isReactModule && filter(id)) { useFastRefresh = true plugins.push([ - await loadPlugin('react-refresh/babel.js'), + await loadPlugin('react-refresh/babel'), { skipEnvCheck: true } ]) } diff --git a/packages/vite/package.json b/packages/vite/package.json index 1a2aeddef3f42d..d2a351c6aa0869 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -74,7 +74,7 @@ "@types/node": "^16.11.26", "@types/resolve": "^1.20.1", "@types/sass": "~1.43.1", - "@types/stylus": "^0.48.36", + "@types/stylus": "^0.48.37", "@types/ws": "^8.5.3", "@vue/compiler-dom": "^3.2.31", "acorn": "^8.7.0", @@ -88,7 +88,7 @@ "debug": "^4.3.4", "dotenv": "^14.3.2", "dotenv-expand": "^5.1.0", - "es-module-lexer": "^0.10.4", + "es-module-lexer": "^0.10.5", "estree-walker": "^2.0.2", "etag": "^1.8.1", "fast-glob": "^3.2.11", @@ -98,13 +98,13 @@ "magic-string": "^0.26.1", "micromatch": "^4.0.5", "mrmime": "^1.0.0", - "node-forge": "^1.3.0", + "node-forge": "^1.3.1", "okie": "^1.0.1", "open": "^8.4.0", "periscopic": "^2.0.3", "picocolors": "^1.0.0", "postcss-import": "^14.1.0", - "postcss-load-config": "^3.1.3", + "postcss-load-config": "^3.1.4", "postcss-modules": "^4.3.1", "resolve.exports": "^1.1.0", "rollup-plugin-license": "^2.6.1", @@ -113,7 +113,7 @@ "source-map-support": "^0.5.21", "strip-ansi": "^6.0.1", "terser": "^5.12.1", - "tsconfck": "^1.2.1", + "tsconfck": "^1.2.2", "tslib": "^2.3.1", "types": "link:./types", "ws": "^8.5.0" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 209425cc19d89e..a54c2eadfcfff2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -10,14 +10,14 @@ importers: .: specifiers: - '@microsoft/api-extractor': ^7.19.5 + '@microsoft/api-extractor': ^7.20.0 '@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.17.0 + '@typescript-eslint/parser': ^5.17.0 conventional-changelog-cli: ^2.2.2 cross-env: ^7.0.3 esbuild: ^0.14.27 @@ -32,8 +32,8 @@ importers: 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 @@ -46,14 +46,14 @@ importers: vite: workspace:* vitepress: ^0.22.3 devDependencies: - '@microsoft/api-extractor': 7.19.5 + '@microsoft/api-extractor': 7.20.0 '@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_e8f8f41828c0dd0ac8e32e1859a7f4f7 - '@typescript-eslint/parser': 5.16.0_eslint@8.12.0+typescript@4.5.4 + '@typescript-eslint/eslint-plugin': 5.17.0_d58f0eed9ebf32fdeceb6a8716e9bcf1 + '@typescript-eslint/parser': 5.17.0_eslint@8.12.0+typescript@4.5.4 conventional-changelog-cli: 2.2.2 cross-env: 7.0.3 esbuild: 0.14.27 @@ -68,8 +68,8 @@ importers: 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.62.0 @@ -771,7 +771,7 @@ importers: '@babel/plugin-transform-react-jsx-self': ^7.16.7 '@babel/plugin-transform-react-jsx-source': ^7.16.7 '@rollup/pluginutils': ^4.2.0 - react-refresh: ^0.11.0 + react-refresh: ^0.12.0 resolve: ^1.22.0 dependencies: '@babel/core': 7.17.8 @@ -780,7 +780,7 @@ importers: '@babel/plugin-transform-react-jsx-self': 7.16.7_@babel+core@7.17.8 '@babel/plugin-transform-react-jsx-source': 7.16.7_@babel+core@7.17.8 '@rollup/pluginutils': 4.2.0 - react-refresh: 0.11.0 + react-refresh: 0.12.0 resolve: 1.22.0 packages/plugin-vue: @@ -843,7 +843,7 @@ importers: '@types/node': ^16.11.26 '@types/resolve': ^1.20.1 '@types/sass': ~1.43.1 - '@types/stylus': ^0.48.36 + '@types/stylus': ^0.48.37 '@types/ws': ^8.5.3 '@vue/compiler-dom': ^3.2.31 acorn: ^8.7.0 @@ -857,7 +857,7 @@ importers: debug: ^4.3.4 dotenv: ^14.3.2 dotenv-expand: ^5.1.0 - es-module-lexer: ^0.10.4 + es-module-lexer: ^0.10.5 esbuild: ^0.14.27 estree-walker: ^2.0.2 etag: ^1.8.1 @@ -869,14 +869,14 @@ importers: magic-string: ^0.26.1 micromatch: ^4.0.5 mrmime: ^1.0.0 - node-forge: ^1.3.0 + node-forge: ^1.3.1 okie: ^1.0.1 open: ^8.4.0 periscopic: ^2.0.3 picocolors: ^1.0.0 postcss: ^8.4.12 postcss-import: ^14.1.0 - postcss-load-config: ^3.1.3 + postcss-load-config: ^3.1.4 postcss-modules: ^4.3.1 resolve: ^1.22.0 resolve.exports: ^1.1.0 @@ -887,7 +887,7 @@ importers: source-map-support: ^0.5.21 strip-ansi: ^6.0.1 terser: ^5.12.1 - tsconfck: ^1.2.1 + tsconfck: ^1.2.2 tslib: ^2.3.1 types: link:./types ws: ^8.5.0 @@ -921,7 +921,7 @@ importers: '@types/node': 16.11.26 '@types/resolve': 1.20.1 '@types/sass': 1.43.1 - '@types/stylus': 0.48.36 + '@types/stylus': 0.48.37 '@types/ws': 8.5.3 '@vue/compiler-dom': 3.2.31 acorn: 8.7.0 @@ -935,7 +935,7 @@ importers: debug: 4.3.4 dotenv: 14.3.2 dotenv-expand: 5.1.0 - es-module-lexer: 0.10.4 + es-module-lexer: 0.10.5 estree-walker: 2.0.2 etag: 1.8.1 fast-glob: 3.2.11 @@ -945,13 +945,13 @@ importers: magic-string: 0.26.1 micromatch: 4.0.5 mrmime: 1.0.0 - node-forge: 1.3.0 + node-forge: 1.3.1 okie: 1.0.1 open: 8.4.0 periscopic: 2.0.3 picocolors: 1.0.0 postcss-import: 14.1.0_postcss@8.4.12 - postcss-load-config: 3.1.3_postcss@8.4.12+ts-node@10.4.0 + postcss-load-config: 3.1.4_postcss@8.4.12+ts-node@10.4.0 postcss-modules: 4.3.1_postcss@8.4.12 resolve.exports: 1.1.0 rollup-plugin-license: 2.6.1_rollup@2.62.0 @@ -960,7 +960,7 @@ importers: source-map-support: 0.5.21 strip-ansi: 6.0.1 terser: 5.12.1 - tsconfck: 1.2.1_typescript@4.5.4 + tsconfck: 1.2.2_typescript@4.5.4 tslib: 2.3.1 types: link:types ws: 8.5.0 @@ -2223,19 +2223,19 @@ packages: - supports-color dev: false - /@microsoft/api-extractor-model/7.15.4: - resolution: {integrity: sha512-9bIXQKKQr5jAH1c9atXrukr4ua30fhqxMwWIOOjEnexPBPu3nhy9lC4/GpE0kPUp1Al3wSXgFnOEGzEH+HFz+w==} + /@microsoft/api-extractor-model/7.16.0: + resolution: {integrity: sha512-0FOrbNIny8mzBrzQnSIkEjAXk0JMSnPmWYxt3ZDTPVg9S8xIPzB6lfgTg9+Mimu0RKCpGKBpd+v2WcR5vGzyUQ==} dependencies: '@microsoft/tsdoc': 0.13.2 '@microsoft/tsdoc-config': 0.15.2 '@rushstack/node-core-library': 3.45.1 dev: true - /@microsoft/api-extractor/7.19.5: - resolution: {integrity: sha512-ra5r8P7PocOpemrZRccI3Tf1+wukI0gT6ncRB448QSxSYlmqKuvez95YUSYPwHIN/ztKL0cn5PfMOauU1lZfGQ==} + /@microsoft/api-extractor/7.20.0: + resolution: {integrity: sha512-WKAu5JpkRXWKL3AyxmFXuwNNPpBlsAefwZIDl8M5mhEqRji4w+gexb0pku3Waa0flm3vm0Cwpm+kGYYJ4/gzAA==} hasBin: true dependencies: - '@microsoft/api-extractor-model': 7.15.4 + '@microsoft/api-extractor-model': 7.16.0 '@microsoft/tsdoc': 0.13.2 '@microsoft/tsdoc-config': 0.15.2 '@rushstack/node-core-library': 3.45.1 @@ -2674,8 +2674,8 @@ packages: resolution: {integrity: sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw==} dev: true - /@types/stylus/0.48.36: - resolution: {integrity: sha512-7klEq45BUE8ZJWkYWy1E442DcCs0wi0FkFY1Tjr6EJ7edL77t9w/QmOwlkFumBMqHlatDBtrA2xgfRrGqkUkzg==} + /@types/stylus/0.48.37: + resolution: {integrity: sha512-IkLnS/GzdDK3rgAmQwLr8LqPvUMa43SHlCnXqsfXNukwaIpiXBNgSHil3ro8aemhF4k4ZiMoa4URE7mwBHPJnQ==} dependencies: '@types/node': 16.11.26 dev: true @@ -2704,8 +2704,8 @@ packages: dev: true optional: true - /@typescript-eslint/eslint-plugin/5.16.0_e8f8f41828c0dd0ac8e32e1859a7f4f7: - resolution: {integrity: sha512-SJoba1edXvQRMmNI505Uo4XmGbxCK9ARQpkvOd00anxzri9RNQk0DDCxD+LIl+jYhkzOJiOMMKYEHnHEODjdCw==} + /@typescript-eslint/eslint-plugin/5.17.0_d58f0eed9ebf32fdeceb6a8716e9bcf1: + resolution: {integrity: sha512-qVstvQilEd89HJk3qcbKt/zZrfBZ+9h2ynpAGlWjWiizA7m/MtLT9RoX6gjtpE500vfIg8jogAkDzdCxbsFASQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: '@typescript-eslint/parser': ^5.0.0 @@ -2715,10 +2715,10 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/parser': 5.16.0_eslint@8.12.0+typescript@4.5.4 - '@typescript-eslint/scope-manager': 5.16.0 - '@typescript-eslint/type-utils': 5.16.0_eslint@8.12.0+typescript@4.5.4 - '@typescript-eslint/utils': 5.16.0_eslint@8.12.0+typescript@4.5.4 + '@typescript-eslint/parser': 5.17.0_eslint@8.12.0+typescript@4.5.4 + '@typescript-eslint/scope-manager': 5.17.0 + '@typescript-eslint/type-utils': 5.17.0_eslint@8.12.0+typescript@4.5.4 + '@typescript-eslint/utils': 5.17.0_eslint@8.12.0+typescript@4.5.4 debug: 4.3.4 eslint: 8.12.0 functional-red-black-tree: 1.0.1 @@ -2731,8 +2731,8 @@ packages: - supports-color dev: true - /@typescript-eslint/parser/5.16.0_eslint@8.12.0+typescript@4.5.4: - resolution: {integrity: sha512-fkDq86F0zl8FicnJtdXakFs4lnuebH6ZADDw6CYQv0UZeIjHvmEw87m9/29nk2Dv5Lmdp0zQ3zDQhiMWQf/GbA==} + /@typescript-eslint/parser/5.17.0_eslint@8.12.0+typescript@4.5.4: + resolution: {integrity: sha512-aRzW9Jg5Rlj2t2/crzhA2f23SIYFlF9mchGudyP0uiD6SenIxzKoLjwzHbafgHn39dNV/TV7xwQkLfFTZlJ4ig==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 @@ -2741,9 +2741,9 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/scope-manager': 5.16.0 - '@typescript-eslint/types': 5.16.0 - '@typescript-eslint/typescript-estree': 5.16.0_typescript@4.5.4 + '@typescript-eslint/scope-manager': 5.17.0 + '@typescript-eslint/types': 5.17.0 + '@typescript-eslint/typescript-estree': 5.17.0_typescript@4.5.4 debug: 4.3.4 eslint: 8.12.0 typescript: 4.5.4 @@ -2751,16 +2751,16 @@ packages: - supports-color dev: true - /@typescript-eslint/scope-manager/5.16.0: - resolution: {integrity: sha512-P+Yab2Hovg8NekLIR/mOElCDPyGgFZKhGoZA901Yax6WR6HVeGLbsqJkZ+Cvk5nts/dAlFKm8PfL43UZnWdpIQ==} + /@typescript-eslint/scope-manager/5.17.0: + resolution: {integrity: sha512-062iCYQF/doQ9T2WWfJohQKKN1zmmXVfAcS3xaiialiw8ZUGy05Em6QVNYJGO34/sU1a7a+90U3dUNfqUDHr3w==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dependencies: - '@typescript-eslint/types': 5.16.0 - '@typescript-eslint/visitor-keys': 5.16.0 + '@typescript-eslint/types': 5.17.0 + '@typescript-eslint/visitor-keys': 5.17.0 dev: true - /@typescript-eslint/type-utils/5.16.0_eslint@8.12.0+typescript@4.5.4: - resolution: {integrity: sha512-SKygICv54CCRl1Vq5ewwQUJV/8padIWvPgCxlWPGO/OgQLCijY9G7lDu6H+mqfQtbzDNlVjzVWQmeqbLMBLEwQ==} + /@typescript-eslint/type-utils/5.17.0_eslint@8.12.0+typescript@4.5.4: + resolution: {integrity: sha512-3hU0RynUIlEuqMJA7dragb0/75gZmwNwFf/QJokWzPehTZousP/MNifVSgjxNcDCkM5HI2K22TjQWUmmHUINSg==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: eslint: '*' @@ -2769,7 +2769,7 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/utils': 5.16.0_eslint@8.12.0+typescript@4.5.4 + '@typescript-eslint/utils': 5.17.0_eslint@8.12.0+typescript@4.5.4 debug: 4.3.4 eslint: 8.12.0 tsutils: 3.21.0_typescript@4.5.4 @@ -2778,13 +2778,13 @@ packages: - supports-color dev: true - /@typescript-eslint/types/5.16.0: - resolution: {integrity: sha512-oUorOwLj/3/3p/HFwrp6m/J2VfbLC8gjW5X3awpQJ/bSG+YRGFS4dpsvtQ8T2VNveV+LflQHjlLvB6v0R87z4g==} + /@typescript-eslint/types/5.17.0: + resolution: {integrity: sha512-AgQ4rWzmCxOZLioFEjlzOI3Ch8giDWx8aUDxyNw9iOeCvD3GEYAB7dxWGQy4T/rPVe8iPmu73jPHuaSqcjKvxw==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true - /@typescript-eslint/typescript-estree/5.16.0_typescript@4.5.4: - resolution: {integrity: sha512-SE4VfbLWUZl9MR+ngLSARptUv2E8brY0luCdgmUevU6arZRY/KxYoLI/3V/yxaURR8tLRN7bmZtJdgmzLHI6pQ==} + /@typescript-eslint/typescript-estree/5.17.0_typescript@4.5.4: + resolution: {integrity: sha512-X1gtjEcmM7Je+qJRhq7ZAAaNXYhTgqMkR10euC4Si6PIjb+kwEQHSxGazXUQXFyqfEXdkGf6JijUu5R0uceQzg==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: typescript: '*' @@ -2792,8 +2792,8 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/types': 5.16.0 - '@typescript-eslint/visitor-keys': 5.16.0 + '@typescript-eslint/types': 5.17.0 + '@typescript-eslint/visitor-keys': 5.17.0 debug: 4.3.4 globby: 11.0.4 is-glob: 4.0.3 @@ -2804,16 +2804,16 @@ packages: - supports-color dev: true - /@typescript-eslint/utils/5.16.0_eslint@8.12.0+typescript@4.5.4: - resolution: {integrity: sha512-iYej2ER6AwmejLWMWzJIHy3nPJeGDuCqf8Jnb+jAQVoPpmWzwQOfa9hWVB8GIQE5gsCv/rfN4T+AYb/V06WseQ==} + /@typescript-eslint/utils/5.17.0_eslint@8.12.0+typescript@4.5.4: + resolution: {integrity: sha512-DVvndq1QoxQH+hFv+MUQHrrWZ7gQ5KcJzyjhzcqB1Y2Xes1UQQkTRPUfRpqhS8mhTWsSb2+iyvDW1Lef5DD7vA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 dependencies: '@types/json-schema': 7.0.9 - '@typescript-eslint/scope-manager': 5.16.0 - '@typescript-eslint/types': 5.16.0 - '@typescript-eslint/typescript-estree': 5.16.0_typescript@4.5.4 + '@typescript-eslint/scope-manager': 5.17.0 + '@typescript-eslint/types': 5.17.0 + '@typescript-eslint/typescript-estree': 5.17.0_typescript@4.5.4 eslint: 8.12.0 eslint-scope: 5.1.1 eslint-utils: 3.0.0_eslint@8.12.0 @@ -2822,11 +2822,11 @@ packages: - typescript dev: true - /@typescript-eslint/visitor-keys/5.16.0: - resolution: {integrity: sha512-jqxO8msp5vZDhikTwq9ubyMHqZ67UIvawohr4qF3KhlpL7gzSjOd+8471H3nh5LyABkaI85laEKKU8SnGUK5/g==} + /@typescript-eslint/visitor-keys/5.17.0: + resolution: {integrity: sha512-6K/zlc4OfCagUu7Am/BD5k8PSWQOgh34Nrv9Rxe2tBzlJ7uOeJ/h7ugCGDCeEZHT6k2CJBhbk9IsbkPI0uvUkA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dependencies: - '@typescript-eslint/types': 5.16.0 + '@typescript-eslint/types': 5.17.0 eslint-visitor-keys: 3.3.0 dev: true @@ -3267,7 +3267,7 @@ packages: /axios/0.24.0: resolution: {integrity: sha512-Q6cWsys88HoPgAaFAVUb0WpPk0O8iTeisR9IMqy9G8AbO4NlpVknrnQS03zzF9PGAWgO3cgletO3VjV/P7VztA==} dependencies: - follow-redirects: 1.14.6 + follow-redirects: 1.14.6_debug@4.3.4 transitivePeerDependencies: - debug dev: false @@ -4451,8 +4451,8 @@ packages: unbox-primitive: 1.0.1 dev: true - /es-module-lexer/0.10.4: - resolution: {integrity: sha512-n5bOGUnrmuCKyMkmHNtC1ObnUx8AgFcKWe2mbxb6jYzuK81W0Rk3Z//sCoGJuxWzos8R2w48TemGIFqZsTY6YA==} + /es-module-lexer/0.10.5: + resolution: {integrity: sha512-+7IwY/kiGAacQfY+YBhKMvEmyAJnw5grTUgjG85Pe7vcUI/6b7pZjZG8nQ7+48YhzEAEqrEgD2dCz/JIK+AYvw==} dev: true /es-to-primitive/1.2.1: @@ -5090,7 +5090,7 @@ packages: resolution: {integrity: sha512-8/sOawo8tJ4QOBX8YlQBMxL8+RLZfxMQOif9o0KUKTNTjMYElWPE0r/m5VNFxTRd0NSw8qSy8dajrwX4RYI1Hw==} dev: true - /follow-redirects/1.14.6: + /follow-redirects/1.14.6_debug@4.3.4: resolution: {integrity: sha512-fhUl5EwSJbbl8AR+uYL2KQDxLkdSjZGR36xy46AO7cOMTrCMON6Sa28FmAnC2tRTDbd/Uuzz3aJBv7EBN7JH8A==} engines: {node: '>=4.0'} peerDependencies: @@ -5098,6 +5098,8 @@ packages: peerDependenciesMeta: debug: optional: true + dependencies: + debug: 4.3.4 /form-data/3.0.1: resolution: {integrity: sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==} @@ -5498,7 +5500,7 @@ packages: engines: {node: '>=8.0.0'} dependencies: eventemitter3: 4.0.7 - follow-redirects: 1.14.6 + follow-redirects: 1.14.6_debug@4.3.4 requires-port: 1.0.0 transitivePeerDependencies: - debug @@ -6584,6 +6586,11 @@ packages: resolution: {integrity: sha512-bfTIN7lEsiooCocSISTWXkiWJkRqtL9wYtYy+8EK3Y41qh3mpwPU0ycTOgjdY9ErwXCc8QyrQp82bdL0Xkm9yA==} engines: {node: '>=10'} + /lilconfig/2.0.5: + resolution: {integrity: sha512-xaYmXZtTHPAw5m+xLN8ab9C+3a8YmV3asNSPOATITbtwrfbwaLJj8h66H1WMIpALCkqsIzK3h7oQ+PdX+LQ9Eg==} + engines: {node: '>=10'} + dev: true + /lines-and-columns/1.2.4: resolution: {integrity: sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==} @@ -7081,8 +7088,8 @@ packages: engines: {node: '>= 6.0.0'} dev: true - /node-forge/1.3.0: - resolution: {integrity: sha512-08ARB91bUi6zNKzVmaj3QO7cr397uiDT2nJ63cHjyNtCTWIgvS47j3eT0WfzUwS9+6Z5YshRaoasFkXCKrIYbA==} + /node-forge/1.3.1: + resolution: {integrity: sha512-dPEtOeMvF9VMcYV/1Wb8CPoVAXtp6MKMlcbAt4ddqmGqUJ6fQZFXkNZNkNlfevtNkGtaSoXf/vNNNSvgrdXwtA==} engines: {node: '>= 6.13.0'} dev: true @@ -7477,21 +7484,21 @@ packages: find-up: 4.1.0 dev: true - /playwright-chromium/1.20.1: - resolution: {integrity: sha512-zDJm59GEOWrHqpByblzaKI+bpswd3nrheCoAGOTBDX7MsQYwAV/ZBS2aCJzeGxDt/67brq/fQuZse3GwnCk+6A==} + /playwright-chromium/1.20.2: + resolution: {integrity: sha512-KsiPLRC1v56qLWqjzeEoDZNVW/eFrP5ad0PFQAa74u5EwnnId89LgOHEZFy487tt3xJdv3Ayyfdn8zwsUpS3Qg==} engines: {node: '>=12'} hasBin: true requiresBuild: true dependencies: - playwright-core: 1.20.1 + playwright-core: 1.20.2 transitivePeerDependencies: - bufferutil - supports-color - utf-8-validate dev: true - /playwright-core/1.20.1: - resolution: {integrity: sha512-A8ZsZ09gaSbxP0UijoLyzp3LJc0kWMxDooLPi+mm4/5iYnTbd6PF5nKjoFw1a7KwjZIEgdhJduah4BcUIh+IPA==} + /playwright-core/1.20.2: + resolution: {integrity: sha512-iV6+HftSPalynkq0CYJala1vaTOq7+gU9BRfKCdM9bAxNq/lFLrwbluug2Wt5OoUwbMABcnTThIEm3/qUhCdJQ==} engines: {node: '>=12'} hasBin: true dependencies: @@ -7589,6 +7596,25 @@ packages: postcss: 8.4.12 ts-node: 10.4.0_44ef5af6cbbc24239b4e70b5c7b0d7a6 yaml: 1.10.2 + dev: false + + /postcss-load-config/3.1.4_postcss@8.4.12+ts-node@10.4.0: + resolution: {integrity: sha512-6DiM4E7v4coTE4uzA8U//WhtPwyhiim3eyjEMFCnUpzbrkK9wJHgKDT2mR+HbtSrd/NubVaYTOpSpjUl8NQeRg==} + engines: {node: '>= 10'} + peerDependencies: + postcss: '>=8.0.9' + ts-node: '>=9.0.0' + peerDependenciesMeta: + postcss: + optional: true + ts-node: + optional: true + dependencies: + lilconfig: 2.0.5 + postcss: 8.4.12 + ts-node: 10.4.0_44ef5af6cbbc24239b4e70b5c7b0d7a6 + yaml: 1.10.2 + dev: true /postcss-modules-extract-imports/3.0.0_postcss@8.4.12: resolution: {integrity: sha512-bdHleFnP3kZ4NYDhuGlVK+CMrQ/pqUm8bx/oGL93K6gVwiclvX5x0n76fYMKuIGKzlABOy13zsvqjb0f92TEXw==} @@ -7717,8 +7743,8 @@ packages: engines: {node: '>= 0.8.0'} dev: true - /prettier/2.6.1: - resolution: {integrity: sha512-8UVbTBYGwN37Bs9LERmxCPjdvPxlEowx2urIL6urHzdb3SDq4B/Z6xLFCblrSnE4iKWcS6ziJ3aOYrc1kz/E2A==} + /prettier/2.6.2: + resolution: {integrity: sha512-PkUpF+qoXTqhOeWL9fu7As8LXsIUZ1WYaJiY/a7McAQzxjk82OF0tibkFXVCDImZtWxbvojFjerkiLb0/q8mew==} engines: {node: '>=10.13.0'} hasBin: true dev: true @@ -7991,8 +8017,8 @@ packages: resolution: {integrity: sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==} dev: true - /react-refresh/0.11.0: - resolution: {integrity: sha512-F27qZr8uUqwhWZboondsPx8tnC3Ct3SxZA3V5WyEvujRyyNv0VYPhoBg1gZ8/MV5tubQp76Trw8lTv9hzRBa+A==} + /react-refresh/0.12.0: + resolution: {integrity: sha512-suLIhrU2IHKL5JEKR/fAwJv7bbeq4kJ+pJopf77jHwuR+HmJS/HbrPIGsTBUVfw7tXPOmYv7UJ7PCaN49e8x4A==} engines: {node: '>=0.10.0'} dev: false @@ -9172,8 +9198,8 @@ packages: yn: 3.1.1 dev: true - /tsconfck/1.2.1_typescript@4.5.4: - resolution: {integrity: sha512-x28dvgpazY0+Gdpheb+D47NiaepLoueunDXlNQ6gVruu9HJbUj3M07ORgjmOQBUpPbXUAQXyfACc8Mi/jlLDVw==} + /tsconfck/1.2.2_typescript@4.5.4: + resolution: {integrity: sha512-x5YpjOqjJnMs1EsJvQBQbrysrY32eGoZRRr5YvbN1hwlrXKc7jiphCOUrT7xbFdOWk8sh+EtMYbGPbTO8rDmcw==} engines: {node: ^12.20 || ^14.13.1 || >= 16} hasBin: true peerDependencies: From ace6e93239c85667eaea656cfda770e3269b336f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Tue, 5 Apr 2022 03:33:48 +0900 Subject: [PATCH 012/175] test: fix server port conflict (#7523) --- .../playground/cli-module/__tests__/serve.js | 4 ++-- packages/playground/cli/__tests__/serve.js | 4 ++-- .../postcss-plugins-different-dir.spec.ts | 4 ++-- .../playground/css/postcss-caching/css.spec.ts | 4 ++-- .../playground/legacy/__tests__/ssr/serve.js | 3 ++- packages/playground/lib/__tests__/serve.js | 3 ++- .../optimize-missing-deps/__test__/serve.js | 3 ++- packages/playground/ssr-deps/__tests__/serve.js | 3 ++- packages/playground/ssr-html/__tests__/serve.js | 3 ++- packages/playground/ssr-pug/__tests__/serve.js | 3 ++- .../playground/ssr-react/__tests__/serve.js | 3 ++- packages/playground/ssr-vue/__tests__/serve.js | 3 ++- .../playground/ssr-webworker/__tests__/serve.js | 3 ++- packages/playground/testUtils.ts | 17 +++++++++++++++++ 14 files changed, 43 insertions(+), 17 deletions(-) diff --git a/packages/playground/cli-module/__tests__/serve.js b/packages/playground/cli-module/__tests__/serve.js index 2b354f566524bf..cf873fd481830b 100644 --- a/packages/playground/cli-module/__tests__/serve.js +++ b/packages/playground/cli-module/__tests__/serve.js @@ -5,10 +5,10 @@ const path = require('path') // eslint-disable-next-line node/no-restricted-require const execa = require('execa') -const { workspaceRoot } = require('../../testUtils') +const { workspaceRoot, ports } = require('../../testUtils') const isWindows = process.platform === 'win32' -const port = (exports.port = 9511) // make sure this port is unique across tests with custom servers +const port = (exports.port = ports['cli-module']) const viteBin = path.join(workspaceRoot, 'packages', 'vite', 'bin', 'vite.js') /** diff --git a/packages/playground/cli/__tests__/serve.js b/packages/playground/cli/__tests__/serve.js index 5dd058f4e1a83c..3ad375d9d1f543 100644 --- a/packages/playground/cli/__tests__/serve.js +++ b/packages/playground/cli/__tests__/serve.js @@ -5,10 +5,10 @@ const path = require('path') // eslint-disable-next-line node/no-restricted-require const execa = require('execa') -const { workspaceRoot } = require('../../testUtils') +const { workspaceRoot, ports } = require('../../testUtils') const isWindows = process.platform === 'win32' -const port = (exports.port = 9510) // make sure this port is unique across tests with custom servers +const port = (exports.port = ports.cli) const viteBin = path.join(workspaceRoot, 'packages', 'vite', 'bin', 'vite.js') /** diff --git a/packages/playground/css/__tests__/postcss-plugins-different-dir.spec.ts b/packages/playground/css/__tests__/postcss-plugins-different-dir.spec.ts index 19e9a43ae4ff6e..8bedc26ee354c8 100644 --- a/packages/playground/css/__tests__/postcss-plugins-different-dir.spec.ts +++ b/packages/playground/css/__tests__/postcss-plugins-different-dir.spec.ts @@ -1,10 +1,10 @@ -import { getColor, getBgColor } from '../../testUtils' +import { getColor, getBgColor, ports } from '../../testUtils' import { createServer } from 'vite' import path from 'path' // Regression test for https://github.com/vitejs/vite/issues/4000 test('postcss plugins in different dir', async () => { - const port = 5006 + const port = ports['css/postcss-plugins-different-dir'] const server = await createServer({ root: path.join(__dirname, '..', '..', 'tailwind'), logLevel: 'silent', 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/legacy/__tests__/ssr/serve.js b/packages/playground/legacy/__tests__/ssr/serve.js index df43f180afb188..c7ef2ed3520e53 100644 --- a/packages/playground/legacy/__tests__/ssr/serve.js +++ b/packages/playground/legacy/__tests__/ssr/serve.js @@ -2,8 +2,9 @@ // this is automtically detected by scripts/jestPerTestSetup.ts and will replace // the default e2e test serve behavior const path = require('path') +const { ports } = require('../../../testUtils') -const port = (exports.port = 9527) +const port = (exports.port = ports['legacy/ssr']) /** * @param {string} root diff --git a/packages/playground/lib/__tests__/serve.js b/packages/playground/lib/__tests__/serve.js index 15c64de40276d1..eac6980286af52 100644 --- a/packages/playground/lib/__tests__/serve.js +++ b/packages/playground/lib/__tests__/serve.js @@ -5,8 +5,9 @@ const path = require('path') const http = require('http') const sirv = require('sirv') +const { ports } = require('../../testUtils') -const port = (exports.port = 9527) +const port = (exports.port = ports.lib) /** * @param {string} root diff --git a/packages/playground/optimize-missing-deps/__test__/serve.js b/packages/playground/optimize-missing-deps/__test__/serve.js index 9f293024f83913..89a6ce3593cd0e 100644 --- a/packages/playground/optimize-missing-deps/__test__/serve.js +++ b/packages/playground/optimize-missing-deps/__test__/serve.js @@ -3,8 +3,9 @@ // the default e2e test serve behavior const path = require('path') +const { ports } = require('../../testUtils') -const port = (exports.port = 9529) +const port = (exports.port = ports['optimize-missing-deps']) /** * @param {string} root diff --git a/packages/playground/ssr-deps/__tests__/serve.js b/packages/playground/ssr-deps/__tests__/serve.js index 5ba5724f2b7a94..6c2584601c9331 100644 --- a/packages/playground/ssr-deps/__tests__/serve.js +++ b/packages/playground/ssr-deps/__tests__/serve.js @@ -3,8 +3,9 @@ // the default e2e test serve behavior const path = require('path') +const { ports } = require('../../testUtils') -const port = (exports.port = 9530) +const port = (exports.port = ports['ssr-deps']) /** * @param {string} root diff --git a/packages/playground/ssr-html/__tests__/serve.js b/packages/playground/ssr-html/__tests__/serve.js index 5ba5724f2b7a94..d119397700cf75 100644 --- a/packages/playground/ssr-html/__tests__/serve.js +++ b/packages/playground/ssr-html/__tests__/serve.js @@ -3,8 +3,9 @@ // the default e2e test serve behavior const path = require('path') +const { ports } = require('../../testUtils') -const port = (exports.port = 9530) +const port = (exports.port = ports['ssr-html']) /** * @param {string} root diff --git a/packages/playground/ssr-pug/__tests__/serve.js b/packages/playground/ssr-pug/__tests__/serve.js index 5ba5724f2b7a94..392aa831ebb82d 100644 --- a/packages/playground/ssr-pug/__tests__/serve.js +++ b/packages/playground/ssr-pug/__tests__/serve.js @@ -3,8 +3,9 @@ // the default e2e test serve behavior const path = require('path') +const { ports } = require('../../testUtils') -const port = (exports.port = 9530) +const port = (exports.port = ports['ssr-pug']) /** * @param {string} root diff --git a/packages/playground/ssr-react/__tests__/serve.js b/packages/playground/ssr-react/__tests__/serve.js index 1bc028c03dc27c..07476e0726e268 100644 --- a/packages/playground/ssr-react/__tests__/serve.js +++ b/packages/playground/ssr-react/__tests__/serve.js @@ -3,8 +3,9 @@ // the default e2e test serve behavior const path = require('path') +const { ports } = require('../../testUtils') -const port = (exports.port = 9528) +const port = (exports.port = ports['ssr-react']) /** * @param {string} root diff --git a/packages/playground/ssr-vue/__tests__/serve.js b/packages/playground/ssr-vue/__tests__/serve.js index 1e220fed9630e4..5bcd5a4639877a 100644 --- a/packages/playground/ssr-vue/__tests__/serve.js +++ b/packages/playground/ssr-vue/__tests__/serve.js @@ -3,8 +3,9 @@ // the default e2e test serve behavior const path = require('path') +const { ports } = require('../../testUtils') -const port = (exports.port = 9527) +const port = (exports.port = ports['ssr-vue']) /** * @param {string} root diff --git a/packages/playground/ssr-webworker/__tests__/serve.js b/packages/playground/ssr-webworker/__tests__/serve.js index f4f207b85026c6..38a957b0a333ea 100644 --- a/packages/playground/ssr-webworker/__tests__/serve.js +++ b/packages/playground/ssr-webworker/__tests__/serve.js @@ -3,8 +3,9 @@ // the default e2e test serve behavior const path = require('path') +const { ports } = require('../../testUtils') -const port = (exports.port = 9528) +const port = (exports.port = ports['ssr-webworker']) /** * @param {string} root diff --git a/packages/playground/testUtils.ts b/packages/playground/testUtils.ts index 7454c88452e9b2..427fea6d947a4f 100644 --- a/packages/playground/testUtils.ts +++ b/packages/playground/testUtils.ts @@ -10,6 +10,23 @@ import type { Manifest } from 'vite' import { normalizePath } from 'vite' import { fromComment } from 'convert-source-map' +// make sure these ports are unique +export const ports = { + cli: 9510, + 'cli-module': 9511, + 'legacy/ssr': 9520, + lib: 9521, + 'optimize-missing-deps': 9522, + 'ssr-deps': 9600, + 'ssr-html': 9601, + 'ssr-pug': 9602, + 'ssr-react': 9603, + 'ssr-vue': 9604, + 'ssr-webworker': 9605, + 'css/postcss-caching': 5005, + 'css/postcss-plugins-different-dir': 5006 +} + export function slash(p: string): string { return p.replace(/\\/g, '/') } From 08e39b792a2591c1c2d636e88e206bd1fa7e0c21 Mon Sep 17 00:00:00 2001 From: bbotto-pdga <76966373+bbotto-pdga@users.noreply.github.com> Date: Mon, 4 Apr 2022 20:59:21 -0700 Subject: [PATCH 013/175] fix(less): handles rewriting relative paths passed Less's `data-uri` function. (#7400) --- packages/playground/css/__tests__/css.spec.ts | 8 ++++++ packages/playground/css/index.html | 4 +++ packages/playground/css/less.less | 3 +++ .../playground/css/less/components/form.less | 4 +++ .../less/images/backgrounds/form-select.svg | 4 +++ packages/vite/src/node/plugins/css.ts | 25 ++++++++++++++++--- 6 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 packages/playground/css/less/components/form.less create mode 100644 packages/playground/css/less/images/backgrounds/form-select.svg diff --git a/packages/playground/css/__tests__/css.spec.ts b/packages/playground/css/__tests__/css.spec.ts index a476826e2023cc..d3577176b4bb16 100644 --- a/packages/playground/css/__tests__/css.spec.ts +++ b/packages/playground/css/__tests__/css.spec.ts @@ -388,3 +388,11 @@ test('import css in less', async () => { expect(await getColor('.css-in-less')).toBe('yellow') expect(await getColor('.css-in-less-2')).toBe('blue') }) + +test("relative path rewritten in Less's data-uri", async () => { + // relative path passed to Less's data-uri is rewritten to absolute, + // the Less inlines it + expect(await getBg('.form-box-data-uri')).toMatch( + /^url\("data:image\/svg\+xml,%3Csvg/ + ) +}) diff --git a/packages/playground/css/index.html b/packages/playground/css/index.html index 52d6bffef134e6..dd496a8ffdce11 100644 --- a/packages/playground/css/index.html +++ b/packages/playground/css/index.html @@ -49,6 +49,10 @@

CSS

Imported Less string:


 
+  
+ tests Less's `data-uri()` function with relative image paths +
+

Stylus: This should be blue

Stylus additionalData: This should be orange 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/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index e2ce47851b7818..dbe9e7d1dfa00f 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -965,6 +965,8 @@ type CssUrlReplacer = ( // https://drafts.csswg.org/css-syntax-3/#identifier-code-point export const cssUrlRE = /(?<=^|[^\w\-\u0080-\uffff])url\(\s*('[^']+'|"[^"]+"|[^'")]+)\s*\)/ +export const cssDataUriRE = + /(?<=^|[^\w\-\u0080-\uffff])data-uri\(\s*('[^']+'|"[^"]+"|[^'")]+)\s*\)/ export const importCssRE = /@import ('[^']+\.css'|"[^"]+\.css"|[^'")]+\.css)/ const cssImageSetRE = /image-set\(([^)]+)\)/ @@ -1015,6 +1017,16 @@ function rewriteCssUrls( }) } +function rewriteCssDataUris( + css: string, + replacer: CssUrlReplacer +): Promise { + return asyncReplace(css, cssDataUriRE, async (match) => { + const [matched, rawUrl] = match + return await doUrlReplace(rawUrl, matched, replacer, 'data-uri') + }) +} + function rewriteImportCss( css: string, replacer: CssUrlReplacer @@ -1040,7 +1052,8 @@ function rewriteCssImageSet( async function doUrlReplace( rawUrl: string, matched: string, - replacer: CssUrlReplacer + replacer: CssUrlReplacer, + funcName: string = 'url' ) { let wrap = '' const first = rawUrl[0] @@ -1057,7 +1070,7 @@ async function doUrlReplace( // The new url might need wrapping even if the original did not have it, e.g. if a space was added during replacement wrap = "'" } - return `url(${wrap}${newUrl}${wrap})` + return `${funcName}(${wrap}${newUrl}${wrap})` } async function doImportCSSReplace( @@ -1307,10 +1320,12 @@ async function rebaseUrls( const content = fs.readFileSync(file, 'utf-8') // no url() const hasUrls = cssUrlRE.test(content) + // data-uri() calls + const hasDataUris = cssDataUriRE.test(content) // no @import xxx.css const hasImportCss = importCssRE.test(content) - if (!hasUrls && !hasImportCss) { + if (!hasUrls && !hasDataUris && !hasImportCss) { return { file } } @@ -1339,6 +1354,10 @@ async function rebaseUrls( rebased = await rewriteCssUrls(rebased || content, rebaseFn) } + if (hasDataUris) { + rebased = await rewriteCssDataUris(rebased || content, rebaseFn) + } + return { file, contents: rebased From 1dd019fa66207337734b8ce6141ae60f692def86 Mon Sep 17 00:00:00 2001 From: bbbboom Date: Tue, 5 Apr 2022 12:01:44 +0800 Subject: [PATCH 014/175] fix: EACCES permission denied due to resolve new paths default (#7612) --- packages/vite/src/node/utils.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/vite/src/node/utils.ts b/packages/vite/src/node/utils.ts index 0e3fe49c9cb584..8c7859e3850454 100644 --- a/packages/vite/src/node/utils.ts +++ b/packages/vite/src/node/utils.ts @@ -83,6 +83,7 @@ export function resolveFrom( ): string { return resolve.sync(id, { basedir, + paths: [], extensions: ssr ? ssrExtensions : DEFAULT_EXTENSIONS, // necessary to work with pnpm preserveSymlinks: preserveSymlinks || isRunningWithYarnPnp || false From a89ea5202e9492c2b60598b6b8095ecf31dafbd8 Mon Sep 17 00:00:00 2001 From: dengqing Date: Wed, 6 Apr 2022 13:13:38 +0800 Subject: [PATCH 015/175] docs: update plugin example (#7624) --- docs/guide/api-plugin.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/guide/api-plugin.md b/docs/guide/api-plugin.md index 4a5b1c07c7893e..8f208006fcab30 100644 --- a/docs/guide/api-plugin.md +++ b/docs/guide/api-plugin.md @@ -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' + } } }) }) From 4433df4c6b278d5a2f4d2ca14f0a7930ed647e80 Mon Sep 17 00:00:00 2001 From: agoni1212 <22545824+agoni1212@users.noreply.github.com> Date: Wed, 6 Apr 2022 21:24:09 +0800 Subject: [PATCH 016/175] chore: update vue template setup api doc url (#7628) --- packages/create-vite/template-vue-ts/src/App.vue | 2 +- packages/create-vite/template-vue/src/App.vue | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/create-vite/template-vue-ts/src/App.vue b/packages/create-vite/template-vue-ts/src/App.vue index df4e2d7644e293..1503baf999e683 100644 --- a/packages/create-vite/template-vue-ts/src/App.vue +++ b/packages/create-vite/template-vue-ts/src/App.vue @@ -1,6 +1,6 @@ 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 @@ From c02537b5b2ac5e39313601cc22530ef6201239b9 Mon Sep 17 00:00:00 2001 From: dengqing Date: Thu, 7 Apr 2022 16:25:36 +0800 Subject: [PATCH 017/175] docs: improve virtual module examples (#7636) --- docs/guide/api-plugin.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/guide/api-plugin.md b/docs/guide/api-plugin.md index 8f208006fcab30..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) ``` From 09c4fc01a83b84f77b7292abcfe7500f0e948db6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20=C2=B7=20=E8=A5=BF=E8=90=8C?= Date: Fri, 8 Apr 2022 18:01:40 +0800 Subject: [PATCH 018/175] docs: warning for `new URL(url, import.meta.url)` (#7279) --- docs/guide/assets.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/guide/assets.md b/docs/guide/assets.md index 53ac153f9465bd..9776dcdd032f35 100644 --- a/docs/guide/assets.md +++ b/docs/guide/assets.md @@ -113,3 +113,7 @@ 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. +::: From eb57627a368a5ae0532b5836c176647525d5394f Mon Sep 17 00:00:00 2001 From: Lijianan <574980606@qq.com> Date: Sun, 10 Apr 2022 22:10:21 +0800 Subject: [PATCH 019/175] chore: update @types/react version (#7655) --- packages/create-vite/template-react-ts/package.json | 4 ++-- packages/create-vite/template-react/package.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/create-vite/template-react-ts/package.json b/packages/create-vite/template-react-ts/package.json index c08d472dca7477..69274929dd903d 100644 --- a/packages/create-vite/template-react-ts/package.json +++ b/packages/create-vite/template-react-ts/package.json @@ -12,8 +12,8 @@ "react-dom": "^18.0.0" }, "devDependencies": { - "@types/react": "^17.0.43", - "@types/react-dom": "^17.0.14", + "@types/react": "^18.0.0", + "@types/react-dom": "^18.0.0", "@vitejs/plugin-react": "^1.3.0", "typescript": "^4.6.3", "vite": "^2.9.1" diff --git a/packages/create-vite/template-react/package.json b/packages/create-vite/template-react/package.json index ac105bd8796ace..4f443aefcb3cdb 100644 --- a/packages/create-vite/template-react/package.json +++ b/packages/create-vite/template-react/package.json @@ -12,8 +12,8 @@ "react-dom": "^18.0.0" }, "devDependencies": { - "@types/react": "^17.0.43", - "@types/react-dom": "^17.0.14", + "@types/react": "^18.0.0", + "@types/react-dom": "^18.0.0", "@vitejs/plugin-react": "^1.3.0", "vite": "^2.9.1" } From 93900f06c06ea484a07c824eab32eb2cefb39751 Mon Sep 17 00:00:00 2001 From: yoho Date: Mon, 11 Apr 2022 17:44:19 +0800 Subject: [PATCH 020/175] fix: nested comments and strings, new regexp utils (#7650) --- CONTRIBUTING.md | 2 +- .../src/node/__tests__/cleanString.spec.ts | 108 ++++++++++++++++++ packages/vite/src/node/cleanString.ts | 14 +++ .../src/node/plugins/assetImportMetaUrl.ts | 23 ++-- .../src/node/plugins/workerImportMetaUrl.ts | 53 ++++----- packages/vite/src/node/utils.ts | 1 - 6 files changed, 151 insertions(+), 50 deletions(-) create mode 100644 packages/vite/src/node/__tests__/cleanString.spec.ts create mode 100644 packages/vite/src/node/cleanString.ts diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b105499159bebb..f086627de5cfe0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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. diff --git a/packages/vite/src/node/__tests__/cleanString.spec.ts b/packages/vite/src/node/__tests__/cleanString.spec.ts new file mode 100644 index 00000000000000..883dc67abfe2f9 --- /dev/null +++ b/packages/vite/src/node/__tests__/cleanString.spec.ts @@ -0,0 +1,108 @@ +import { emptyString } from '../../node/cleanString' + +test('comments', () => { + expect( + emptyString(` + // comment1 // comment + // comment1 + /* coment2 */ + /* + // coment3 + */ + /* // coment3 */ + /* // coment3 */ // comment + // comment 4 /* comment 5 */ + `).trim() + ).toBe('') +}) + +test('strings', () => { + const clean = emptyString(` + // comment1 + const a = 'aaaa' + /* coment2 */ + const b = "bbbb" + /* + // coment3 + */ + /* // coment3 */ + // comment 4 /* comment 5 */ + `) + expect(clean).toMatch("const a = '\0\0\0\0'") + expect(clean).toMatch('const b = "\0\0\0\0"') +}) + +test('strings comment nested', () => { + expect( + emptyString(` + // comment 1 /* " */ + const a = "a //" + // comment 2 /* " */ + `) + ).toMatch('const a = "\0\0\0\0"') + + expect( + emptyString(` + // comment 1 /* ' */ + const a = "a //" + // comment 2 /* ' */ + `) + ).toMatch('const a = "\0\0\0\0"') + + expect( + emptyString(` + // comment 1 /* \` */ + const a = "a //" + // comment 2 /* \` */ + `) + ).toMatch('const a = "\0\0\0\0"') + + expect( + emptyString(` + const a = "a //" + console.log("console") + `) + ).toMatch('const a = "\0\0\0\0"') + + expect( + emptyString(` + const a = "a /*" + console.log("console") + const b = "b */" + `) + ).toMatch('const a = "\0\0\0\0"') + + expect( + emptyString(` + const a = "a ' " + console.log("console") + const b = "b ' " + `) + ).toMatch('const a = "\0\0\0\0"') + + expect( + emptyString(` + const a = "a \` " + console.log("console") + const b = "b \` " + `) + ).toMatch('const a = "\0\0\0\0"') +}) + +test('find empty string flag in raw index', () => { + const str = ` + const a = "aaaaa" + const b = "bbbbb" + ` + const clean = emptyString(str) + expect(clean).toMatch('const a = "\0\0\0\0\0"') + expect(clean).toMatch('const b = "\0\0\0\0\0"') + + const aIndex = str.indexOf('const a = "aaaaa"') + const aStart = clean.indexOf('\0\0\0\0\0', aIndex) + expect(str.slice(aStart, aStart + 5)).toMatch('aaaaa') + + const bIndex = str.indexOf('const b = "bbbbb"') + const bStart = clean.indexOf('\0\0\0\0\0', bIndex) + expect(str.slice(bStart, bStart + 5)).toMatch('bbbbb') +}) diff --git a/packages/vite/src/node/cleanString.ts b/packages/vite/src/node/cleanString.ts new file mode 100644 index 00000000000000..d26274397124ff --- /dev/null +++ b/packages/vite/src/node/cleanString.ts @@ -0,0 +1,14 @@ +// bank on the non-overlapping nature of regex matches and combine all filters into one giant regex +// /`([^`\$\{\}]|\$\{(`|\g<1>)*\})*`/g can match nested string template +// but js not support match expression(\g<0>). so clean string template(`...`) in other ways. +const cleanerRE = /"[^"]*"|'[^']*'|\/\*(.|[\r\n])*?\*\/|\/\/.*/g + +const blankReplacer = (s: string) => ' '.repeat(s.length) +const stringBlankReplacer = (s: string) => + `${s[0]}${'\0'.repeat(s.length - 2)}${s[0]}` + +export function emptyString(raw: string): string { + return raw.replace(cleanerRE, (s: string) => + s[0] === '/' ? blankReplacer(s) : stringBlankReplacer(s) + ) +} diff --git a/packages/vite/src/node/plugins/assetImportMetaUrl.ts b/packages/vite/src/node/plugins/assetImportMetaUrl.ts index a3f8e441b0f933..b8c16f76d2b93f 100644 --- a/packages/vite/src/node/plugins/assetImportMetaUrl.ts +++ b/packages/vite/src/node/plugins/assetImportMetaUrl.ts @@ -3,12 +3,7 @@ import MagicString from 'magic-string' import path from 'path' import { fileToUrl } from './asset' import type { ResolvedConfig } from '../config' -import { - multilineCommentsRE, - singlelineCommentsRE, - stringsRE, - blankReplacer -} from '../utils' +import { emptyString } from '../cleanString' /** * Convert `new URL('./foo.png', import.meta.url)` to its resolved built URL @@ -29,19 +24,16 @@ export function assetImportMetaUrlPlugin(config: ResolvedConfig): Plugin { code.includes('new URL') && code.includes(`import.meta.url`) ) { - const importMetaUrlRE = + let s: MagicString | undefined + const assetImportMetaUrlRE = /\bnew\s+URL\s*\(\s*('[^']+'|"[^"]+"|`[^`]+`)\s*,\s*import\.meta\.url\s*,?\s*\)/g - const noCommentsCode = code - .replace(multilineCommentsRE, blankReplacer) - .replace(singlelineCommentsRE, blankReplacer) - .replace(stringsRE, (m) => `'${'\0'.repeat(m.length - 2)}'`) + const cleanString = emptyString(code) - let s: MagicString | null = null let match: RegExpExecArray | null - while ((match = importMetaUrlRE.exec(noCommentsCode))) { + while ((match = assetImportMetaUrlRE.exec(cleanString))) { const { 0: exp, 1: emptyUrl, index } = match - const urlStart = exp.indexOf(emptyUrl) + index + const urlStart = cleanString.indexOf(emptyUrl, index) const urlEnd = urlStart + emptyUrl.length const rawUrl = code.slice(urlStart, urlEnd) @@ -74,8 +66,9 @@ export function assetImportMetaUrlPlugin(config: ResolvedConfig): Plugin { // Get final asset URL. Catch error if the file does not exist, // in which we can resort to the initial URL and let it resolve in runtime const builtUrl = await fileToUrl(file, config, this).catch(() => { + const rawExp = code.slice(index, index + exp.length) config.logger.warnOnce( - `\n${exp} doesn't exist at build time, it will remain unchanged to be resolved at runtime` + `\n${rawExp} doesn't exist at build time, it will remain unchanged to be resolved at runtime` ) return url }) diff --git a/packages/vite/src/node/plugins/workerImportMetaUrl.ts b/packages/vite/src/node/plugins/workerImportMetaUrl.ts index c9a2903d9a4142..c8ab20fe21694c 100644 --- a/packages/vite/src/node/plugins/workerImportMetaUrl.ts +++ b/packages/vite/src/node/plugins/workerImportMetaUrl.ts @@ -2,14 +2,7 @@ import JSON5 from 'json5' import type { ResolvedConfig } from '../config' import type { Plugin } from '../plugin' import { fileToUrl } from './asset' -import { - blankReplacer, - cleanUrl, - injectQuery, - multilineCommentsRE, - singlelineCommentsRE, - stringsRE -} from '../utils' +import { cleanUrl, injectQuery } from '../utils' import path from 'path' import { workerFileToUrl } from './worker' import { parseRequest } from '../utils' @@ -17,27 +10,25 @@ import { ENV_ENTRY, ENV_PUBLIC_PATH } from '../constants' import MagicString from 'magic-string' import type { ViteDevServer } from '..' import type { RollupError } from 'rollup' +import { emptyString } from '../cleanString' type WorkerType = 'classic' | 'module' | 'ignore' +const ignoreFlagRE = /\/\*\s*@vite-ignore\s*\*\// const WORKER_FILE_ID = 'worker_url_file' -function getWorkerType( - code: string, - noCommentsCode: string, - i: number -): WorkerType { +function getWorkerType(raw: string, clean: string, i: number): WorkerType { function err(e: string, pos: number) { const error = new Error(e) as RollupError error.pos = pos throw error } - const commaIndex = noCommentsCode.indexOf(',', i) + const commaIndex = clean.indexOf(',', i) if (commaIndex === -1) { return 'classic' } - const endIndex = noCommentsCode.indexOf(')', i) + const endIndex = clean.indexOf(')', i) // case: ') ... ,' mean no worker options params if (commaIndex > endIndex) { @@ -45,22 +36,22 @@ function getWorkerType( } // need to find in comment code - let workerOptsString = code.substring(commaIndex + 1, endIndex) + const workerOptString = raw.substring(commaIndex + 1, endIndex) - const hasViteIgnore = /\/\*\s*@vite-ignore\s*\*\//.test(workerOptsString) + const hasViteIgnore = ignoreFlagRE.test(workerOptString) if (hasViteIgnore) { return 'ignore' } // need to find in no comment code - workerOptsString = noCommentsCode.substring(commaIndex + 1, endIndex) - if (!workerOptsString.trim().length) { + const cleanWorkerOptString = clean.substring(commaIndex + 1, endIndex) + if (!cleanWorkerOptString.trim().length) { return 'classic' } let workerOpts: { type: WorkerType } = { type: 'classic' } try { - workerOpts = JSON5.parse(workerOptsString) + workerOpts = JSON5.parse(workerOptString) } catch (e) { // can't parse by JSON5, so the worker options had unexpect char. err( @@ -113,28 +104,22 @@ export function workerImportMetaUrlPlugin(config: ResolvedConfig): Plugin { code: injectEnv + code } } + let s: MagicString | undefined if ( (code.includes('new Worker') || code.includes('new ShareWorker')) && code.includes('new URL') && code.includes(`import.meta.url`) ) { - const importMetaUrlRE = + const cleanString = emptyString(code) + const workerImportMetaUrlRE = /\bnew\s+(Worker|SharedWorker)\s*\(\s*(new\s+URL\s*\(\s*('[^']+'|"[^"]+"|`[^`]+`)\s*,\s*import\.meta\.url\s*\))/g - const noCommentsCode = code - .replace(multilineCommentsRE, blankReplacer) - .replace(singlelineCommentsRE, blankReplacer) - - const noStringCode = noCommentsCode.replace( - stringsRE, - (m) => `'${' '.repeat(m.length - 2)}'` - ) + let match: RegExpExecArray | null - let s: MagicString | null = null - while ((match = importMetaUrlRE.exec(noStringCode))) { + while ((match = workerImportMetaUrlRE.exec(cleanString))) { const { 0: allExp, 2: exp, 3: emptyUrl, index } = match const urlIndex = allExp.indexOf(exp) + index - const urlStart = allExp.indexOf(emptyUrl) + index + const urlStart = cleanString.indexOf(emptyUrl, index) const urlEnd = urlStart + emptyUrl.length const rawUrl = code.slice(urlStart, urlEnd) @@ -156,7 +141,7 @@ export function workerImportMetaUrlPlugin(config: ResolvedConfig): Plugin { s ||= new MagicString(code) const workerType = getWorkerType( code, - noCommentsCode, + cleanString, index + allExp.length ) const file = path.resolve(path.dirname(id), rawUrl.slice(1, -1)) @@ -172,12 +157,14 @@ export function workerImportMetaUrlPlugin(config: ResolvedConfig): Plugin { contentOnly: true }) } + if (s) { return { code: s.toString(), map: config.build.sourcemap ? s.generateMap({ hires: true }) : null } } + return null } } diff --git a/packages/vite/src/node/utils.ts b/packages/vite/src/node/utils.ts index 8c7859e3850454..16391df8c73df3 100644 --- a/packages/vite/src/node/utils.ts +++ b/packages/vite/src/node/utils.ts @@ -733,4 +733,3 @@ export function parseRequest(id: string): Record | null { } export const blankReplacer = (match: string) => ' '.repeat(match.length) -export const stringsRE = /"[^"]*"|'[^']*'|`[^`]*`/g From 485263cdca78e5b30fce77f1af9862b3ea3d76f1 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 11 Apr 2022 15:10:42 +0200 Subject: [PATCH 021/175] fix(deps): update all non-major dependencies (#7668) --- package.json | 12 +- packages/plugin-legacy/package.json | 2 +- packages/plugin-react/package.json | 2 +- packages/plugin-vue-jsx/package.json | 2 +- packages/vite/package.json | 2 +- pnpm-lock.yaml | 336 ++++++++++++++------------- 6 files changed, 186 insertions(+), 170 deletions(-) diff --git a/package.json b/package.json index 27445e0d25cb29..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.20.0", + "@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.17.0", - "@typescript-eslint/parser": "^5.17.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", @@ -61,7 +61,7 @@ "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,7 +85,7 @@ "eslint --ext .ts" ] }, - "packageManager": "pnpm@6.32.4", + "packageManager": "pnpm@6.32.6", "pnpm": { "overrides": { "vite": "workspace:*", diff --git a/packages/plugin-legacy/package.json b/packages/plugin-legacy/package.json index aa8c478e4dae18..eb974d790f1e71 100644 --- a/packages/plugin-legacy/package.json +++ b/packages/plugin-legacy/package.json @@ -22,7 +22,7 @@ }, "homepage": "https://github.com/vitejs/vite/tree/main/packages/plugin-legacy#readme", "dependencies": { - "@babel/standalone": "^7.17.8", + "@babel/standalone": "^7.17.9", "core-js": "^3.21.1", "magic-string": "^0.26.1", "regenerator-runtime": "^0.13.9", diff --git a/packages/plugin-react/package.json b/packages/plugin-react/package.json index e0230a4a61cd30..e7fc9544120b11 100644 --- a/packages/plugin-react/package.json +++ b/packages/plugin-react/package.json @@ -33,7 +33,7 @@ }, "homepage": "https://github.com/vitejs/vite/tree/main/packages/plugin-react#readme", "dependencies": { - "@babel/core": "^7.17.8", + "@babel/core": "^7.17.9", "@babel/plugin-transform-react-jsx": "^7.17.3", "@babel/plugin-transform-react-jsx-development": "^7.16.7", "@babel/plugin-transform-react-jsx-self": "^7.16.7", diff --git a/packages/plugin-vue-jsx/package.json b/packages/plugin-vue-jsx/package.json index c6a352eccc99a0..d8057b91f8ab24 100644 --- a/packages/plugin-vue-jsx/package.json +++ b/packages/plugin-vue-jsx/package.json @@ -22,7 +22,7 @@ }, "homepage": "https://github.com/vitejs/vite/tree/main/packages/plugin-vue-jsx#readme", "dependencies": { - "@babel/core": "^7.17.8", + "@babel/core": "^7.17.9", "@babel/plugin-syntax-import-meta": "^7.10.4", "@babel/plugin-transform-typescript": "^7.16.8", "@rollup/pluginutils": "^4.2.0", diff --git a/packages/vite/package.json b/packages/vite/package.json index d2a351c6aa0869..adf73956a5c33a 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -53,7 +53,7 @@ }, "devDependencies": { "@ampproject/remapping": "^2.1.2", - "@babel/parser": "^7.17.8", + "@babel/parser": "^7.17.9", "@babel/types": "^7.17.0", "@jridgewell/trace-mapping": "^0.3.4", "@rollup/plugin-alias": "^3.1.9", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a54c2eadfcfff2..fbc05e51fbfc7a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -10,18 +10,18 @@ importers: .: specifiers: - '@microsoft/api-extractor': ^7.20.0 + '@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.17.0 - '@typescript-eslint/parser': ^5.17.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 @@ -37,7 +37,7 @@ importers: 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 @@ -46,20 +46,20 @@ importers: vite: workspace:* vitepress: ^0.22.3 devDependencies: - '@microsoft/api-extractor': 7.20.0 + '@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.17.0_d58f0eed9ebf32fdeceb6a8716e9bcf1 - '@typescript-eslint/parser': 5.17.0_eslint@8.12.0+typescript@4.5.4 + '@typescript-eslint/eslint-plugin': 5.18.0_423061f51ca07e3dd1eb999a8074f5cd + '@typescript-eslint/parser': 5.18.0_eslint@8.13.0+typescript@4.5.4 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_eslint@8.12.0 + eslint-plugin-node: 11.1.0_eslint@8.13.0 execa: 5.1.1 fs-extra: 10.0.1 jest: 27.5.1_ts-node@10.4.0 @@ -73,7 +73,7 @@ importers: prompts: 2.4.2 rimraf: 3.0.2 rollup: 2.62.0 - semver: 7.3.5 + semver: 7.3.6 simple-git-hooks: 2.7.0 sirv: 2.0.2 ts-jest: 27.1.4_4dfe14e0e8266437469ae0475a5c09ac @@ -751,13 +751,13 @@ importers: packages/plugin-legacy: specifiers: - '@babel/standalone': ^7.17.8 + '@babel/standalone': ^7.17.9 core-js: ^3.21.1 magic-string: ^0.26.1 regenerator-runtime: ^0.13.9 systemjs: ^6.12.1 dependencies: - '@babel/standalone': 7.17.8 + '@babel/standalone': 7.17.9 core-js: 3.21.1 magic-string: 0.26.1 regenerator-runtime: 0.13.9 @@ -765,7 +765,7 @@ importers: packages/plugin-react: specifiers: - '@babel/core': ^7.17.8 + '@babel/core': ^7.17.9 '@babel/plugin-transform-react-jsx': ^7.17.3 '@babel/plugin-transform-react-jsx-development': ^7.16.7 '@babel/plugin-transform-react-jsx-self': ^7.16.7 @@ -774,11 +774,11 @@ importers: react-refresh: ^0.12.0 resolve: ^1.22.0 dependencies: - '@babel/core': 7.17.8 - '@babel/plugin-transform-react-jsx': 7.17.3_@babel+core@7.17.8 - '@babel/plugin-transform-react-jsx-development': 7.16.7_@babel+core@7.17.8 - '@babel/plugin-transform-react-jsx-self': 7.16.7_@babel+core@7.17.8 - '@babel/plugin-transform-react-jsx-source': 7.16.7_@babel+core@7.17.8 + '@babel/core': 7.17.9 + '@babel/plugin-transform-react-jsx': 7.17.3_@babel+core@7.17.9 + '@babel/plugin-transform-react-jsx-development': 7.16.7_@babel+core@7.17.9 + '@babel/plugin-transform-react-jsx-self': 7.16.7_@babel+core@7.17.9 + '@babel/plugin-transform-react-jsx-source': 7.16.7_@babel+core@7.17.9 '@rollup/pluginutils': 4.2.0 react-refresh: 0.12.0 resolve: 1.22.0 @@ -805,24 +805,24 @@ importers: packages/plugin-vue-jsx: specifiers: - '@babel/core': ^7.17.8 + '@babel/core': ^7.17.9 '@babel/plugin-syntax-import-meta': ^7.10.4 '@babel/plugin-transform-typescript': ^7.16.8 '@rollup/pluginutils': ^4.2.0 '@vue/babel-plugin-jsx': ^1.1.1 hash-sum: ^2.0.0 dependencies: - '@babel/core': 7.17.8 - '@babel/plugin-syntax-import-meta': 7.10.4_@babel+core@7.17.8 - '@babel/plugin-transform-typescript': 7.16.8_@babel+core@7.17.8 + '@babel/core': 7.17.9 + '@babel/plugin-syntax-import-meta': 7.10.4_@babel+core@7.17.9 + '@babel/plugin-transform-typescript': 7.16.8_@babel+core@7.17.9 '@rollup/pluginutils': 4.2.0 - '@vue/babel-plugin-jsx': 1.1.1_@babel+core@7.17.8 + '@vue/babel-plugin-jsx': 1.1.1_@babel+core@7.17.9 hash-sum: 2.0.0 packages/vite: specifiers: '@ampproject/remapping': ^2.1.2 - '@babel/parser': ^7.17.8 + '@babel/parser': ^7.17.9 '@babel/types': ^7.17.0 '@jridgewell/trace-mapping': ^0.3.4 '@rollup/plugin-alias': ^3.1.9 @@ -900,7 +900,7 @@ importers: fsevents: 2.3.2 devDependencies: '@ampproject/remapping': 2.1.2 - '@babel/parser': 7.17.8 + '@babel/parser': 7.17.9 '@babel/types': 7.17.0 '@jridgewell/trace-mapping': 0.3.4 '@rollup/plugin-alias': 3.1.9_rollup@2.62.0 @@ -1135,24 +1135,24 @@ packages: - supports-color dev: true - /@babel/core/7.17.8: - resolution: {integrity: sha512-OdQDV/7cRBtJHLSOBqqbYNkOcydOgnX59TZx4puf41fzcVtN3e/4yqY8lMQsK+5X2lJtAdmA+6OHqsj1hBJ4IQ==} + /@babel/core/7.17.9: + resolution: {integrity: sha512-5ug+SfZCpDAkVp9SFIZAzlW18rlzsOcJGaetCjkySnrXXDUw9AR8cDUm1iByTmdWM6yxX6/zycaV76w3YTF2gw==} engines: {node: '>=6.9.0'} dependencies: '@ampproject/remapping': 2.1.2 '@babel/code-frame': 7.16.7 - '@babel/generator': 7.17.7 - '@babel/helper-compilation-targets': 7.17.7_@babel+core@7.17.8 + '@babel/generator': 7.17.9 + '@babel/helper-compilation-targets': 7.17.7_@babel+core@7.17.9 '@babel/helper-module-transforms': 7.17.7 - '@babel/helpers': 7.17.8 - '@babel/parser': 7.17.8 + '@babel/helpers': 7.17.9 + '@babel/parser': 7.17.9 '@babel/template': 7.16.7 - '@babel/traverse': 7.17.3 + '@babel/traverse': 7.17.9 '@babel/types': 7.17.0 convert-source-map: 1.8.0 - debug: 4.3.3 + debug: 4.3.4 gensync: 1.0.0-beta.2 - json5: 2.2.0 + json5: 2.2.1 semver: 6.3.0 transitivePeerDependencies: - supports-color @@ -1185,8 +1185,8 @@ packages: source-map: 0.5.7 dev: true - /@babel/generator/7.17.7: - resolution: {integrity: sha512-oLcVCTeIFadUoArDTwpluncplrYBmTCCZZgXCbgNGvOBBiSDDK3eWO4b/+eOTli5tKv1lg+a5/NAXg+nTcei1w==} + /@babel/generator/7.17.9: + resolution: {integrity: sha512-rAdDousTwxbIxbz5I7GEQ3lUip+xVCXooZNbsydCWs3xA7ZsYOv+CFRdzGxRX78BmQHu9B1Eso59AOZQOJDEdQ==} engines: {node: '>=6.9.0'} dependencies: '@babel/types': 7.17.0 @@ -1214,26 +1214,26 @@ packages: semver: 6.3.0 dev: true - /@babel/helper-compilation-targets/7.17.7_@babel+core@7.17.8: + /@babel/helper-compilation-targets/7.17.7_@babel+core@7.17.9: resolution: {integrity: sha512-UFzlz2jjd8kroj0hmCFV5zr+tQPi1dpC2cRsDV/3IEW8bJfCPrPpmcSN6ZS8RqIq4LXcmpipCQFPddyFA5Yc7w==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0 dependencies: '@babel/compat-data': 7.17.7 - '@babel/core': 7.17.8 + '@babel/core': 7.17.9 '@babel/helper-validator-option': 7.16.7 browserslist: 4.19.1 semver: 6.3.0 dev: false - /@babel/helper-create-class-features-plugin/7.16.10_@babel+core@7.17.8: + /@babel/helper-create-class-features-plugin/7.16.10_@babel+core@7.17.9: resolution: {integrity: sha512-wDeej0pu3WN/ffTxMNCPW5UCiOav8IcLRxSIyp/9+IF2xJUM9h/OYjg0IJLHaL6F8oU8kqMz9nc1vryXhMsgXg==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0 dependencies: - '@babel/core': 7.17.8 + '@babel/core': 7.17.9 '@babel/helper-annotate-as-pure': 7.16.7 '@babel/helper-environment-visitor': 7.16.7 '@babel/helper-function-name': 7.16.7 @@ -1259,6 +1259,14 @@ packages: '@babel/template': 7.16.7 '@babel/types': 7.17.0 + /@babel/helper-function-name/7.17.9: + resolution: {integrity: sha512-7cRisGlVtiVqZ0MW0/yFB4atgpGLWEHUVYnb448hZK4x+vih0YO5UoS11XIYtZYqHd0dIPMdUSv8q5K4LdMnIg==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/template': 7.16.7 + '@babel/types': 7.17.0 + dev: false + /@babel/helper-get-function-arity/7.16.7: resolution: {integrity: sha512-flc+RLSOBXzNzVhcLu6ujeHUrD6tANAOU5ojrRx/as+tbzf8+stUCj7+IfRRoAbEZqj/ahXEMsjhOhgeZsrnTw==} engines: {node: '>=6.9.0'} @@ -1323,7 +1331,7 @@ packages: '@babel/helper-split-export-declaration': 7.16.7 '@babel/helper-validator-identifier': 7.16.7 '@babel/template': 7.16.7 - '@babel/traverse': 7.17.3 + '@babel/traverse': 7.17.9 '@babel/types': 7.17.0 transitivePeerDependencies: - supports-color @@ -1400,12 +1408,12 @@ packages: - supports-color dev: true - /@babel/helpers/7.17.8: - resolution: {integrity: sha512-QcL86FGxpfSJwGtAvv4iG93UL6bmqBdmoVY0CMCU2g+oD2ezQse3PT5Pa+jiD6LJndBQi0EDlpzOWNlLuhz5gw==} + /@babel/helpers/7.17.9: + resolution: {integrity: sha512-cPCt915ShDWUEzEp3+UNRktO2n6v49l5RSnG9M5pS24hA+2FAc5si+Pn1i4VVbQQ+jh+bIZhPFQOJOzbrOYY1Q==} engines: {node: '>=6.9.0'} dependencies: '@babel/template': 7.16.7 - '@babel/traverse': 7.17.3 + '@babel/traverse': 7.17.9 '@babel/types': 7.17.0 transitivePeerDependencies: - supports-color @@ -1449,6 +1457,11 @@ packages: engines: {node: '>=6.0.0'} hasBin: true + /@babel/parser/7.17.9: + resolution: {integrity: sha512-vqUSBLP8dQHFPdPi9bc5GK9vRkYHJ49fsZdtoJ8EQ8ibpwk5rPKfvNIwChB0KVXcIjcepEBBd2VHC5r9Gy8ueg==} + engines: {node: '>=6.0.0'} + hasBin: true + /@babel/plugin-proposal-pipeline-operator/7.16.5: resolution: {integrity: sha512-aMw3gPJYa2F6mVnL6QuHr9NtAScspBPTVXU2kaup7FVl02Hr4tY2diaGNdismAOmiroWa/2ENy4EFyoz81ACLg==} engines: {node: '>=6.9.0'} @@ -1495,12 +1508,12 @@ packages: '@babel/helper-plugin-utils': 7.16.5 dev: true - /@babel/plugin-syntax-import-meta/7.10.4_@babel+core@7.17.8: + /@babel/plugin-syntax-import-meta/7.10.4_@babel+core@7.17.9: resolution: {integrity: sha512-Yqfm+XDx0+Prh3VSeEQCPU81yC+JWZ2pDPFSS4ZdpfZhp4MkFMaDC1UqseovEKwSUpnIL7+vK+Clp7bfh0iD7g==} peerDependencies: '@babel/core': ^7.0.0-0 dependencies: - '@babel/core': 7.17.8 + '@babel/core': 7.17.9 '@babel/helper-plugin-utils': 7.16.5 dev: false @@ -1522,23 +1535,23 @@ packages: '@babel/helper-plugin-utils': 7.16.7 dev: true - /@babel/plugin-syntax-jsx/7.16.5_@babel+core@7.17.8: + /@babel/plugin-syntax-jsx/7.16.5_@babel+core@7.17.9: resolution: {integrity: sha512-42OGssv9NPk4QHKVgIHlzeLgPOW5rGgfV5jzG90AhcXXIv6hu/eqj63w4VgvRxdvZY3AlYeDgPiSJ3BqAd1Y6Q==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0-0 dependencies: - '@babel/core': 7.17.8 + '@babel/core': 7.17.9 '@babel/helper-plugin-utils': 7.16.7 dev: false - /@babel/plugin-syntax-jsx/7.16.7_@babel+core@7.17.8: + /@babel/plugin-syntax-jsx/7.16.7_@babel+core@7.17.9: resolution: {integrity: sha512-Esxmk7YjA8QysKeT3VhTXvF6y77f/a91SIs4pWb4H2eWGQkCKFgQaG6hdoEVZtGsrAcb2K5BW66XsOErD4WU3Q==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0-0 dependencies: - '@babel/core': 7.17.8 + '@babel/core': 7.17.9 '@babel/helper-plugin-utils': 7.16.7 dev: false @@ -1625,70 +1638,70 @@ packages: '@babel/helper-plugin-utils': 7.16.7 dev: true - /@babel/plugin-syntax-typescript/7.16.7_@babel+core@7.17.8: + /@babel/plugin-syntax-typescript/7.16.7_@babel+core@7.17.9: resolution: {integrity: sha512-YhUIJHHGkqPgEcMYkPCKTyGUdoGKWtopIycQyjJH8OjvRgOYsXsaKehLVPScKJWAULPxMa4N1vCe6szREFlZ7A==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0-0 dependencies: - '@babel/core': 7.17.8 + '@babel/core': 7.17.9 '@babel/helper-plugin-utils': 7.16.7 dev: false - /@babel/plugin-transform-react-jsx-development/7.16.7_@babel+core@7.17.8: + /@babel/plugin-transform-react-jsx-development/7.16.7_@babel+core@7.17.9: resolution: {integrity: sha512-RMvQWvpla+xy6MlBpPlrKZCMRs2AGiHOGHY3xRwl0pEeim348dDyxeH4xBsMPbIMhujeq7ihE702eM2Ew0Wo+A==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0-0 dependencies: - '@babel/core': 7.17.8 - '@babel/plugin-transform-react-jsx': 7.17.3_@babel+core@7.17.8 + '@babel/core': 7.17.9 + '@babel/plugin-transform-react-jsx': 7.17.3_@babel+core@7.17.9 dev: false - /@babel/plugin-transform-react-jsx-self/7.16.7_@babel+core@7.17.8: + /@babel/plugin-transform-react-jsx-self/7.16.7_@babel+core@7.17.9: resolution: {integrity: sha512-oe5VuWs7J9ilH3BCCApGoYjHoSO48vkjX2CbA5bFVhIuO2HKxA3vyF7rleA4o6/4rTDbk6r8hBW7Ul8E+UZrpA==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0-0 dependencies: - '@babel/core': 7.17.8 + '@babel/core': 7.17.9 '@babel/helper-plugin-utils': 7.16.7 dev: false - /@babel/plugin-transform-react-jsx-source/7.16.7_@babel+core@7.17.8: + /@babel/plugin-transform-react-jsx-source/7.16.7_@babel+core@7.17.9: resolution: {integrity: sha512-rONFiQz9vgbsnaMtQlZCjIRwhJvlrPET8TabIUK2hzlXw9B9s2Ieaxte1SCOOXMbWRHodbKixNf3BLcWVOQ8Bw==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0-0 dependencies: - '@babel/core': 7.17.8 + '@babel/core': 7.17.9 '@babel/helper-plugin-utils': 7.16.7 dev: false - /@babel/plugin-transform-react-jsx/7.17.3_@babel+core@7.17.8: + /@babel/plugin-transform-react-jsx/7.17.3_@babel+core@7.17.9: resolution: {integrity: sha512-9tjBm4O07f7mzKSIlEmPdiE6ub7kfIe6Cd+w+oQebpATfTQMAgW+YOuWxogbKVTulA+MEO7byMeIUtQ1z+z+ZQ==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0-0 dependencies: - '@babel/core': 7.17.8 + '@babel/core': 7.17.9 '@babel/helper-annotate-as-pure': 7.16.7 '@babel/helper-module-imports': 7.16.7 '@babel/helper-plugin-utils': 7.16.7 - '@babel/plugin-syntax-jsx': 7.16.7_@babel+core@7.17.8 + '@babel/plugin-syntax-jsx': 7.16.7_@babel+core@7.17.9 '@babel/types': 7.17.0 dev: false - /@babel/plugin-transform-typescript/7.16.8_@babel+core@7.17.8: + /@babel/plugin-transform-typescript/7.16.8_@babel+core@7.17.9: resolution: {integrity: sha512-bHdQ9k7YpBDO2d0NVfkj51DpQcvwIzIusJ7mEUaMlbZq3Kt/U47j24inXZHQ5MDiYpCs+oZiwnXyKedE8+q7AQ==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0-0 dependencies: - '@babel/core': 7.17.8 - '@babel/helper-create-class-features-plugin': 7.16.10_@babel+core@7.17.8 + '@babel/core': 7.17.9 + '@babel/helper-create-class-features-plugin': 7.16.10_@babel+core@7.17.9 '@babel/helper-plugin-utils': 7.16.7 - '@babel/plugin-syntax-typescript': 7.16.7_@babel+core@7.17.8 + '@babel/plugin-syntax-typescript': 7.16.7_@babel+core@7.17.9 transitivePeerDependencies: - supports-color dev: false @@ -1699,8 +1712,8 @@ packages: dependencies: regenerator-runtime: 0.13.9 - /@babel/standalone/7.17.8: - resolution: {integrity: sha512-tr3SDpVnxR/fzrxyG+HZPAyEA9eTHZIAjy4eqrc7m+KBwsdo1YvTbUfJ6teWHQ177mk6GmdmltsIiOYCcvRPWA==} + /@babel/standalone/7.17.9: + resolution: {integrity: sha512-9wL9AtDlga8avxUrBvQJmhUtJWrelsUL0uV+TcP+49Sb6Pj8/bNIzQzU4dDp0NAPOvnZR/7msFIKsKoCl/W1/w==} engines: {node: '>=6.9.0'} dev: false @@ -1775,19 +1788,19 @@ packages: - supports-color dev: true - /@babel/traverse/7.17.3: - resolution: {integrity: sha512-5irClVky7TxRWIRtxlh2WPUUOLhcPN06AGgaQSB8AEwuyEBgJVuJ5imdHm5zxk8w0QS5T+tDfnDxAlhWjpb7cw==} + /@babel/traverse/7.17.9: + resolution: {integrity: sha512-PQO8sDIJ8SIwipTPiR71kJQCKQYB5NGImbOviK8K+kg5xkNSYXLBupuX9QhatFowrsvo9Hj8WgArg3W7ijNAQw==} engines: {node: '>=6.9.0'} dependencies: '@babel/code-frame': 7.16.7 - '@babel/generator': 7.17.7 + '@babel/generator': 7.17.9 '@babel/helper-environment-visitor': 7.16.7 - '@babel/helper-function-name': 7.16.7 + '@babel/helper-function-name': 7.17.9 '@babel/helper-hoist-variables': 7.16.7 '@babel/helper-split-export-declaration': 7.16.7 - '@babel/parser': 7.17.8 + '@babel/parser': 7.17.9 '@babel/types': 7.17.0 - debug: 4.3.3 + debug: 4.3.4 globals: 11.12.0 transitivePeerDependencies: - supports-color @@ -2223,28 +2236,28 @@ packages: - supports-color dev: false - /@microsoft/api-extractor-model/7.16.0: - resolution: {integrity: sha512-0FOrbNIny8mzBrzQnSIkEjAXk0JMSnPmWYxt3ZDTPVg9S8xIPzB6lfgTg9+Mimu0RKCpGKBpd+v2WcR5vGzyUQ==} + /@microsoft/api-extractor-model/7.16.1: + resolution: {integrity: sha512-+1mlvy/ji+mUuH7WdVZ6fTo/aCKfS6m37aAFVOFWLfkMvmR+I9SjPfiv9qOg83If7GOrk2HPiHHibv6kA80VTg==} dependencies: '@microsoft/tsdoc': 0.13.2 '@microsoft/tsdoc-config': 0.15.2 - '@rushstack/node-core-library': 3.45.1 + '@rushstack/node-core-library': 3.45.2 dev: true - /@microsoft/api-extractor/7.20.0: - resolution: {integrity: sha512-WKAu5JpkRXWKL3AyxmFXuwNNPpBlsAefwZIDl8M5mhEqRji4w+gexb0pku3Waa0flm3vm0Cwpm+kGYYJ4/gzAA==} + /@microsoft/api-extractor/7.21.2: + resolution: {integrity: sha512-m0+YPaXVou01O/V9swugZG7Gn4mw6HSWY+uisf0j2JPRZcoEDyoYe4hg0ERKXOEf0hByOnMLT28nQ82v8ig9Yw==} hasBin: true dependencies: - '@microsoft/api-extractor-model': 7.16.0 + '@microsoft/api-extractor-model': 7.16.1 '@microsoft/tsdoc': 0.13.2 '@microsoft/tsdoc-config': 0.15.2 - '@rushstack/node-core-library': 3.45.1 - '@rushstack/rig-package': 0.3.8 - '@rushstack/ts-command-line': 4.10.7 + '@rushstack/node-core-library': 3.45.2 + '@rushstack/rig-package': 0.3.9 + '@rushstack/ts-command-line': 4.10.8 colors: 1.2.5 lodash: 4.17.21 resolve: 1.17.0 - semver: 7.3.5 + semver: 7.3.6 source-map: 0.6.1 typescript: 4.5.4 dev: true @@ -2418,8 +2431,8 @@ packages: estree-walker: 2.0.2 picomatch: 2.3.0 - /@rushstack/node-core-library/3.45.1: - resolution: {integrity: sha512-BwdssTNe007DNjDBxJgInHg8ePytIPyT0La7ZZSQZF9+rSkT42AygXPGvbGsyFfEntjr4X37zZSJI7yGzL16cQ==} + /@rushstack/node-core-library/3.45.2: + resolution: {integrity: sha512-MJKdB6mxOoIkks3htGVCo7aiTzllm2I6Xua+KbTSb0cp7rBp8gTCOF/4d8R4HFMwpRdEdwzKgqMM6k9rAK73iw==} dependencies: '@types/node': 12.20.24 colors: 1.2.5 @@ -2427,20 +2440,20 @@ packages: import-lazy: 4.0.0 jju: 1.4.0 resolve: 1.17.0 - semver: 7.3.5 + semver: 7.3.6 timsort: 0.3.0 z-schema: 5.0.2 dev: true - /@rushstack/rig-package/0.3.8: - resolution: {integrity: sha512-MDWg1xovea99PWloSiYMjFcCLsrdjFtYt6aOyHNs5ojn5mxrzR6U9F83hvbQjTWnKPMvZtr0vcek+4n+OQOp3Q==} + /@rushstack/rig-package/0.3.9: + resolution: {integrity: sha512-z3Oxpfb4n9mGXwseX+ifpkmUf9B8Fy8oieVwg8eFgpCbzllkgOwEiwLKEnRWVQ8owFcd46NCKz+7ICH35CRsAw==} dependencies: resolve: 1.17.0 strip-json-comments: 3.1.1 dev: true - /@rushstack/ts-command-line/4.10.7: - resolution: {integrity: sha512-CjS+DfNXUSO5Ab2wD1GBGtUTnB02OglRWGqfaTcac9Jn45V5MeUOsq/wA8wEeS5Y/3TZ2P1k+IWdVDiuOFP9Og==} + /@rushstack/ts-command-line/4.10.8: + resolution: {integrity: sha512-G7CQYY/m3aZU5fVxbebv35yDeua7sSumrDAB2pJp0d60ZEsxGkUQW8771CeMcGWwSKqT9PxPzKpmIakiWv54sA==} dependencies: '@types/argparse': 1.0.38 argparse: 1.0.10 @@ -2704,8 +2717,8 @@ packages: dev: true optional: true - /@typescript-eslint/eslint-plugin/5.17.0_d58f0eed9ebf32fdeceb6a8716e9bcf1: - resolution: {integrity: sha512-qVstvQilEd89HJk3qcbKt/zZrfBZ+9h2ynpAGlWjWiizA7m/MtLT9RoX6gjtpE500vfIg8jogAkDzdCxbsFASQ==} + /@typescript-eslint/eslint-plugin/5.18.0_423061f51ca07e3dd1eb999a8074f5cd: + resolution: {integrity: sha512-tzrmdGMJI/uii9/V6lurMo4/o+dMTKDH82LkNjhJ3adCW22YQydoRs5MwTiqxGF9CSYxPxQ7EYb4jLNlIs+E+A==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: '@typescript-eslint/parser': ^5.0.0 @@ -2715,24 +2728,24 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/parser': 5.17.0_eslint@8.12.0+typescript@4.5.4 - '@typescript-eslint/scope-manager': 5.17.0 - '@typescript-eslint/type-utils': 5.17.0_eslint@8.12.0+typescript@4.5.4 - '@typescript-eslint/utils': 5.17.0_eslint@8.12.0+typescript@4.5.4 + '@typescript-eslint/parser': 5.18.0_eslint@8.13.0+typescript@4.5.4 + '@typescript-eslint/scope-manager': 5.18.0 + '@typescript-eslint/type-utils': 5.18.0_eslint@8.13.0+typescript@4.5.4 + '@typescript-eslint/utils': 5.18.0_eslint@8.13.0+typescript@4.5.4 debug: 4.3.4 - eslint: 8.12.0 + eslint: 8.13.0 functional-red-black-tree: 1.0.1 ignore: 5.2.0 regexpp: 3.2.0 - semver: 7.3.5 + semver: 7.3.6 tsutils: 3.21.0_typescript@4.5.4 typescript: 4.5.4 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/parser/5.17.0_eslint@8.12.0+typescript@4.5.4: - resolution: {integrity: sha512-aRzW9Jg5Rlj2t2/crzhA2f23SIYFlF9mchGudyP0uiD6SenIxzKoLjwzHbafgHn39dNV/TV7xwQkLfFTZlJ4ig==} + /@typescript-eslint/parser/5.18.0_eslint@8.13.0+typescript@4.5.4: + resolution: {integrity: sha512-+08nYfurBzSSPndngnHvFw/fniWYJ5ymOrn/63oMIbgomVQOvIDhBoJmYZ9lwQOCnQV9xHGvf88ze3jFGUYooQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 @@ -2741,26 +2754,26 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/scope-manager': 5.17.0 - '@typescript-eslint/types': 5.17.0 - '@typescript-eslint/typescript-estree': 5.17.0_typescript@4.5.4 + '@typescript-eslint/scope-manager': 5.18.0 + '@typescript-eslint/types': 5.18.0 + '@typescript-eslint/typescript-estree': 5.18.0_typescript@4.5.4 debug: 4.3.4 - eslint: 8.12.0 + eslint: 8.13.0 typescript: 4.5.4 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/scope-manager/5.17.0: - resolution: {integrity: sha512-062iCYQF/doQ9T2WWfJohQKKN1zmmXVfAcS3xaiialiw8ZUGy05Em6QVNYJGO34/sU1a7a+90U3dUNfqUDHr3w==} + /@typescript-eslint/scope-manager/5.18.0: + resolution: {integrity: sha512-C0CZML6NyRDj+ZbMqh9FnPscg2PrzSaVQg3IpTmpe0NURMVBXlghGZgMYqBw07YW73i0MCqSDqv2SbywnCS8jQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dependencies: - '@typescript-eslint/types': 5.17.0 - '@typescript-eslint/visitor-keys': 5.17.0 + '@typescript-eslint/types': 5.18.0 + '@typescript-eslint/visitor-keys': 5.18.0 dev: true - /@typescript-eslint/type-utils/5.17.0_eslint@8.12.0+typescript@4.5.4: - resolution: {integrity: sha512-3hU0RynUIlEuqMJA7dragb0/75gZmwNwFf/QJokWzPehTZousP/MNifVSgjxNcDCkM5HI2K22TjQWUmmHUINSg==} + /@typescript-eslint/type-utils/5.18.0_eslint@8.13.0+typescript@4.5.4: + resolution: {integrity: sha512-vcn9/6J5D6jtHxpEJrgK8FhaM8r6J1/ZiNu70ZUJN554Y3D9t3iovi6u7JF8l/e7FcBIxeuTEidZDR70UuCIfA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: eslint: '*' @@ -2769,22 +2782,22 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/utils': 5.17.0_eslint@8.12.0+typescript@4.5.4 + '@typescript-eslint/utils': 5.18.0_eslint@8.13.0+typescript@4.5.4 debug: 4.3.4 - eslint: 8.12.0 + eslint: 8.13.0 tsutils: 3.21.0_typescript@4.5.4 typescript: 4.5.4 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/types/5.17.0: - resolution: {integrity: sha512-AgQ4rWzmCxOZLioFEjlzOI3Ch8giDWx8aUDxyNw9iOeCvD3GEYAB7dxWGQy4T/rPVe8iPmu73jPHuaSqcjKvxw==} + /@typescript-eslint/types/5.18.0: + resolution: {integrity: sha512-bhV1+XjM+9bHMTmXi46p1Led5NP6iqQcsOxgx7fvk6gGiV48c6IynY0apQb7693twJDsXiVzNXTflhplmaiJaw==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true - /@typescript-eslint/typescript-estree/5.17.0_typescript@4.5.4: - resolution: {integrity: sha512-X1gtjEcmM7Je+qJRhq7ZAAaNXYhTgqMkR10euC4Si6PIjb+kwEQHSxGazXUQXFyqfEXdkGf6JijUu5R0uceQzg==} + /@typescript-eslint/typescript-estree/5.18.0_typescript@4.5.4: + resolution: {integrity: sha512-wa+2VAhOPpZs1bVij9e5gyVu60ReMi/KuOx4LKjGx2Y3XTNUDJgQ+5f77D49pHtqef/klglf+mibuHs9TrPxdQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: typescript: '*' @@ -2792,41 +2805,41 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/types': 5.17.0 - '@typescript-eslint/visitor-keys': 5.17.0 + '@typescript-eslint/types': 5.18.0 + '@typescript-eslint/visitor-keys': 5.18.0 debug: 4.3.4 globby: 11.0.4 is-glob: 4.0.3 - semver: 7.3.5 + semver: 7.3.6 tsutils: 3.21.0_typescript@4.5.4 typescript: 4.5.4 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/utils/5.17.0_eslint@8.12.0+typescript@4.5.4: - resolution: {integrity: sha512-DVvndq1QoxQH+hFv+MUQHrrWZ7gQ5KcJzyjhzcqB1Y2Xes1UQQkTRPUfRpqhS8mhTWsSb2+iyvDW1Lef5DD7vA==} + /@typescript-eslint/utils/5.18.0_eslint@8.13.0+typescript@4.5.4: + resolution: {integrity: sha512-+hFGWUMMri7OFY26TsOlGa+zgjEy1ssEipxpLjtl4wSll8zy85x0GrUSju/FHdKfVorZPYJLkF3I4XPtnCTewA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 dependencies: '@types/json-schema': 7.0.9 - '@typescript-eslint/scope-manager': 5.17.0 - '@typescript-eslint/types': 5.17.0 - '@typescript-eslint/typescript-estree': 5.17.0_typescript@4.5.4 - eslint: 8.12.0 + '@typescript-eslint/scope-manager': 5.18.0 + '@typescript-eslint/types': 5.18.0 + '@typescript-eslint/typescript-estree': 5.18.0_typescript@4.5.4 + eslint: 8.13.0 eslint-scope: 5.1.1 - eslint-utils: 3.0.0_eslint@8.12.0 + eslint-utils: 3.0.0_eslint@8.13.0 transitivePeerDependencies: - supports-color - typescript dev: true - /@typescript-eslint/visitor-keys/5.17.0: - resolution: {integrity: sha512-6K/zlc4OfCagUu7Am/BD5k8PSWQOgh34Nrv9Rxe2tBzlJ7uOeJ/h7ugCGDCeEZHT6k2CJBhbk9IsbkPI0uvUkA==} + /@typescript-eslint/visitor-keys/5.18.0: + resolution: {integrity: sha512-Hf+t+dJsjAKpKSkg3EHvbtEpFFb/1CiOHnvI8bjHgOD4/wAw3gKrA0i94LrbekypiZVanJu3McWJg7rWDMzRTg==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dependencies: - '@typescript-eslint/types': 5.17.0 + '@typescript-eslint/types': 5.18.0 eslint-visitor-keys: 3.3.0 dev: true @@ -2834,11 +2847,11 @@ packages: resolution: {integrity: sha512-hz4R8tS5jMn8lDq6iD+yWL6XNB699pGIVLk7WSJnn1dbpjaazsjZQkieJoRX6gW5zpYSCFqQ7jUquPNY65tQYA==} dev: false - /@vue/babel-plugin-jsx/1.1.1_@babel+core@7.17.8: + /@vue/babel-plugin-jsx/1.1.1_@babel+core@7.17.9: resolution: {integrity: sha512-j2uVfZjnB5+zkcbc/zsOc0fSNGCMMjaEXP52wdwdIfn0qjFfEYpYZBFKFg+HHnQeJCVrjOeO0YxgaL7DMrym9w==} dependencies: '@babel/helper-module-imports': 7.16.0 - '@babel/plugin-syntax-jsx': 7.16.5_@babel+core@7.17.8 + '@babel/plugin-syntax-jsx': 7.16.5_@babel+core@7.17.9 '@babel/template': 7.16.0 '@babel/traverse': 7.16.5 '@babel/types': 7.16.0 @@ -3267,7 +3280,7 @@ packages: /axios/0.24.0: resolution: {integrity: sha512-Q6cWsys88HoPgAaFAVUb0WpPk0O8iTeisR9IMqy9G8AbO4NlpVknrnQS03zzF9PGAWgO3cgletO3VjV/P7VztA==} dependencies: - follow-redirects: 1.14.6_debug@4.3.4 + follow-redirects: 1.14.6 transitivePeerDependencies: - debug dev: false @@ -4714,25 +4727,25 @@ packages: engines: {node: '>= 16.9.0', npm: '>= 7.0.0', pnpm: '>= 6.32.2'} dev: true - /eslint-plugin-es/3.0.1_eslint@8.12.0: + /eslint-plugin-es/3.0.1_eslint@8.13.0: resolution: {integrity: sha512-GUmAsJaN4Fc7Gbtl8uOBlayo2DqhwWvEzykMHSCZHU3XdJ+NSzzZcVhXh3VxX5icqQ+oQdIEawXX8xkR3mIFmQ==} engines: {node: '>=8.10.0'} peerDependencies: eslint: '>=4.19.1' dependencies: - eslint: 8.12.0 + eslint: 8.13.0 eslint-utils: 2.1.0 regexpp: 3.2.0 dev: true - /eslint-plugin-node/11.1.0_eslint@8.12.0: + /eslint-plugin-node/11.1.0_eslint@8.13.0: resolution: {integrity: sha512-oUwtPJ1W0SKD0Tr+wqu92c5xuCeQqB3hSCHasn/ZgjFdA9iDGNkNf2Zi9ztY7X+hNuMib23LNGRm6+uN+KLE3g==} engines: {node: '>=8.10.0'} peerDependencies: eslint: '>=5.16.0' dependencies: - eslint: 8.12.0 - eslint-plugin-es: 3.0.1_eslint@8.12.0 + eslint: 8.13.0 + eslint-plugin-es: 3.0.1_eslint@8.13.0 eslint-utils: 2.1.0 ignore: 5.2.0 minimatch: 3.0.4 @@ -4763,13 +4776,13 @@ packages: eslint-visitor-keys: 1.3.0 dev: true - /eslint-utils/3.0.0_eslint@8.12.0: + /eslint-utils/3.0.0_eslint@8.13.0: resolution: {integrity: sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==} engines: {node: ^10.0.0 || ^12.0.0 || >= 14.0.0} peerDependencies: eslint: '>=5' dependencies: - eslint: 8.12.0 + eslint: 8.13.0 eslint-visitor-keys: 2.1.0 dev: true @@ -4788,8 +4801,8 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true - /eslint/8.12.0: - resolution: {integrity: sha512-it1oBL9alZg1S8UycLm5YDMAkIhtH6FtAzuZs6YvoGVldWjbS08BkAdb/ymP9LlAyq8koANu32U7Ib/w+UNh8Q==} + /eslint/8.13.0: + resolution: {integrity: sha512-D+Xei61eInqauAyTJ6C0q6x9mx7kTUC1KZ0m0LSEexR0V+e94K12LmWX076ZIsldwfQ2RONdaJe0re0TRGQbRQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} hasBin: true dependencies: @@ -4802,7 +4815,7 @@ packages: doctrine: 3.0.0 escape-string-regexp: 4.0.0 eslint-scope: 7.1.1 - eslint-utils: 3.0.0_eslint@8.12.0 + eslint-utils: 3.0.0_eslint@8.13.0 eslint-visitor-keys: 3.3.0 espree: 9.3.1 esquery: 1.4.0 @@ -5090,7 +5103,7 @@ packages: resolution: {integrity: sha512-8/sOawo8tJ4QOBX8YlQBMxL8+RLZfxMQOif9o0KUKTNTjMYElWPE0r/m5VNFxTRd0NSw8qSy8dajrwX4RYI1Hw==} dev: true - /follow-redirects/1.14.6_debug@4.3.4: + /follow-redirects/1.14.6: resolution: {integrity: sha512-fhUl5EwSJbbl8AR+uYL2KQDxLkdSjZGR36xy46AO7cOMTrCMON6Sa28FmAnC2tRTDbd/Uuzz3aJBv7EBN7JH8A==} engines: {node: '>=4.0'} peerDependencies: @@ -5098,8 +5111,6 @@ packages: peerDependenciesMeta: debug: optional: true - dependencies: - debug: 4.3.4 /form-data/3.0.1: resolution: {integrity: sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==} @@ -5500,7 +5511,7 @@ packages: engines: {node: '>=8.0.0'} dependencies: eventemitter3: 4.0.7 - follow-redirects: 1.14.6_debug@4.3.4 + follow-redirects: 1.14.6 requires-port: 1.0.0 transitivePeerDependencies: - debug @@ -6305,7 +6316,7 @@ packages: jest-util: 27.5.1 natural-compare: 1.4.0 pretty-format: 27.5.1 - semver: 7.3.5 + semver: 7.3.6 transitivePeerDependencies: - supports-color dev: true @@ -6473,19 +6484,10 @@ packages: resolution: {integrity: sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=} dev: true - /json5/2.2.0: - resolution: {integrity: sha512-f+8cldu7X/y7RAJurMEJmdoKXGB/X550w2Nr3tTbezL6RwEE/iMcm+tZnXeoZtKuOq6ft8+CqzEkrIgx1fPoQA==} - engines: {node: '>=6'} - hasBin: true - dependencies: - minimist: 1.2.5 - dev: false - /json5/2.2.1: resolution: {integrity: sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==} engines: {node: '>=6'} hasBin: true - dev: true /jsonfile/4.0.0: resolution: {integrity: sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=} @@ -6736,6 +6738,11 @@ packages: dependencies: yallist: 4.0.0 + /lru-cache/7.8.1: + resolution: {integrity: sha512-E1v547OCgJvbvevfjgK9sNKIVXO96NnsTsFPBlg4ZxjhsJSODoH9lk8Bm0OxvHNm6Vm5Yqkl/1fErDxhYL8Skg==} + engines: {node: '>=12'} + dev: true + /magic-string/0.25.7: resolution: {integrity: sha512-4CrMT5DOHTDk4HYDlzmwu4FVCcIYI8gauveasrdCu2IKIFOJ3f0v/8MDGJCDL9oD2ppz/Av1b0Nj345H9M+XIA==} dependencies: @@ -7123,7 +7130,7 @@ packages: dependencies: hosted-git-info: 4.0.2 is-core-module: 2.8.1 - semver: 7.3.5 + semver: 7.3.6 validate-npm-package-license: 3.0.4 dev: true @@ -8390,6 +8397,15 @@ packages: hasBin: true dependencies: lru-cache: 6.0.0 + dev: false + + /semver/7.3.6: + resolution: {integrity: sha512-HZWqcgwLsjaX1HBD31msI/rXktuIhS+lWvdE4kN9z+8IVT4Itc7vqU2WvYsyD6/sjYCt4dEKH/m1M3dwI9CC5w==} + engines: {node: ^10.0.0 || ^12.0.0 || ^14.0.0 || >=16.0.0} + hasBin: true + dependencies: + lru-cache: 7.8.1 + dev: true /send/0.17.2: resolution: {integrity: sha512-UJYB6wFSJE3G00nEivR5rgWp8c2xXvJ3OPWPhmuteU0IKj8nKbG3DrjiOmLwpnHGYWAVwA69zmTm++YG0Hmwww==} @@ -9163,7 +9179,7 @@ packages: json5: 2.2.1 lodash.memoize: 4.1.2 make-error: 1.3.6 - semver: 7.3.5 + semver: 7.3.6 typescript: 4.5.4 yargs-parser: 20.2.9 dev: true From 29e622cc7c9843a51508136df856c419a99e8d73 Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Tue, 12 Apr 2022 02:13:37 +0800 Subject: [PATCH 022/175] fix(css): hoist charset (#7678) --- packages/playground/css/__tests__/css.spec.ts | 9 +++++++ packages/playground/css/charset.css | 5 ++++ packages/playground/css/index.html | 3 +++ packages/playground/css/main.js | 3 +++ packages/vite/src/node/plugins/css.ts | 24 ++++++++++++------- 5 files changed, 35 insertions(+), 9 deletions(-) create mode 100644 packages/playground/css/charset.css diff --git a/packages/playground/css/__tests__/css.spec.ts b/packages/playground/css/__tests__/css.spec.ts index d3577176b4bb16..6ca00e760349b1 100644 --- a/packages/playground/css/__tests__/css.spec.ts +++ b/packages/playground/css/__tests__/css.spec.ts @@ -247,6 +247,15 @@ test('inline css modules', async () => { expect(css).toMatch(/\.inline-module__apply-color-inline___[\w-]{5}/) }) +if (isBuild) { + test('@charset hoist', async () => { + serverLogs.forEach((log) => { + // no warning from esbuild css minifier + expect(log).not.toMatch('"@charset" must be the first rule in the file') + }) + }) +} + test('@import dependency w/ style entry', async () => { expect(await getColor('.css-dep')).toBe('purple') }) diff --git a/packages/playground/css/charset.css b/packages/playground/css/charset.css new file mode 100644 index 00000000000000..5c42b279f8404c --- /dev/null +++ b/packages/playground/css/charset.css @@ -0,0 +1,5 @@ +@charset "utf-8"; + +.utf8 { + color: green; +} diff --git a/packages/playground/css/index.html b/packages/playground/css/index.html index dd496a8ffdce11..fef6a0be393748 100644 --- a/packages/playground/css/index.html +++ b/packages/playground/css/index.html @@ -96,6 +96,9 @@

CSS

Inline CSS module:


 
+  

CSS with @charset:

+

+
   

@import dependency w/ style enrtrypoints: this should be purple

diff --git a/packages/playground/css/main.js b/packages/playground/css/main.js index 564b3a56677dbd..0d03aafbf0ec7f 100644 --- a/packages/playground/css/main.js +++ b/packages/playground/css/main.js @@ -41,6 +41,9 @@ text( 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/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index dbe9e7d1dfa00f..adef254950c5e5 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -427,10 +427,10 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin { return `./${path.posix.basename(filename)}` } }) - // only external @imports should exist at this point - and they need to - // be hoisted to the top of the CSS chunk per spec (#1845) - if (css.includes('@import')) { - css = await hoistAtImports(css) + // only external @imports and @charset should exist at this point + // hoist them to the top of the CSS chunk per spec (#1845 and #6333) + if (css.includes('@import') || css.includes('@charset')) { + css = await hoistAtRules(css) } if (minify && config.build.minify) { css = await minifyCSS(css, config) @@ -1109,27 +1109,33 @@ async function minifyCSS(css: string, config: ResolvedConfig) { // #1845 // CSS @import can only appear at top of the file. We need to hoist all @import // to top when multiple files are concatenated. -async function hoistAtImports(css: string) { +// #6333 +// CSS @charset must be the top-first in the file, hoist to top too +async function hoistAtRules(css: string) { const postcss = await import('postcss') - return (await postcss.default([AtImportHoistPlugin]).process(css)).css + return (await postcss.default([AtRuleHoistPlugin]).process(css)).css } -const AtImportHoistPlugin: PostCSS.PluginCreator = () => { +const AtRuleHoistPlugin: PostCSS.PluginCreator = () => { return { - postcssPlugin: 'vite-hoist-at-imports', + postcssPlugin: 'vite-hoist-at-rules', Once(root) { const imports: PostCSS.AtRule[] = [] + let charset: PostCSS.AtRule | undefined root.walkAtRules((rule) => { if (rule.name === 'import') { // record in reverse so that can simply prepend to preserve order imports.unshift(rule) + } else if (!charset && rule.name === 'charset') { + charset = rule } }) imports.forEach((i) => root.prepend(i)) + if (charset) root.prepend(charset) } } } -AtImportHoistPlugin.postcss = true +AtRuleHoistPlugin.postcss = true // Preprocessor support. This logic is largely replicated from @vue/compiler-sfc From 9ed1672a4700a1d8f62f6606e38a3cd3946738f8 Mon Sep 17 00:00:00 2001 From: fishDog <40156382+Bigfish8@users.noreply.github.com> Date: Tue, 12 Apr 2022 02:50:24 +0800 Subject: [PATCH 023/175] fix: update watch mode (#7132) Co-authored-by: Bjorn Lu --- .../assets/__tests__/assets.spec.ts | 22 ++++++++++++++++++- packages/playground/assets/css/foo.module.css | 3 +++ packages/playground/assets/index.html | 10 +++++++++ packages/playground/assets/static/foo.txt | 1 + packages/vite/src/node/build.ts | 2 ++ packages/vite/src/node/plugins/ensureWatch.ts | 17 ++++++++++++++ packages/vite/src/node/plugins/index.ts | 3 +++ scripts/jestPerTestSetup.ts | 3 ++- 8 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 packages/playground/assets/css/foo.module.css create mode 100644 packages/playground/assets/static/foo.txt create mode 100644 packages/vite/src/node/plugins/ensureWatch.ts diff --git a/packages/playground/assets/__tests__/assets.spec.ts b/packages/playground/assets/__tests__/assets.spec.ts index f53c783c52b606..e08de24265e24a 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') }) } }) 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..b0ec76f5483b6f 100644 --- a/packages/playground/assets/index.html +++ b/packages/playground/assets/index.html @@ -212,6 +212,10 @@

@import

@import CSS from publicDir should load (this should be red)

+

import module css

+ +

+ @@ -268,6 +272,12 @@

document.querySelector('.import-meta-url-img-comma-nl').src = metaUrlWithCommaNL + import classNames from './css/foo.module.css' + document.querySelector('#foo').className = classNames['foo-module'] + + import someString from './static/foo.txt?raw' + document.querySelector('.raw-query').textContent = someString + const metaUrlNonExistent = new URL('non-existent', import.meta.url).pathname text('.non-existent-import-meta-url', metaUrlNonExistent) diff --git a/packages/playground/assets/static/foo.txt b/packages/playground/assets/static/foo.txt new file mode 100644 index 00000000000000..19102815663d23 --- /dev/null +++ b/packages/playground/assets/static/foo.txt @@ -0,0 +1 @@ +foo \ No newline at end of file diff --git a/packages/vite/src/node/build.ts b/packages/vite/src/node/build.ts index 3541cc377dc411..ff03352a20d7a7 100644 --- a/packages/vite/src/node/build.ts +++ b/packages/vite/src/node/build.ts @@ -39,6 +39,7 @@ import { getDepsCacheDir, findKnownImports } from './optimizer' import { assetImportMetaUrlPlugin } from './plugins/assetImportMetaUrl' import { loadFallbackPlugin } from './plugins/loadFallback' import { watchPackageDataPlugin } from './packages' +import { ensureWatchPlugin } from './plugins/ensureWatch' export interface BuildOptions { /** @@ -308,6 +309,7 @@ export function resolveBuildPlugins(config: ResolvedConfig): { return { pre: [ + ...(options.watch ? [ensureWatchPlugin()] : []), watchPackageDataPlugin(config), commonjsPlugin(options.commonjsOptions), dataURIPlugin(), diff --git a/packages/vite/src/node/plugins/ensureWatch.ts b/packages/vite/src/node/plugins/ensureWatch.ts new file mode 100644 index 00000000000000..30a6fb3d6df819 --- /dev/null +++ b/packages/vite/src/node/plugins/ensureWatch.ts @@ -0,0 +1,17 @@ +import type { Plugin } from '../plugin' +import { cleanUrl, queryRE } from '../utils' + +/** + * plugin to ensure rollup can watch correctly. + */ +export function ensureWatchPlugin(): Plugin { + return { + name: 'vite:ensure-watch', + load(id) { + if (queryRE.test(id)) { + this.addWatchFile(cleanUrl(id)) + } + return null + } + } +} diff --git a/packages/vite/src/node/plugins/index.ts b/packages/vite/src/node/plugins/index.ts index d294233b92ae17..2d34b99aebf1c5 100644 --- a/packages/vite/src/node/plugins/index.ts +++ b/packages/vite/src/node/plugins/index.ts @@ -17,6 +17,7 @@ import { preAliasPlugin } from './preAlias' import { definePlugin } from './define' import { ssrRequireHookPlugin } from './ssrRequireHook' import { workerImportMetaUrlPlugin } from './workerImportMetaUrl' +import { ensureWatchPlugin } from './ensureWatch' import { metadataPlugin } from './metadata' export async function resolvePlugins( @@ -26,12 +27,14 @@ export async function resolvePlugins( postPlugins: Plugin[] ): Promise { const isBuild = config.command === 'build' + const isWatch = isBuild && !!config.build.watch const buildPlugins = isBuild ? (await import('../build')).resolveBuildPlugins(config) : { pre: [], post: [] } return [ + isWatch ? ensureWatchPlugin() : null, isBuild ? metadataPlugin() : null, isBuild ? null : preAliasPlugin(), aliasPlugin({ entries: config.resolve.alias }), diff --git a/scripts/jestPerTestSetup.ts b/scripts/jestPerTestSetup.ts index 150c02eed5b76c..fcdca77ee9a6eb 100644 --- a/scripts/jestPerTestSetup.ts +++ b/scripts/jestPerTestSetup.ts @@ -175,6 +175,7 @@ afterAll(async () => { global.serverLogs = [] await global.page?.close() await server?.close() + global.watcher?.close() const beforeAllErr = getBeforeAllError() if (beforeAllErr) { throw beforeAllErr @@ -200,7 +201,7 @@ function startStaticServer(config?: InlineConfig): Promise { } // start static file server - const serve = sirv(resolve(rootDir, 'dist')) + const serve = sirv(resolve(rootDir, 'dist'), { dev: !!config?.build?.watch }) const httpServer = (server = http.createServer((req, res) => { if (req.url === '/ping') { res.statusCode = 200 From dfce28355c42d38425bc3374ed944ac324f50882 Mon Sep 17 00:00:00 2001 From: yoho Date: Tue, 12 Apr 2022 02:59:02 +0800 Subject: [PATCH 024/175] feat: clean string module lex string template (#7667) --- .../src/node/__tests__/cleanString.spec.ts | 52 ++++++++ packages/vite/src/node/cleanString.ts | 113 +++++++++++++++++- 2 files changed, 164 insertions(+), 1 deletion(-) diff --git a/packages/vite/src/node/__tests__/cleanString.spec.ts b/packages/vite/src/node/__tests__/cleanString.spec.ts index 883dc67abfe2f9..1065a2d4985ceb 100644 --- a/packages/vite/src/node/__tests__/cleanString.spec.ts +++ b/packages/vite/src/node/__tests__/cleanString.spec.ts @@ -106,3 +106,55 @@ test('find empty string flag in raw index', () => { const bStart = clean.indexOf('\0\0\0\0\0', bIndex) expect(str.slice(bStart, bStart + 5)).toMatch('bbbbb') }) + +test('template string nested', () => { + let str = '`aaaa`' + let res = '`\0\0\0\0`' + let clean = emptyString(str) + expect(clean).toMatch(res) + + str = '`aaaa` `aaaa`' + res = '`\0\0\0\0` `\0\0\0\0`' + clean = emptyString(str) + expect(clean).toMatch(res) + + str = '`aa${a}aa`' + res = '`\0\0${a}\0\0`' + clean = emptyString(str) + expect(clean).toMatch(res) + + str = '`aa${a + `a` + a}aa`' + res = '`\0\0${a + `\0` + a}\0\0`' + clean = emptyString(str) + expect(clean).toMatch(res) + + str = '`aa${a + `a` + a}aa` `aa${a + `a` + a}aa`' + res = '`\0\0${a + `\0` + a}\0\0` `\0\0${a + `\0` + a}\0\0`' + clean = emptyString(str) + expect(clean).toMatch(res) + + str = '`aa${a + `aaaa${c + (a = {b: 1}) + d}` + a}aa`' + res = '`\0\0${a + `\0\0\0\0${c + (a = {b: 1}) + d}` + a}\0\0`' + clean = emptyString(str) + expect(clean).toMatch(res) + + str = + '`aa${a + `aaaa${c + (a = {b: 1}) + d}` + a}aa` `aa${a + `aaaa${c + (a = {b: 1}) + d}` + a}aa`' + res = + '`\0\0${a + `\0\0\0\0${c + (a = {b: 1}) + d}` + a}\0\0` `\0\0${a + `\0\0\0\0${c + (a = {b: 1}) + d}` + a}\0\0`' + clean = emptyString(str) + expect(clean).toMatch(res) + + str = '`aaaa' + res = '' + try { + clean = emptyString(str) + } catch {} + expect(clean).toMatch(res) + + str = + "" + res = `` + clean = emptyString(str) + expect(clean).toMatch(res) +}) diff --git a/packages/vite/src/node/cleanString.ts b/packages/vite/src/node/cleanString.ts index d26274397124ff..05163ea055b631 100644 --- a/packages/vite/src/node/cleanString.ts +++ b/packages/vite/src/node/cleanString.ts @@ -1,3 +1,4 @@ +import type { RollupError } from 'rollup' // bank on the non-overlapping nature of regex matches and combine all filters into one giant regex // /`([^`\$\{\}]|\$\{(`|\g<1>)*\})*`/g can match nested string template // but js not support match expression(\g<0>). so clean string template(`...`) in other ways. @@ -8,7 +9,117 @@ const stringBlankReplacer = (s: string) => `${s[0]}${'\0'.repeat(s.length - 2)}${s[0]}` export function emptyString(raw: string): string { - return raw.replace(cleanerRE, (s: string) => + let res = raw.replace(cleanerRE, (s: string) => s[0] === '/' ? blankReplacer(s) : stringBlankReplacer(s) ) + + let lastEnd = 0 + let start = 0 + while ((start = res.indexOf('`', lastEnd)) >= 0) { + let clean + ;[clean, lastEnd] = lexStringTemplateExpression(res, start) + res = replaceAt(res, start, lastEnd, clean) + } + + return res +} + +const enum LexerState { + inTemplateString, + inInterpolationExpression, + inObjectExpression +} + +function replaceAt( + string: string, + start: number, + end: number, + replacement: string +): string { + return string.slice(0, start) + replacement + string.slice(end) +} + +/** + * lex string template and clean it. + */ +function lexStringTemplateExpression( + code: string, + start: number +): [string, number] { + let state = LexerState.inTemplateString as LexerState + let clean = '`' + const opStack: LexerState[] = [state] + + function pushStack(newState: LexerState) { + state = newState + opStack.push(state) + } + + function popStack() { + opStack.pop() + state = opStack[opStack.length - 1] + } + + let i = start + 1 + outer: for (; i < code.length; i++) { + const char = code.charAt(i) + switch (state) { + case LexerState.inTemplateString: + if (char === '$' && code.charAt(i + 1) === '{') { + pushStack(LexerState.inInterpolationExpression) + clean += '${' + i++ // jump next + } else if (char === '`') { + popStack() + clean += char + if (opStack.length === 0) { + break outer + } + } else { + clean += '\0' + } + break + case LexerState.inInterpolationExpression: + if (char === '{') { + pushStack(LexerState.inObjectExpression) + clean += char + } else if (char === '}') { + popStack() + clean += char + } else if (char === '`') { + pushStack(LexerState.inTemplateString) + clean += char + } else { + clean += char + } + break + case LexerState.inObjectExpression: + if (char === '}') { + popStack() + clean += char + } else if (char === '`') { + pushStack(LexerState.inTemplateString) + clean += char + } else { + clean += char + } + break + default: + throw new Error('unknown string template lexer state') + } + } + + if (opStack.length !== 0) { + error(start) + } + + return [clean, i + 1] +} + +function error(pos: number) { + const err = new Error( + `can not match string template expression.` + ) as RollupError + err.pos = pos + throw err } From 66b6dc508086a4ab75af4dacc849c50a58c7aebc Mon Sep 17 00:00:00 2001 From: Rom Date: Tue, 12 Apr 2022 06:40:07 +0200 Subject: [PATCH 025/175] fix: `$ vite preview` 404 handling (#7665) --- packages/vite/src/node/preview.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/vite/src/node/preview.ts b/packages/vite/src/node/preview.ts index c00f62a9cb8f0c..23b905fd01a719 100644 --- a/packages/vite/src/node/preview.ts +++ b/packages/vite/src/node/preview.ts @@ -1,4 +1,5 @@ import path from 'path' +import fs from 'fs' import sirv from 'sirv' import connect from 'connect' import compression from './server/middlewares/compression' @@ -90,11 +91,20 @@ export async function preview( config.base, sirv(distDir, { etag: true, - dev: true, - single: true + dev: true }) ) + app.use(config.base, (_, res, next) => { + const file = path.join(distDir, './404.html') + if (fs.existsSync(file)) { + res.statusCode = 404 + res.end(fs.readFileSync(file)) + } else { + next() + } + }) + const options = config.preview const hostname = resolveHostname(options.host) const port = options.port ?? 4173 From 0c928aa079df5060c5bc7a745a128be62fd86cd2 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Tue, 12 Apr 2022 17:29:25 +0800 Subject: [PATCH 026/175] refactor: esbuild handles `target` and `useDefineForClassFields` (#7698) --- packages/vite/src/node/plugins/esbuild.ts | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/packages/vite/src/node/plugins/esbuild.ts b/packages/vite/src/node/plugins/esbuild.ts index db216c7d6b0d77..c982b4e61f30c8 100644 --- a/packages/vite/src/node/plugins/esbuild.ts +++ b/packages/vite/src/node/plugins/esbuild.ts @@ -81,6 +81,7 @@ export async function transformWithEsbuild( // these fields would affect the compilation result // https://esbuild.github.io/content-types/#tsconfig-json const meaningfulFields: Array = [ + 'target', 'jsxFactory', 'jsxFragmentFactory', 'useDefineForClassFields', @@ -98,17 +99,9 @@ export async function transformWithEsbuild( compilerOptionsForFile[field] = loadedCompilerOptions[field] } } - - // align with TypeScript 4.3 - // https://github.com/microsoft/TypeScript/pull/42663 - if (loadedCompilerOptions.target?.toLowerCase() === 'esnext') { - compilerOptionsForFile.useDefineForClassFields = - loadedCompilerOptions.useDefineForClassFields ?? true - } } tsconfigRaw = { - ...tsconfigRaw, compilerOptions: { ...compilerOptionsForFile, ...tsconfigRaw?.compilerOptions From 8f28350291dde55e9d20b05f124b53867bcaf8e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Tue, 12 Apr 2022 18:32:02 +0900 Subject: [PATCH 027/175] chore(create-vite): add isolatedModules (#7697) --- packages/create-vite/template-lit-ts/tsconfig.json | 1 + packages/create-vite/template-svelte-ts/tsconfig.json | 3 ++- packages/create-vite/template-vanilla-ts/tsconfig.json | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) 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-svelte-ts/tsconfig.json b/packages/create-vite/template-svelte-ts/tsconfig.json index 4d6c04cf0ab13b..96bfd81aaf1203 100644 --- a/packages/create-vite/template-svelte-ts/tsconfig.json +++ b/packages/create-vite/template-svelte-ts/tsconfig.json @@ -13,7 +13,8 @@ * of JS in `.svelte` files. */ "allowJs": true, - "checkJs": true + "checkJs": true, + "isolatedModules": true }, "include": ["src/**/*.d.ts", "src/**/*.ts", "src/**/*.js", "src/**/*.svelte"], "references": [{ "path": "./tsconfig.node.json" }] diff --git a/packages/create-vite/template-vanilla-ts/tsconfig.json b/packages/create-vite/template-vanilla-ts/tsconfig.json index 1885c8f9b00106..05f80b91398b98 100644 --- a/packages/create-vite/template-vanilla-ts/tsconfig.json +++ b/packages/create-vite/template-vanilla-ts/tsconfig.json @@ -8,6 +8,7 @@ "strict": true, "sourceMap": true, "resolveJsonModule": true, + "isolatedModules": true, "esModuleInterop": true, "noEmit": true, "noUnusedLocals": true, From 7e6a2c8f7d140186576b9492639f462b3eb99e12 Mon Sep 17 00:00:00 2001 From: patak-dev Date: Tue, 12 Apr 2022 14:54:15 +0200 Subject: [PATCH 028/175] chore: revert removed line in #7698 --- packages/vite/src/node/plugins/esbuild.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/vite/src/node/plugins/esbuild.ts b/packages/vite/src/node/plugins/esbuild.ts index c982b4e61f30c8..9e8bae24424d76 100644 --- a/packages/vite/src/node/plugins/esbuild.ts +++ b/packages/vite/src/node/plugins/esbuild.ts @@ -102,6 +102,7 @@ export async function transformWithEsbuild( } tsconfigRaw = { + ...tsconfigRaw, compilerOptions: { ...compilerOptionsForFile, ...tsconfigRaw?.compilerOptions From 88581807cce75bbb104ef4c1cb3dd483b748d3fd Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Tue, 12 Apr 2022 21:52:50 +0800 Subject: [PATCH 029/175] perf(css): hoist at rules with regex (#7691) --- .../src/node/__tests__/plugins/css.spec.ts | 36 +++++++++++++- packages/vite/src/node/plugins/css.ts | 48 ++++++++----------- 2 files changed, 55 insertions(+), 29 deletions(-) diff --git a/packages/vite/src/node/__tests__/plugins/css.spec.ts b/packages/vite/src/node/__tests__/plugins/css.spec.ts index 539ec2f1af1810..9b652a563ccb0a 100644 --- a/packages/vite/src/node/__tests__/plugins/css.spec.ts +++ b/packages/vite/src/node/__tests__/plugins/css.spec.ts @@ -1,4 +1,4 @@ -import { cssUrlRE, cssPlugin } from '../../plugins/css' +import { cssUrlRE, cssPlugin, hoistAtRules } from '../../plugins/css' import { resolveConfig } from '../../config' import fs from 'fs' import path from 'path' @@ -114,3 +114,37 @@ describe('css path resolutions', () => { mockFs.mockReset() }) }) + +describe('hoist @ rules', () => { + test('hoist @import', async () => { + const css = `.foo{color:red;}@import "bla";` + const result = await hoistAtRules(css) + expect(result).toBe(`@import "bla";.foo{color:red;}`) + }) + + test('hoist @import with semicolon in quotes', async () => { + const css = `.foo{color:red;}@import "bla;bar";` + const result = await hoistAtRules(css) + expect(result).toBe(`@import "bla;bar";.foo{color:red;}`) + }) + + test('hoist @charset', async () => { + const css = `.foo{color:red;}@charset "utf-8";` + const result = await hoistAtRules(css) + expect(result).toBe(`@charset "utf-8";.foo{color:red;}`) + }) + + test('hoist one @charset only', async () => { + const css = `.foo{color:red;}@charset "utf-8";@charset "utf-8";` + const result = await hoistAtRules(css) + expect(result).toBe(`@charset "utf-8";.foo{color:red;}`) + }) + + test('hoist @import and @charset', async () => { + const css = `.foo{color:red;}@import "bla";@charset "utf-8";.bar{color:grren;}@import "baz";` + const result = await hoistAtRules(css) + expect(result).toBe( + `@charset "utf-8";@import "bla";@import "baz";.foo{color:red;}.bar{color:grren;}` + ) + }) +}) diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index adef254950c5e5..08bdfbeed4e616 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -1106,36 +1106,28 @@ async function minifyCSS(css: string, config: ResolvedConfig) { return code } -// #1845 -// CSS @import can only appear at top of the file. We need to hoist all @import -// to top when multiple files are concatenated. -// #6333 -// CSS @charset must be the top-first in the file, hoist to top too -async function hoistAtRules(css: string) { - const postcss = await import('postcss') - return (await postcss.default([AtRuleHoistPlugin]).process(css)).css -} - -const AtRuleHoistPlugin: PostCSS.PluginCreator = () => { - return { - postcssPlugin: 'vite-hoist-at-rules', - Once(root) { - const imports: PostCSS.AtRule[] = [] - let charset: PostCSS.AtRule | undefined - root.walkAtRules((rule) => { - if (rule.name === 'import') { - // record in reverse so that can simply prepend to preserve order - imports.unshift(rule) - } else if (!charset && rule.name === 'charset') { - charset = rule - } - }) - imports.forEach((i) => root.prepend(i)) - if (charset) root.prepend(charset) +export async function hoistAtRules(css: string) { + const s = new MagicString(css) + // #1845 + // CSS @import can only appear at top of the file. We need to hoist all @import + // to top when multiple files are concatenated. + // match until semicolon that's not in quotes + s.replace(/@import\s*(?:"[^"]*"|'[^']*'|[^;]*).*?;/gm, (match) => { + s.appendLeft(0, match) + return '' + }) + // #6333 + // CSS @charset must be the top-first in the file, hoist the first to top + let foundCharset = false + s.replace(/@charset\s*(?:"[^"]*"|'[^']*'|[^;]*).*?;/gm, (match) => { + if (!foundCharset) { + s.prepend(match) + foundCharset = true } - } + return '' + }) + return s.toString() } -AtRuleHoistPlugin.postcss = true // Preprocessor support. This logic is largely replicated from @vue/compiler-sfc From 23fdef1dec68ff5552f140659e83a18dc8b0b060 Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Tue, 12 Apr 2022 23:23:44 +0800 Subject: [PATCH 030/175] chore: type unknown env as any (#7702) --- docs/guide/env-and-mode.md | 2 +- packages/vite/types/importMeta.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/guide/env-and-mode.md b/docs/guide/env-and-mode.md index 1649feda8c7501..b2b1264e85a8e4 100644 --- a/docs/guide/env-and-mode.md +++ b/docs/guide/env-and-mode.md @@ -42,7 +42,7 @@ In addition, environment variables that already exist when Vite is executed have `.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: diff --git a/packages/vite/types/importMeta.d.ts b/packages/vite/types/importMeta.d.ts index 9b57fd120a7ba9..900b975d37d6ad 100644 --- a/packages/vite/types/importMeta.d.ts +++ b/packages/vite/types/importMeta.d.ts @@ -36,7 +36,7 @@ interface ImportMeta { } interface ImportMetaEnv { - [key: string]: string | boolean | undefined + [key: string]: any BASE_URL: string MODE: string DEV: boolean From 7ddbf96ae11bf0eeef97ffc00dcf5ac4c561cc20 Mon Sep 17 00:00:00 2001 From: yoho Date: Tue, 12 Apr 2022 23:25:37 +0800 Subject: [PATCH 031/175] feat: explicit the word boundary (#6876) --- .../assets/__tests__/assets.spec.ts | 7 +++++++ packages/playground/assets/index.html | 19 +++++++++++++++++ packages/vite/src/node/plugins/html.ts | 21 ++++++++++++------- 3 files changed, 40 insertions(+), 7 deletions(-) diff --git a/packages/playground/assets/__tests__/assets.spec.ts b/packages/playground/assets/__tests__/assets.spec.ts index e08de24265e24a..75c0e57952db24 100644 --- a/packages/playground/assets/__tests__/assets.spec.ts +++ b/packages/playground/assets/__tests__/assets.spec.ts @@ -307,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/index.html b/packages/playground/assets/index.html index b0ec76f5483b6f..6678a2da7c2106 100644 --- a/packages/playground/assets/index.html +++ b/packages/playground/assets/index.html @@ -176,9 +176,28 @@

new URL(`non-existent`, import.meta.url)

simple script tag import-expression

+ +

url in style tag

url

diff --git a/packages/vite/src/node/plugins/html.ts b/packages/vite/src/node/plugins/html.ts index 25ad91582140c3..5c86b6c0ac6073 100644 --- a/packages/vite/src/node/plugins/html.ts +++ b/packages/vite/src/node/plugins/html.ts @@ -35,6 +35,7 @@ import type { TextNode } from '@vue/compiler-dom' import { NodeTypes } from '@vue/compiler-dom' +import { emptyString } from '../cleanString' interface ScriptAssetsUrl { start: number @@ -44,8 +45,9 @@ interface ScriptAssetsUrl { const htmlProxyRE = /\?html-proxy=?[&inline\-css]*&index=(\d+)\.(js|css)$/ const inlineCSSRE = /__VITE_INLINE_CSS__([^_]+_\d+)__/g +// Do not allow preceding '.', but do allow preceding '...' for spread operations +const inlineImportRE = /(? htmlProxyRE.test(id) @@ -303,14 +305,19 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin { } } else if (node.children.length) { const scriptNode = node.children.pop()! as TextNode - const code = scriptNode.content + const cleanCode = emptyString(scriptNode.content) + let match: RegExpExecArray | null - while ((match = inlineImportRE.exec(code))) { - const { 0: full, 1: url, index } = match - const startUrl = full.indexOf(url) - const start = scriptNode.loc.start.offset + index + startUrl + 1 + while ((match = inlineImportRE.exec(cleanCode))) { + const { 1: url, index } = match + const startUrl = cleanCode.indexOf(url, index) + const start = startUrl + 1 const end = start + url.length - 2 - scriptUrls.push({ start, end, url: url.slice(1, -1) }) + scriptUrls.push({ + start: start + scriptNode.loc.start.offset, + end: end + scriptNode.loc.start.offset, + url: scriptNode.content.slice(start, end) + }) } } } From 83d32d965e3abd78fe390e347923e68dfb6de773 Mon Sep 17 00:00:00 2001 From: Rongjian Zhang Date: Wed, 13 Apr 2022 02:50:19 +0800 Subject: [PATCH 032/175] fix: default value of assetsDir option (#7703) --- packages/vite/src/node/cli.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vite/src/node/cli.ts b/packages/vite/src/node/cli.ts index 9cec6ebd9cfd68..89412a825e9fc1 100644 --- a/packages/vite/src/node/cli.ts +++ b/packages/vite/src/node/cli.ts @@ -130,7 +130,7 @@ cli .option('--outDir ', `[string] output directory (default: dist)`) .option( '--assetsDir ', - `[string] directory under outDir to place assets in (default: _assets)` + `[string] directory under outDir to place assets in (default: assets)` ) .option( '--assetsInlineLimit ', From 48e038cc53d609120ffcb0b04c2a6e24cfdebb7b Mon Sep 17 00:00:00 2001 From: patak Date: Wed, 13 Apr 2022 06:34:32 +0200 Subject: [PATCH 033/175] feat: optimizeDeps.disabled (#7646) --- packages/playground/vue-jsx/vite.config.js | 3 ++- packages/vite/src/node/config.ts | 15 ++++++++++----- packages/vite/src/node/optimizer/index.ts | 6 ++++++ packages/vite/src/node/server/index.ts | 10 ++++++++-- 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/packages/playground/vue-jsx/vite.config.js b/packages/playground/vue-jsx/vite.config.js index d6eb84e05f4e4a..4c7370a0ce4787 100644 --- a/packages/playground/vue-jsx/vite.config.js +++ b/packages/playground/vue-jsx/vite.config.js @@ -35,5 +35,6 @@ export default defineComponent(() => { build: { // to make tests faster minify: false - } + }, + optimizeDeps: false } diff --git a/packages/vite/src/node/config.ts b/packages/vite/src/node/config.ts index 9910cbb3a8b004..b02ac6e496593e 100644 --- a/packages/vite/src/node/config.ts +++ b/packages/vite/src/node/config.ts @@ -145,8 +145,10 @@ export interface UserConfig { preview?: PreviewOptions /** * Dep optimization options + * + * false disables optimization completely (experimental) */ - optimizeDeps?: DepOptimizationOptions + optimizeDeps?: DepOptimizationOptions | false /** * SSR specific options * @alpha @@ -463,6 +465,8 @@ export async function resolveConfig( const server = resolveServerOptions(resolvedRoot, config.server) + const optimizeDeps = config.optimizeDeps || {} + const resolved: ResolvedConfig = { ...config, configFile: configFile ? normalizePath(configFile) : undefined, @@ -497,11 +501,12 @@ export async function resolveConfig( packageCache: new Map(), createResolver, optimizeDeps: { - ...config.optimizeDeps, + disabled: config.optimizeDeps === false, + ...optimizeDeps, esbuildOptions: { - keepNames: config.optimizeDeps?.keepNames, + keepNames: optimizeDeps.keepNames, preserveSymlinks: config.resolve?.preserveSymlinks, - ...config.optimizeDeps?.esbuildOptions + ...optimizeDeps.esbuildOptions } }, worker: resolvedWorkerOptions @@ -605,7 +610,7 @@ export async function resolveConfig( } }) - if (config.optimizeDeps?.keepNames) { + if (optimizeDeps.keepNames) { logDeprecationWarning( 'optimizeDeps.keepNames', 'Use "optimizeDeps.esbuildOptions.keepNames" instead.' diff --git a/packages/vite/src/node/optimizer/index.ts b/packages/vite/src/node/optimizer/index.ts index 88c41801938b98..13c322610cf493 100644 --- a/packages/vite/src/node/optimizer/index.ts +++ b/packages/vite/src/node/optimizer/index.ts @@ -101,6 +101,12 @@ export interface DepOptimizationOptions { * @experimental */ extensions?: string[] + /** + * Disables dependencies optimizations + * @default false + * @experimental + */ + disabled?: boolean } export interface DepOptimizationResult { diff --git a/packages/vite/src/node/server/index.ts b/packages/vite/src/node/server/index.ts index de80ac1147ff0f..bf13ba683a9b93 100644 --- a/packages/vite/src/node/server/index.ts +++ b/packages/vite/src/node/server/index.ts @@ -571,6 +571,12 @@ export async function createServer( // error handler middlewares.use(errorMiddleware(server, !!middlewareMode)) + const initOptimizer = () => { + if (!config.optimizeDeps.disabled) { + server._optimizedDeps = createOptimizedDeps(server) + } + } + if (!middlewareMode && httpServer) { let isOptimized = false // overwrite listen to init optimizer before server start @@ -579,7 +585,7 @@ export async function createServer( if (!isOptimized) { try { await container.buildStart({}) - server._optimizedDeps = createOptimizedDeps(server) + initOptimizer() isOptimized = true } catch (e) { httpServer.emit('error', e) @@ -590,7 +596,7 @@ export async function createServer( }) as any } else { await container.buildStart({}) - server._optimizedDeps = createOptimizedDeps(server) + initOptimizer() } return server From d6830e3d70b693945113b7504b25be8a18b27815 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Wed, 13 Apr 2022 12:36:35 +0800 Subject: [PATCH 034/175] fix(ssr): properly transform export default with expressions (#7705) --- .../node/ssr/__tests__/ssrTransform.spec.ts | 23 +++++++++++++++++++ packages/vite/src/node/ssr/ssrTransform.ts | 7 +++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/packages/vite/src/node/ssr/__tests__/ssrTransform.spec.ts b/packages/vite/src/node/ssr/__tests__/ssrTransform.spec.ts index e086365ee25f16..a5f915edea97fd 100644 --- a/packages/vite/src/node/ssr/__tests__/ssrTransform.spec.ts +++ b/packages/vite/src/node/ssr/__tests__/ssrTransform.spec.ts @@ -657,3 +657,26 @@ export function fn1() { " `) }) + +// https://github.com/vitest-dev/vitest/issues/1141 +test('export default expression', async () => { + // esbuild transform result of following TS code + // export default function getRandom() { + // return Math.random() + // } + const code = ` +export default (function getRandom() { + return Math.random(); +}); +`.trim() + + expect((await ssrTransform(code, null, null)).code).toMatchInlineSnapshot(` + "__vite_ssr_exports__.default = (function getRandom() { + return Math.random(); + });" + `) + + expect( + (await ssrTransform(`export default (class A {});`, null, null)).code + ).toMatchInlineSnapshot(`"__vite_ssr_exports__.default = (class A {});"`) +}) diff --git a/packages/vite/src/node/ssr/ssrTransform.ts b/packages/vite/src/node/ssr/ssrTransform.ts index 56b75f8dd14913..79ccd25f9ca8ff 100644 --- a/packages/vite/src/node/ssr/ssrTransform.ts +++ b/packages/vite/src/node/ssr/ssrTransform.ts @@ -143,7 +143,12 @@ export async function ssrTransform( // default export if (node.type === 'ExportDefaultDeclaration') { - if ('id' in node.declaration && node.declaration.id) { + const expressionTypes = ['FunctionExpression', 'ClassExpression'] + if ( + 'id' in node.declaration && + node.declaration.id && + !expressionTypes.includes(node.declaration.type) + ) { // named hoistable/class exports // export default function foo() {} // export default class A {} From ba9a1ffe9ea5414d6e232a7ded9d341014a4e726 Mon Sep 17 00:00:00 2001 From: patak Date: Wed, 13 Apr 2022 15:32:15 +0200 Subject: [PATCH 035/175] fix: revert optimizeDeps false, keep optimizedDeps.disabled (#7715) --- packages/playground/vue-jsx/vite.config.js | 4 +++- packages/vite/src/node/config.ts | 5 +---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/playground/vue-jsx/vite.config.js b/packages/playground/vue-jsx/vite.config.js index 4c7370a0ce4787..2f4ea255c95094 100644 --- a/packages/playground/vue-jsx/vite.config.js +++ b/packages/playground/vue-jsx/vite.config.js @@ -36,5 +36,7 @@ export default defineComponent(() => { // to make tests faster minify: false }, - optimizeDeps: false + optimizeDeps: { + disabled: true + } } diff --git a/packages/vite/src/node/config.ts b/packages/vite/src/node/config.ts index b02ac6e496593e..f633d1158bfa95 100644 --- a/packages/vite/src/node/config.ts +++ b/packages/vite/src/node/config.ts @@ -145,10 +145,8 @@ export interface UserConfig { preview?: PreviewOptions /** * Dep optimization options - * - * false disables optimization completely (experimental) */ - optimizeDeps?: DepOptimizationOptions | false + optimizeDeps?: DepOptimizationOptions /** * SSR specific options * @alpha @@ -501,7 +499,6 @@ export async function resolveConfig( packageCache: new Map(), createResolver, optimizeDeps: { - disabled: config.optimizeDeps === false, ...optimizeDeps, esbuildOptions: { keepNames: optimizeDeps.keepNames, From f699afb9531201dc24566821fcab55d3e70a2708 Mon Sep 17 00:00:00 2001 From: patak-dev Date: Wed, 13 Apr 2022 15:47:32 +0200 Subject: [PATCH 036/175] release: v2.9.2 --- packages/vite/CHANGELOG.md | 32 ++++++++++++++++++++++++++++++++ packages/vite/package.json | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/packages/vite/CHANGELOG.md b/packages/vite/CHANGELOG.md index 0f91a004602caa..b011910c8615cc 100644 --- a/packages/vite/CHANGELOG.md +++ b/packages/vite/CHANGELOG.md @@ -1,3 +1,35 @@ +## 2.9.2 (2022-04-13) + +* fix: `$ vite preview` 404 handling (#7665) ([66b6dc5](https://github.com/vitejs/vite/commit/66b6dc5)), closes [#7665](https://github.com/vitejs/vite/issues/7665) +* fix: build should also respect esbuild=false config (#7602) ([2dc0e80](https://github.com/vitejs/vite/commit/2dc0e80)), closes [#7602](https://github.com/vitejs/vite/issues/7602) +* fix: default value of assetsDir option (#7703) ([83d32d9](https://github.com/vitejs/vite/commit/83d32d9)), closes [#7703](https://github.com/vitejs/vite/issues/7703) +* fix: detect env hmr (#7595) ([212d454](https://github.com/vitejs/vite/commit/212d454)), closes [#7595](https://github.com/vitejs/vite/issues/7595) +* fix: EACCES permission denied due to resolve new paths default (#7612) ([1dd019f](https://github.com/vitejs/vite/commit/1dd019f)), closes [#7612](https://github.com/vitejs/vite/issues/7612) +* fix: fix HMR propagation when imports not analyzed (#7561) ([57e7914](https://github.com/vitejs/vite/commit/57e7914)), closes [#7561](https://github.com/vitejs/vite/issues/7561) +* fix: nested comments and strings, new regexp utils (#7650) ([93900f0](https://github.com/vitejs/vite/commit/93900f0)), closes [#7650](https://github.com/vitejs/vite/issues/7650) +* fix: revert optimizeDeps false, keep optimizedDeps.disabled (#7715) ([ba9a1ff](https://github.com/vitejs/vite/commit/ba9a1ff)), closes [#7715](https://github.com/vitejs/vite/issues/7715) +* fix: update watch mode (#7132) ([9ed1672](https://github.com/vitejs/vite/commit/9ed1672)), closes [#7132](https://github.com/vitejs/vite/issues/7132) +* fix: update ws types (#7605) ([b620587](https://github.com/vitejs/vite/commit/b620587)), closes [#7605](https://github.com/vitejs/vite/issues/7605) +* fix: use correct proxy config in preview (#7604) ([cf59005](https://github.com/vitejs/vite/commit/cf59005)), closes [#7604](https://github.com/vitejs/vite/issues/7604) +* fix(css): hoist charset (#7678) ([29e622c](https://github.com/vitejs/vite/commit/29e622c)), closes [#7678](https://github.com/vitejs/vite/issues/7678) +* fix(css): include inline css module in bundle (#7591) ([45b9273](https://github.com/vitejs/vite/commit/45b9273)), closes [#7591](https://github.com/vitejs/vite/issues/7591) +* fix(deps): update all non-major dependencies (#7668) ([485263c](https://github.com/vitejs/vite/commit/485263c)), closes [#7668](https://github.com/vitejs/vite/issues/7668) +* fix(less): handles rewriting relative paths passed Less's `data-uri` function. (#7400) ([08e39b7](https://github.com/vitejs/vite/commit/08e39b7)), closes [#7400](https://github.com/vitejs/vite/issues/7400) +* fix(resolver): skip known ESM entries when resolving a `require` call (#7582) ([5d6ea8e](https://github.com/vitejs/vite/commit/5d6ea8e)), closes [#7582](https://github.com/vitejs/vite/issues/7582) +* fix(ssr): properly transform export default with expressions (#7705) ([d6830e3](https://github.com/vitejs/vite/commit/d6830e3)), closes [#7705](https://github.com/vitejs/vite/issues/7705) +* feat: clean string module lex string template (#7667) ([dfce283](https://github.com/vitejs/vite/commit/dfce283)), closes [#7667](https://github.com/vitejs/vite/issues/7667) +* feat: explicit the word boundary (#6876) ([7ddbf96](https://github.com/vitejs/vite/commit/7ddbf96)), closes [#6876](https://github.com/vitejs/vite/issues/6876) +* feat: optimizeDeps.disabled (#7646) ([48e038c](https://github.com/vitejs/vite/commit/48e038c)), closes [#7646](https://github.com/vitejs/vite/issues/7646) +* chore: fix term cases (#7553) ([c296130](https://github.com/vitejs/vite/commit/c296130)), closes [#7553](https://github.com/vitejs/vite/issues/7553) +* chore: revert removed line in #7698 ([7e6a2c8](https://github.com/vitejs/vite/commit/7e6a2c8)), closes [#7698](https://github.com/vitejs/vite/issues/7698) +* chore: type unknown env as any (#7702) ([23fdef1](https://github.com/vitejs/vite/commit/23fdef1)), closes [#7702](https://github.com/vitejs/vite/issues/7702) +* chore(deps): update all non-major dependencies (#7603) ([fc51a15](https://github.com/vitejs/vite/commit/fc51a15)), closes [#7603](https://github.com/vitejs/vite/issues/7603) +* perf(css): hoist at rules with regex (#7691) ([8858180](https://github.com/vitejs/vite/commit/8858180)), closes [#7691](https://github.com/vitejs/vite/issues/7691) +* refactor: esbuild handles `target` and `useDefineForClassFields` (#7698) ([0c928aa](https://github.com/vitejs/vite/commit/0c928aa)), closes [#7698](https://github.com/vitejs/vite/issues/7698) +* docs: update release notes (#7563) ([a74bd7b](https://github.com/vitejs/vite/commit/a74bd7b)), closes [#7563](https://github.com/vitejs/vite/issues/7563) + + + ## 2.9.1 (2022-03-31) * fix: allow port 0 to be provided to server (#7530) ([173e4c9](https://github.com/vitejs/vite/commit/173e4c9)), closes [#7530](https://github.com/vitejs/vite/issues/7530) diff --git a/packages/vite/package.json b/packages/vite/package.json index adf73956a5c33a..1a749f662be43a 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -1,6 +1,6 @@ { "name": "vite", - "version": "2.9.1", + "version": "2.9.2", "license": "MIT", "author": "Evan You", "description": "Native-ESM powered web dev build tool", From 720e73c5f507eb3c142c53e4bc2e3d025e9a9f8a Mon Sep 17 00:00:00 2001 From: patak-dev Date: Wed, 13 Apr 2022 15:49:07 +0200 Subject: [PATCH 037/175] release: plugin-vue-jsx@1.3.10 --- packages/plugin-vue-jsx/CHANGELOG.md | 6 ++++++ packages/plugin-vue-jsx/package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/plugin-vue-jsx/CHANGELOG.md b/packages/plugin-vue-jsx/CHANGELOG.md index 3a1b9e681b45ea..94effd95f316b6 100644 --- a/packages/plugin-vue-jsx/CHANGELOG.md +++ b/packages/plugin-vue-jsx/CHANGELOG.md @@ -1,3 +1,9 @@ +## 1.3.10 (2022-04-13) + +* fix(deps): update all non-major dependencies (#7668) ([485263c](https://github.com/vitejs/vite/commit/485263c)), closes [#7668](https://github.com/vitejs/vite/issues/7668) + + + ## 1.3.9 (2022-03-30) * fix(deps): update all non-major dependencies (#7392) ([b63fc3b](https://github.com/vitejs/vite/commit/b63fc3b)), closes [#7392](https://github.com/vitejs/vite/issues/7392) diff --git a/packages/plugin-vue-jsx/package.json b/packages/plugin-vue-jsx/package.json index d8057b91f8ab24..151d0a71ce648c 100644 --- a/packages/plugin-vue-jsx/package.json +++ b/packages/plugin-vue-jsx/package.json @@ -1,6 +1,6 @@ { "name": "@vitejs/plugin-vue-jsx", - "version": "1.3.9", + "version": "1.3.10", "license": "MIT", "author": "Evan You", "files": [ From 070321bd6d38cee05e9ab4a96fc3a06d07f699ea Mon Sep 17 00:00:00 2001 From: patak-dev Date: Wed, 13 Apr 2022 15:51:10 +0200 Subject: [PATCH 038/175] release: plugin-react@1.3.1 --- packages/plugin-react/CHANGELOG.md | 8 ++++++++ packages/plugin-react/package.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/plugin-react/CHANGELOG.md b/packages/plugin-react/CHANGELOG.md index c05c0989d6beb4..958c8270b6f221 100644 --- a/packages/plugin-react/CHANGELOG.md +++ b/packages/plugin-react/CHANGELOG.md @@ -1,3 +1,11 @@ +## 1.3.1 (2022-04-13) + +* fix(deps): update all non-major dependencies (#7668) ([485263c](https://github.com/vitejs/vite/commit/485263c)), closes [#7668](https://github.com/vitejs/vite/issues/7668) +* chore: fix term cases (#7553) ([c296130](https://github.com/vitejs/vite/commit/c296130)), closes [#7553](https://github.com/vitejs/vite/issues/7553) +* chore(deps): update all non-major dependencies (#7603) ([fc51a15](https://github.com/vitejs/vite/commit/fc51a15)), closes [#7603](https://github.com/vitejs/vite/issues/7603) + + + ## 1.3.0 (2022-03-30) * feat(plugin-react): adding jsxPure option (#7088) ([d451435](https://github.com/vitejs/vite/commit/d451435)), closes [#7088](https://github.com/vitejs/vite/issues/7088) diff --git a/packages/plugin-react/package.json b/packages/plugin-react/package.json index e7fc9544120b11..6608eef784fa22 100644 --- a/packages/plugin-react/package.json +++ b/packages/plugin-react/package.json @@ -1,6 +1,6 @@ { "name": "@vitejs/plugin-react", - "version": "1.3.0", + "version": "1.3.1", "license": "MIT", "author": "Evan You", "contributors": [ From e7ea19ad2204a12fadc37f5ecd6ab0eea2d23373 Mon Sep 17 00:00:00 2001 From: patak-dev Date: Wed, 13 Apr 2022 15:52:05 +0200 Subject: [PATCH 039/175] release: plugin-legacy@1.8.1 --- packages/plugin-legacy/CHANGELOG.md | 7 +++++++ packages/plugin-legacy/package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/plugin-legacy/CHANGELOG.md b/packages/plugin-legacy/CHANGELOG.md index ced87d2efd665c..5c00212554ce8c 100644 --- a/packages/plugin-legacy/CHANGELOG.md +++ b/packages/plugin-legacy/CHANGELOG.md @@ -1,3 +1,10 @@ +## 1.8.1 (2022-04-13) + +* fix(deps): update all non-major dependencies (#7668) ([485263c](https://github.com/vitejs/vite/commit/485263c)), closes [#7668](https://github.com/vitejs/vite/issues/7668) +* docs(legacy): note works in build only (#7596) ([f26b14a](https://github.com/vitejs/vite/commit/f26b14a)), closes [#7596](https://github.com/vitejs/vite/issues/7596) + + + ## 1.8.0 (2022-03-30) * fix(deps): update all non-major dependencies (#6782) ([e38be3e](https://github.com/vitejs/vite/commit/e38be3e)), closes [#6782](https://github.com/vitejs/vite/issues/6782) diff --git a/packages/plugin-legacy/package.json b/packages/plugin-legacy/package.json index eb974d790f1e71..4c6783abc04bc8 100644 --- a/packages/plugin-legacy/package.json +++ b/packages/plugin-legacy/package.json @@ -1,6 +1,6 @@ { "name": "@vitejs/plugin-legacy", - "version": "1.8.0", + "version": "1.8.1", "license": "MIT", "author": "Evan You", "files": [ From adacaba1cf03256cf18a3494b4d7b053605d4a46 Mon Sep 17 00:00:00 2001 From: patak-dev Date: Wed, 13 Apr 2022 15:53:05 +0200 Subject: [PATCH 040/175] release: create-vite@2.9.1 --- packages/create-vite/CHANGELOG.md | 10 ++++++++++ packages/create-vite/package.json | 2 +- packages/create-vite/template-lit-ts/package.json | 2 +- packages/create-vite/template-lit/package.json | 2 +- packages/create-vite/template-preact-ts/package.json | 2 +- packages/create-vite/template-preact/package.json | 2 +- packages/create-vite/template-react-ts/package.json | 2 +- packages/create-vite/template-react/package.json | 2 +- packages/create-vite/template-svelte-ts/package.json | 2 +- packages/create-vite/template-svelte/package.json | 2 +- packages/create-vite/template-vanilla-ts/package.json | 2 +- packages/create-vite/template-vanilla/package.json | 2 +- packages/create-vite/template-vue-ts/package.json | 4 ++-- packages/create-vite/template-vue/package.json | 4 ++-- 14 files changed, 25 insertions(+), 15 deletions(-) diff --git a/packages/create-vite/CHANGELOG.md b/packages/create-vite/CHANGELOG.md index bf69fae7e535ad..cac7f2664ecaed 100644 --- a/packages/create-vite/CHANGELOG.md +++ b/packages/create-vite/CHANGELOG.md @@ -1,3 +1,13 @@ +## 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) diff --git a/packages/create-vite/package.json b/packages/create-vite/package.json index 72955697360477..dcaf3962c987cf 100644 --- a/packages/create-vite/package.json +++ b/packages/create-vite/package.json @@ -1,6 +1,6 @@ { "name": "create-vite", - "version": "2.9.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 061def321a22e6..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.9.0", + "vite": "^2.9.2", "typescript": "^4.5.4" } } diff --git a/packages/create-vite/template-lit/package.json b/packages/create-vite/template-lit/package.json index 89f4fee41576c6..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.9.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 dfa6659650c5ae..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.9.0" + "vite": "^2.9.2" } } diff --git a/packages/create-vite/template-preact/package.json b/packages/create-vite/template-preact/package.json index 02528128f6442e..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.9.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 69274929dd903d..ea89f3a68d8c45 100644 --- a/packages/create-vite/template-react-ts/package.json +++ b/packages/create-vite/template-react-ts/package.json @@ -16,6 +16,6 @@ "@types/react-dom": "^18.0.0", "@vitejs/plugin-react": "^1.3.0", "typescript": "^4.6.3", - "vite": "^2.9.1" + "vite": "^2.9.2" } } diff --git a/packages/create-vite/template-react/package.json b/packages/create-vite/template-react/package.json index 4f443aefcb3cdb..f81b751dc8f30c 100644 --- a/packages/create-vite/template-react/package.json +++ b/packages/create-vite/template-react/package.json @@ -15,6 +15,6 @@ "@types/react": "^18.0.0", "@types/react-dom": "^18.0.0", "@vitejs/plugin-react": "^1.3.0", - "vite": "^2.9.1" + "vite": "^2.9.2" } } diff --git a/packages/create-vite/template-svelte-ts/package.json b/packages/create-vite/template-svelte-ts/package.json index 32e080146e0b6e..bed1e3caedeef0 100644 --- a/packages/create-vite/template-svelte-ts/package.json +++ b/packages/create-vite/template-svelte-ts/package.json @@ -17,6 +17,6 @@ "svelte-preprocess": "^4.9.8", "tslib": "^2.3.1", "typescript": "^4.5.4", - "vite": "^2.9.0" + "vite": "^2.9.2" } } diff --git a/packages/create-vite/template-svelte/package.json b/packages/create-vite/template-svelte/package.json index da049c170731b9..661a174421d156 100644 --- a/packages/create-vite/template-svelte/package.json +++ b/packages/create-vite/template-svelte/package.json @@ -11,6 +11,6 @@ "devDependencies": { "@sveltejs/vite-plugin-svelte": "^1.0.0-next.30", "svelte": "^3.44.0", - "vite": "^2.9.0" + "vite": "^2.9.2" } } diff --git a/packages/create-vite/template-vanilla-ts/package.json b/packages/create-vite/template-vanilla-ts/package.json index 8dd7a0bb800909..adedc3d4e83a65 100644 --- a/packages/create-vite/template-vanilla-ts/package.json +++ b/packages/create-vite/template-vanilla-ts/package.json @@ -9,6 +9,6 @@ }, "devDependencies": { "typescript": "^4.5.4", - "vite": "^2.9.0" + "vite": "^2.9.2" } } diff --git a/packages/create-vite/template-vanilla/package.json b/packages/create-vite/template-vanilla/package.json index ff318e00f14fd1..ee68e7cd13e903 100644 --- a/packages/create-vite/template-vanilla/package.json +++ b/packages/create-vite/template-vanilla/package.json @@ -8,6 +8,6 @@ "preview": "vite preview" }, "devDependencies": { - "vite": "^2.9.0" + "vite": "^2.9.2" } } diff --git a/packages/create-vite/template-vue-ts/package.json b/packages/create-vite/template-vue-ts/package.json index 1d8ff2b3e19d56..2ad29ac0b91725 100644 --- a/packages/create-vite/template-vue-ts/package.json +++ b/packages/create-vite/template-vue-ts/package.json @@ -11,9 +11,9 @@ "vue": "^3.2.25" }, "devDependencies": { - "@vitejs/plugin-vue": "^2.3.0", + "@vitejs/plugin-vue": "^2.3.1", "typescript": "^4.5.4", - "vite": "^2.9.0", + "vite": "^2.9.2", "vue-tsc": "^0.29.8" } } diff --git a/packages/create-vite/template-vue/package.json b/packages/create-vite/template-vue/package.json index 707b664d3dfff7..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.3.0", - "vite": "^2.9.0" + "@vitejs/plugin-vue": "^2.3.1", + "vite": "^2.9.2" } } From 26862c4b7aabd876ece0197ae9f6404fdfcec408 Mon Sep 17 00:00:00 2001 From: patak Date: Wed, 13 Apr 2022 18:24:18 +0200 Subject: [PATCH 041/175] fix: revert #7665 (#7716) --- packages/vite/src/node/preview.ts | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/packages/vite/src/node/preview.ts b/packages/vite/src/node/preview.ts index 23b905fd01a719..c00f62a9cb8f0c 100644 --- a/packages/vite/src/node/preview.ts +++ b/packages/vite/src/node/preview.ts @@ -1,5 +1,4 @@ import path from 'path' -import fs from 'fs' import sirv from 'sirv' import connect from 'connect' import compression from './server/middlewares/compression' @@ -91,20 +90,11 @@ export async function preview( config.base, sirv(distDir, { etag: true, - dev: true + dev: true, + single: true }) ) - app.use(config.base, (_, res, next) => { - const file = path.join(distDir, './404.html') - if (fs.existsSync(file)) { - res.statusCode = 404 - res.end(fs.readFileSync(file)) - } else { - next() - } - }) - const options = config.preview const hostname = resolveHostname(options.host) const port = options.port ?? 4173 From cb5c3f99bfe8ea1f4b43a1d81030b95bc704720b Mon Sep 17 00:00:00 2001 From: patak-dev Date: Wed, 13 Apr 2022 18:35:02 +0200 Subject: [PATCH 042/175] release: v2.9.3 --- packages/vite/CHANGELOG.md | 6 ++++++ packages/vite/package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/vite/CHANGELOG.md b/packages/vite/CHANGELOG.md index b011910c8615cc..822d801d57537e 100644 --- a/packages/vite/CHANGELOG.md +++ b/packages/vite/CHANGELOG.md @@ -1,3 +1,9 @@ +## 2.9.3 (2022-04-13) + +* fix: revert #7665 (#7716) ([26862c4](https://github.com/vitejs/vite/commit/26862c4)), closes [#7665](https://github.com/vitejs/vite/issues/7665) [#7716](https://github.com/vitejs/vite/issues/7716) + + + ## 2.9.2 (2022-04-13) * fix: `$ vite preview` 404 handling (#7665) ([66b6dc5](https://github.com/vitejs/vite/commit/66b6dc5)), closes [#7665](https://github.com/vitejs/vite/issues/7665) diff --git a/packages/vite/package.json b/packages/vite/package.json index 1a749f662be43a..eeecf5b2160544 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -1,6 +1,6 @@ { "name": "vite", - "version": "2.9.2", + "version": "2.9.3", "license": "MIT", "author": "Evan You", "description": "Native-ESM powered web dev build tool", From a5c2a7803eeed55e023bec464f6b193ed5ddac79 Mon Sep 17 00:00:00 2001 From: Hugo ATTAL Date: Wed, 13 Apr 2022 21:39:46 +0200 Subject: [PATCH 043/175] fix: handle url imports with semicolon (fix #7717) (#7718) --- .../vite/src/node/__tests__/plugins/css.spec.ts | 14 ++++++++++++++ packages/vite/src/node/plugins/css.ts | 11 +++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/packages/vite/src/node/__tests__/plugins/css.spec.ts b/packages/vite/src/node/__tests__/plugins/css.spec.ts index 9b652a563ccb0a..078cec2e0f3d77 100644 --- a/packages/vite/src/node/__tests__/plugins/css.spec.ts +++ b/packages/vite/src/node/__tests__/plugins/css.spec.ts @@ -122,6 +122,20 @@ describe('hoist @ rules', () => { expect(result).toBe(`@import "bla";.foo{color:red;}`) }) + test('hoist @import url with semicolon', async () => { + const css = `.foo{color:red;}@import url("bla;bla");` + const result = await hoistAtRules(css) + expect(result).toBe(`@import url("bla;bla");.foo{color:red;}`) + }) + + test('hoist @import url data with semicolon', async () => { + const css = `.foo{color:red;}@import url(data:image/png;base64,iRxVB0);` + const result = await hoistAtRules(css) + expect(result).toBe( + `@import url(data:image/png;base64,iRxVB0);.foo{color:red;}` + ) + }) + test('hoist @import with semicolon in quotes', async () => { const css = `.foo{color:red;}@import "bla;bar";` const result = await hoistAtRules(css) diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index 08bdfbeed4e616..0a14e091c53637 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -1112,10 +1112,13 @@ export async function hoistAtRules(css: string) { // CSS @import can only appear at top of the file. We need to hoist all @import // to top when multiple files are concatenated. // match until semicolon that's not in quotes - s.replace(/@import\s*(?:"[^"]*"|'[^']*'|[^;]*).*?;/gm, (match) => { - s.appendLeft(0, match) - return '' - }) + s.replace( + /@import\s*(?:url\([^\)]*\)|"[^"]*"|'[^']*'|[^;]*).*?;/gm, + (match) => { + s.appendLeft(0, match) + return '' + } + ) // #6333 // CSS @charset must be the top-first in the file, hoist the first to top let foundCharset = false From 6c27f14997db377c7baa5cc6721a9c3f74964a98 Mon Sep 17 00:00:00 2001 From: patak-dev Date: Wed, 13 Apr 2022 21:52:47 +0200 Subject: [PATCH 044/175] release: v2.9.4 --- packages/vite/CHANGELOG.md | 6 ++++++ packages/vite/package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/vite/CHANGELOG.md b/packages/vite/CHANGELOG.md index 822d801d57537e..8ed8c8cf8ba692 100644 --- a/packages/vite/CHANGELOG.md +++ b/packages/vite/CHANGELOG.md @@ -1,3 +1,9 @@ +## 2.9.4 (2022-04-13) + +* fix: handle url imports with semicolon (fix #7717) (#7718) ([a5c2a78](https://github.com/vitejs/vite/commit/a5c2a78)), closes [#7717](https://github.com/vitejs/vite/issues/7717) [#7718](https://github.com/vitejs/vite/issues/7718) + + + ## 2.9.3 (2022-04-13) * fix: revert #7665 (#7716) ([26862c4](https://github.com/vitejs/vite/commit/26862c4)), closes [#7665](https://github.com/vitejs/vite/issues/7665) [#7716](https://github.com/vitejs/vite/issues/7716) diff --git a/packages/vite/package.json b/packages/vite/package.json index eeecf5b2160544..1ab75ada9c7cd3 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -1,6 +1,6 @@ { "name": "vite", - "version": "2.9.3", + "version": "2.9.4", "license": "MIT", "author": "Evan You", "description": "Native-ESM powered web dev build tool", From c4450757d4c87de671a985714139d17349f905d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Thu, 14 Apr 2022 23:16:14 +0900 Subject: [PATCH 045/175] chore: format css minify esbuild error (#7731) --- packages/vite/src/node/plugins/css.ts | 31 +++++++++++++++++---------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index 0a14e091c53637..2f5ab3df58b46a 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -1092,18 +1092,27 @@ async function doImportCSSReplace( } async function minifyCSS(css: string, config: ResolvedConfig) { - const { code, warnings } = await transform(css, { - loader: 'css', - minify: true, - target: config.build.cssTarget || undefined - }) - if (warnings.length) { - const msgs = await formatMessages(warnings, { kind: 'warning' }) - config.logger.warn( - colors.yellow(`warnings when minifying css:\n${msgs.join('\n')}`) - ) + try { + const { code, warnings } = await transform(css, { + loader: 'css', + minify: true, + target: config.build.cssTarget || undefined + }) + if (warnings.length) { + const msgs = await formatMessages(warnings, { kind: 'warning' }) + config.logger.warn( + colors.yellow(`warnings when minifying css:\n${msgs.join('\n')}`) + ) + } + return code + } catch (e) { + if (e.errors) { + const msgs = await formatMessages(e.errors, { kind: 'error' }) + e.frame = '\n' + msgs.join('\n') + e.loc = e.errors[0].location + } + throw e } - return code } export async function hoistAtRules(css: string) { From fa86d69ca54e9a538302c8fcc300c5bfba0ce59f Mon Sep 17 00:00:00 2001 From: patak Date: Thu, 14 Apr 2022 16:40:53 +0200 Subject: [PATCH 046/175] fix: revert #7582, fix #7721 and #7736 (#7737) --- .../resolve/__tests__/resolve.spec.ts | 10 ++------ packages/playground/resolve/index.html | 20 ++++------------ packages/playground/resolve/package.json | 3 +-- .../index.cjs | 8 ------- .../require-pkg-with-esm-entries/index.cjs | 9 ------- .../require-pkg-with-esm-entries/package.json | 9 ------- .../dep.cjs | 0 .../require-pkg-with-module-field/index.cjs | 8 +++++++ .../package.json | 2 +- packages/playground/resolve/vite.config.js | 5 +--- packages/vite/src/node/constants.ts | 15 ------------ packages/vite/src/node/plugins/resolve.ts | 6 ----- pnpm-lock.yaml | 24 +++---------------- 13 files changed, 20 insertions(+), 99 deletions(-) delete mode 100644 packages/playground/resolve/require-pkg-with-browser-and-module-field/index.cjs delete mode 100644 packages/playground/resolve/require-pkg-with-esm-entries/index.cjs delete mode 100644 packages/playground/resolve/require-pkg-with-esm-entries/package.json rename packages/playground/resolve/{require-pkg-with-browser-and-module-field => require-pkg-with-module-field}/dep.cjs (100%) create mode 100644 packages/playground/resolve/require-pkg-with-module-field/index.cjs rename packages/playground/resolve/{require-pkg-with-browser-and-module-field => require-pkg-with-module-field}/package.json (68%) diff --git a/packages/playground/resolve/__tests__/resolve.spec.ts b/packages/playground/resolve/__tests__/resolve.spec.ts index 46f8f6138b39a4..2deb2fab7f8d40 100644 --- a/packages/playground/resolve/__tests__/resolve.spec.ts +++ b/packages/playground/resolve/__tests__/resolve.spec.ts @@ -61,14 +61,8 @@ test('dont add extension to directory name (./dir-with-ext.js/index.js)', async expect(await page.textContent('.dir-with-ext')).toMatch('[success]') }) -test('resolve to the `browser` field instead of `module` when the importer is a `require` call', async () => { - expect( - await page.textContent('.require-pkg-with-browser-and-module-field') - ).toMatch('[success]') -}) - -test('resolve to the `main` field instead of `module` when the importer is a `require` call', async () => { - expect(await page.textContent('.require-pkg-with-esm-entries')).toMatch( +test('do not resolve to the `module` field if the importer is a `require` call', async () => { + expect(await page.textContent('.require-pkg-with-module-field')).toMatch( '[success]' ) }) diff --git a/packages/playground/resolve/index.html b/packages/playground/resolve/index.html index 2478c89b495f49..1920ebb675d24c 100644 --- a/packages/playground/resolve/index.html +++ b/packages/playground/resolve/index.html @@ -58,17 +58,8 @@

Resolve file name containing dot

Browser Field

fail

-

- Resolve to the `browser` field instead of `module` when the importer is a - `require` call -

-

fail

- -

- Resolve to the `main` field instead of `module` when the importer is a - `require` call -

-

fail

+

Don't resolve to the `module` field if the importer is a `require` call

+

fail

CSS Entry

@@ -194,11 +185,8 @@

resolve package that contains # in path

text('.browser', main) } - import { msg as requireBrowserMsg } from 'require-pkg-with-browser-and-module-field' - text('.require-pkg-with-browser-and-module-field', requireBrowserMsg) - - import { msg as requireMainMsg } from 'require-pkg-with-esm-entries' - text('.require-pkg-with-esm-entries', requireMainMsg) + import { msg as requireButWithModuleFieldMsg } from 'require-pkg-with-module-field' + text('.require-pkg-with-module-field', requireButWithModuleFieldMsg) import { msg as customExtMsg } from './custom-ext' text('.custom-ext', customExtMsg) diff --git a/packages/playground/resolve/package.json b/packages/playground/resolve/package.json index 4b8d497b3dbb27..dda4476bc6ae82 100644 --- a/packages/playground/resolve/package.json +++ b/packages/playground/resolve/package.json @@ -12,8 +12,7 @@ "@babel/runtime": "^7.16.0", "es5-ext": "0.10.53", "normalize.css": "^8.0.1", - "require-pkg-with-browser-and-module-field": "link:./require-pkg-with-browser-and-module-field", - "require-pkg-with-esm-entries": "link:./require-pkg-with-esm-entries", + "require-pkg-with-module-field": "link:./require-pkg-with-module-field", "resolve-browser-field": "link:./browser-field", "resolve-custom-condition": "link:./custom-condition", "resolve-custom-main-field": "link:./custom-main-field", diff --git a/packages/playground/resolve/require-pkg-with-browser-and-module-field/index.cjs b/packages/playground/resolve/require-pkg-with-browser-and-module-field/index.cjs deleted file mode 100644 index 86d3360ab38dcb..00000000000000 --- a/packages/playground/resolve/require-pkg-with-browser-and-module-field/index.cjs +++ /dev/null @@ -1,8 +0,0 @@ -const dep = require('./dep.cjs') - -const msg = - dep === '1.111222233334444555566e+21' - ? '[success] require-pkg-with-browser-and-module-field' - : '[failed] require-pkg-with-browser-and-module-field' - -exports.msg = msg diff --git a/packages/playground/resolve/require-pkg-with-esm-entries/index.cjs b/packages/playground/resolve/require-pkg-with-esm-entries/index.cjs deleted file mode 100644 index 55958fbdba26ee..00000000000000 --- a/packages/playground/resolve/require-pkg-with-esm-entries/index.cjs +++ /dev/null @@ -1,9 +0,0 @@ -const fromEvent = require('callbag-from-event') - -const msg = - // should be the exported function instead of the ES Module record (`{ default: ... }`) - typeof fromEvent === 'function' - ? '[success] require-pkg-with-esm-entries' - : '[failed] require-pkg-with-esm-entries' - -exports.msg = msg diff --git a/packages/playground/resolve/require-pkg-with-esm-entries/package.json b/packages/playground/resolve/require-pkg-with-esm-entries/package.json deleted file mode 100644 index b845364bb6f19a..00000000000000 --- a/packages/playground/resolve/require-pkg-with-esm-entries/package.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "require-pkg-with-esm-entries", - "private": true, - "version": "1.0.0", - "main": "./index.cjs", - "dependencies": { - "callbag-from-event": "1.3.0" - } -} diff --git a/packages/playground/resolve/require-pkg-with-browser-and-module-field/dep.cjs b/packages/playground/resolve/require-pkg-with-module-field/dep.cjs similarity index 100% rename from packages/playground/resolve/require-pkg-with-browser-and-module-field/dep.cjs rename to packages/playground/resolve/require-pkg-with-module-field/dep.cjs diff --git a/packages/playground/resolve/require-pkg-with-module-field/index.cjs b/packages/playground/resolve/require-pkg-with-module-field/index.cjs new file mode 100644 index 00000000000000..da215f306d1ac1 --- /dev/null +++ b/packages/playground/resolve/require-pkg-with-module-field/index.cjs @@ -0,0 +1,8 @@ +const dep = require('./dep.cjs') + +const msg = + dep === '1.111222233334444555566e+21' + ? '[success] require-pkg-with-module-field' + : '[failed] require-pkg-with-module-field' + +exports.msg = msg diff --git a/packages/playground/resolve/require-pkg-with-browser-and-module-field/package.json b/packages/playground/resolve/require-pkg-with-module-field/package.json similarity index 68% rename from packages/playground/resolve/require-pkg-with-browser-and-module-field/package.json rename to packages/playground/resolve/require-pkg-with-module-field/package.json index 2a0419b331c407..e409343a7567d5 100644 --- a/packages/playground/resolve/require-pkg-with-browser-and-module-field/package.json +++ b/packages/playground/resolve/require-pkg-with-module-field/package.json @@ -1,5 +1,5 @@ { - "name": "require-pkg-with-browser-and-module-field", + "name": "require-pkg-with-module-field", "private": true, "version": "1.0.0", "main": "./index.cjs", diff --git a/packages/playground/resolve/vite.config.js b/packages/playground/resolve/vite.config.js index c1282f4ffc789d..0550d1ecf6f044 100644 --- a/packages/playground/resolve/vite.config.js +++ b/packages/playground/resolve/vite.config.js @@ -42,9 +42,6 @@ module.exports = { } ], optimizeDeps: { - include: [ - 'require-pkg-with-browser-and-module-field', - 'require-pkg-with-esm-entries' - ] + include: ['require-pkg-with-module-field'] } } diff --git a/packages/vite/src/node/constants.ts b/packages/vite/src/node/constants.ts index 1741bf2dd7a94b..9612cd8c96460d 100644 --- a/packages/vite/src/node/constants.ts +++ b/packages/vite/src/node/constants.ts @@ -6,21 +6,6 @@ export const DEFAULT_MAIN_FIELDS = [ 'jsnext' ] -/** - * A non-exhaustive list of known-to-be-ES-module entry names. - * From - */ -export const KNOWN_ESM_MAIN_FIELDS = [ - 'module', - 'jsnext:main', - 'jsnext', - 'esnext', - 'es2015', - 'es2020', - 'fesm2015', - 'fesm2020' -] - export const DEFAULT_EXTENSIONS = [ '.mjs', '.js', diff --git a/packages/vite/src/node/plugins/resolve.ts b/packages/vite/src/node/plugins/resolve.ts index 10e2989af1114f..1b59503a9d43ed 100644 --- a/packages/vite/src/node/plugins/resolve.ts +++ b/packages/vite/src/node/plugins/resolve.ts @@ -7,7 +7,6 @@ import { SPECIAL_QUERY_RE, DEFAULT_EXTENSIONS, DEFAULT_MAIN_FIELDS, - KNOWN_ESM_MAIN_FIELDS, OPTIMIZABLE_ENTRY_RE, DEP_VERSION_RE } from '../constants' @@ -778,11 +777,6 @@ export function resolvePackageEntry( if (!entryPoint || entryPoint.endsWith('.mjs')) { for (const field of options.mainFields || DEFAULT_MAIN_FIELDS) { - // If the initiator is a `require` call, don't use the ESM entries - if (options.isRequire && KNOWN_ESM_MAIN_FIELDS.includes(field)) { - continue - } - if (typeof data[field] === 'string') { entryPoint = data[field] break diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fbc05e51fbfc7a..09d96eb30938d7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -461,8 +461,7 @@ importers: '@babel/runtime': ^7.16.0 es5-ext: 0.10.53 normalize.css: ^8.0.1 - require-pkg-with-browser-and-module-field: link:./require-pkg-with-browser-and-module-field - require-pkg-with-esm-entries: link:./require-pkg-with-esm-entries + require-pkg-with-module-field: link:./require-pkg-with-module-field resolve-browser-field: link:./browser-field resolve-custom-condition: link:./custom-condition resolve-custom-main-field: link:./custom-main-field @@ -473,8 +472,7 @@ importers: '@babel/runtime': 7.16.5 es5-ext: 0.10.53 normalize.css: 8.0.1 - require-pkg-with-browser-and-module-field: link:require-pkg-with-browser-and-module-field - require-pkg-with-esm-entries: link:require-pkg-with-esm-entries + require-pkg-with-module-field: link:require-pkg-with-module-field resolve-browser-field: link:browser-field resolve-custom-condition: link:custom-condition resolve-custom-main-field: link:custom-main-field @@ -506,18 +504,12 @@ importers: packages/playground/resolve/inline-package: specifiers: {} - packages/playground/resolve/require-pkg-with-browser-and-module-field: + packages/playground/resolve/require-pkg-with-module-field: specifiers: bignumber.js: 9.0.2 dependencies: bignumber.js: 9.0.2 - packages/playground/resolve/require-pkg-with-esm-entries: - specifiers: - callbag-from-event: 1.3.0 - dependencies: - callbag-from-event: 1.3.0 - packages/playground/ssr-deps: specifiers: bcrypt: ^5.0.1 @@ -3497,16 +3489,6 @@ packages: get-intrinsic: 1.1.1 dev: true - /callbag-from-event/1.3.0: - resolution: {integrity: sha512-cAu82hKKFmMtKTmd50p/nlMfs1oKz+PGUZmmwhbzPbw4YtjNgTKg6pXjpcQprhBQdrqg/v8pHcAS8Qs6X7r8fw==} - dependencies: - callbag: 1.5.0 - dev: false - - /callbag/1.5.0: - resolution: {integrity: sha512-PH3id0HEb/cNS+BehYlF4Z5wzjKAIUao6ab2hWtMs2bi6aW+0PXl0jymqwnFyT2cQO2h30ggUgpQlmzOpAIKNg==} - dev: false - /callsites/3.1.0: resolution: {integrity: sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==} engines: {node: '>=6'} From 5d96dcab9ce207c9fc7f37116b00d45b678fc87c Mon Sep 17 00:00:00 2001 From: patak-dev Date: Thu, 14 Apr 2022 16:43:29 +0200 Subject: [PATCH 047/175] release: v2.9.5 --- packages/vite/CHANGELOG.md | 7 +++++++ packages/vite/package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/vite/CHANGELOG.md b/packages/vite/CHANGELOG.md index 8ed8c8cf8ba692..084a6363109266 100644 --- a/packages/vite/CHANGELOG.md +++ b/packages/vite/CHANGELOG.md @@ -1,3 +1,10 @@ +## 2.9.5 (2022-04-14) + +* fix: revert #7582, fix #7721 and #7736 (#7737) ([fa86d69](https://github.com/vitejs/vite/commit/fa86d69)), closes [#7721](https://github.com/vitejs/vite/issues/7721) [#7736](https://github.com/vitejs/vite/issues/7736) [#7737](https://github.com/vitejs/vite/issues/7737) +* chore: format css minify esbuild error (#7731) ([c445075](https://github.com/vitejs/vite/commit/c445075)), closes [#7731](https://github.com/vitejs/vite/issues/7731) + + + ## 2.9.4 (2022-04-13) * fix: handle url imports with semicolon (fix #7717) (#7718) ([a5c2a78](https://github.com/vitejs/vite/commit/a5c2a78)), closes [#7717](https://github.com/vitejs/vite/issues/7717) [#7718](https://github.com/vitejs/vite/issues/7718) diff --git a/packages/vite/package.json b/packages/vite/package.json index 1ab75ada9c7cd3..e575c5b4f6c907 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -1,6 +1,6 @@ { "name": "vite", - "version": "2.9.4", + "version": "2.9.5", "license": "MIT", "author": "Evan You", "description": "Native-ESM powered web dev build tool", From 434bb5c05bce8a376bde50100a1466072d5e3624 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Fri, 15 Apr 2022 03:47:53 +0900 Subject: [PATCH 048/175] docs: mention `process.env` for config env vars (#7744) --- docs/config/index.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/config/index.md b/docs/config/index.md index d7560e58736a43..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' From 1f2ca536101d54649c6abc34e9665c2163878b56 Mon Sep 17 00:00:00 2001 From: Rom Date: Fri, 15 Apr 2022 07:45:26 +0200 Subject: [PATCH 049/175] fix: `apply` condition skipped for nested plugins (#7741) --- packages/vite/src/node/config.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/vite/src/node/config.ts b/packages/vite/src/node/config.ts index f633d1158bfa95..a30d84465e9990 100644 --- a/packages/vite/src/node/config.ts +++ b/packages/vite/src/node/config.ts @@ -63,7 +63,7 @@ export function defineConfig(config: UserConfigExport): UserConfigExport { return config } -export type PluginOption = Plugin | false | null | undefined +export type PluginOption = Plugin | false | null | undefined | PluginOption[] export interface UserConfig { /** @@ -109,7 +109,7 @@ export interface UserConfig { /** * Array of vite plugins to use. */ - plugins?: (PluginOption | PluginOption[])[] + plugins?: PluginOption[] /** * Configure resolver */ @@ -199,7 +199,7 @@ export interface UserConfig { /** * Vite plugins that apply to worker bundle */ - plugins?: (PluginOption | PluginOption[])[] + plugins?: PluginOption[] /** * Rollup options to build worker bundle */ @@ -322,7 +322,7 @@ export async function resolveConfig( configEnv.mode = mode // resolve plugins - const rawUserPlugins = (config.plugins || []).flat().filter((p) => { + const rawUserPlugins = (config.plugins || []).flat(Infinity).filter((p) => { if (!p) { return false } else if (!p.apply) { From b89974a127c7a986d309db675d95287a9ae75386 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Sat, 16 Apr 2022 04:20:36 +0900 Subject: [PATCH 050/175] fix(ssr): rewrite dynamic class method name (fix #7751) (#7757) --- .../node/ssr/__tests__/ssrTransform.spec.ts | 39 +++++++++++++++++++ packages/vite/src/node/ssr/ssrTransform.ts | 2 +- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/packages/vite/src/node/ssr/__tests__/ssrTransform.spec.ts b/packages/vite/src/node/ssr/__tests__/ssrTransform.spec.ts index a5f915edea97fd..14481f98a4a87a 100644 --- a/packages/vite/src/node/ssr/__tests__/ssrTransform.spec.ts +++ b/packages/vite/src/node/ssr/__tests__/ssrTransform.spec.ts @@ -545,6 +545,45 @@ class A { `) }) +test('class methods', async () => { + expect( + ( + await ssrTransform( + ` +import foo from 'foo' + +const bar = 'bar' + +class A { + foo() {} + [foo]() {} + [bar]() {} + #foo() {} + bar(foo) {} +} +`, + null, + null + ) + ).code + ).toMatchInlineSnapshot(` + " + const __vite_ssr_import_0__ = await __vite_ssr_import__(\\"foo\\"); + + + const bar = 'bar' + + class A { + foo() {} + [__vite_ssr_import_0__.default]() {} + [bar]() {} + #foo() {} + bar(foo) {} + } + " + `) +}) + test('declare scope', async () => { expect( ( diff --git a/packages/vite/src/node/ssr/ssrTransform.ts b/packages/vite/src/node/ssr/ssrTransform.ts index 79ccd25f9ca8ff..238482a0ceac2f 100644 --- a/packages/vite/src/node/ssr/ssrTransform.ts +++ b/packages/vite/src/node/ssr/ssrTransform.ts @@ -429,7 +429,7 @@ function isRefIdentifier(id: Identifier, parent: _Node, parentStack: _Node[]) { } // class method name - if (parent.type === 'MethodDefinition') { + if (parent.type === 'MethodDefinition' && !parent.computed) { return false } From 12a4e7d8bbf06d35d6fcc0135dcb76fd06a57c22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Sat, 16 Apr 2022 17:32:13 +0900 Subject: [PATCH 051/175] refactor(legacy): remove unneeded dynamic import var init code (#7759) --- packages/plugin-legacy/README.md | 1 - packages/plugin-legacy/index.js | 8 -------- 2 files changed, 9 deletions(-) diff --git a/packages/plugin-legacy/README.md b/packages/plugin-legacy/README.md index 36da971c6a17c2..3c9fe67e107f7f 100644 --- a/packages/plugin-legacy/README.md +++ b/packages/plugin-legacy/README.md @@ -163,7 +163,6 @@ The legacy plugin requires inline scripts for [Safari 10.1 `nomodule` fix](https - `sha256-MS6/3FCg4WjP9gwgaBGwLpRCY6fZBgwmhVCdrPrNf3E=` - `sha256-tQjf8gvb2ROOMapIxFvFAYBeUJ0v1HCbOcSmDNXGtDo=` -- `sha256-xYj09txJ9OsgySe5ommpqul6FiaJZRrwe3KTD7wbV6w=` - `sha256-4m6wOIrq/wFDmi9Xh3mFM2mwI4ik9n3TMgHk6xDtLxk=` - `sha256-uS7/g9fhQwNZS1f/MqYqqKv8y9hCu36IfX9XZB5L7YY=` diff --git a/packages/plugin-legacy/index.js b/packages/plugin-legacy/index.js index 41f7157ebfc533..2f1b1991c31c31 100644 --- a/packages/plugin-legacy/index.js +++ b/packages/plugin-legacy/index.js @@ -20,7 +20,6 @@ const legacyEntryId = 'vite-legacy-entry' const systemJSInlineCode = `System.import(document.getElementById('${legacyEntryId}').getAttribute('data-src'))` const detectDynamicImportVarName = '__vite_is_dynamic_import_support' -const detectDynamicImportVarInitCode = `var ${detectDynamicImportVarName}=false;` const detectDynamicImportCode = `try{import("_").catch(()=>1);}catch(e){}window.${detectDynamicImportVarName}=true;` const dynamicFallbackInlineCode = `!function(){if(window.${detectDynamicImportVarName})return;console.warn("vite: loading legacy build because dynamic import is unsupported, syntax error above should be ignored");var e=document.getElementById("${legacyPolyfillId}"),n=document.createElement("script");n.src=e.src,n.onload=function(){${systemJSInlineCode}},document.body.appendChild(n)}();` @@ -437,12 +436,6 @@ function viteLegacyPlugin(options = {}) { // 5. inject dynamic import fallback entry if (genDynamicFallback && legacyPolyfillFilename && legacyEntryFilename) { - tags.push({ - tag: 'script', - attrs: { type: 'module' }, - children: detectDynamicImportVarInitCode, - injectTo: 'head' - }) tags.push({ tag: 'script', attrs: { type: 'module' }, @@ -714,7 +707,6 @@ viteLegacyPlugin.default = viteLegacyPlugin viteLegacyPlugin.cspHashes = [ createHash('sha256').update(safari10NoModuleFix).digest('base64'), createHash('sha256').update(systemJSInlineCode).digest('base64'), - createHash('sha256').update(detectDynamicImportVarInitCode).digest('base64'), createHash('sha256').update(detectDynamicImportCode).digest('base64'), createHash('sha256').update(dynamicFallbackInlineCode).digest('base64') ] From 9a932339aae8bfbb9f3b522706c551a21a1eea3a Mon Sep 17 00:00:00 2001 From: Hydrogen <3038094028@qq.com> Date: Sat, 16 Apr 2022 20:05:49 +0800 Subject: [PATCH 052/175] fix(create-vite): bump `vue-tsc` to `0.34.7` (#7760) --- packages/create-vite/template-vue-ts/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/create-vite/template-vue-ts/package.json b/packages/create-vite/template-vue-ts/package.json index 2ad29ac0b91725..a3af0acf1ef7ab 100644 --- a/packages/create-vite/template-vue-ts/package.json +++ b/packages/create-vite/template-vue-ts/package.json @@ -14,6 +14,6 @@ "@vitejs/plugin-vue": "^2.3.1", "typescript": "^4.5.4", "vite": "^2.9.2", - "vue-tsc": "^0.29.8" + "vue-tsc": "^0.34.7" } } From 694c1ce765b80458197e039ce720bb9ce1076667 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Mon, 18 Apr 2022 00:28:25 +0900 Subject: [PATCH 053/175] test: fix use terser for preload test (#7771) --- packages/playground/preload/vite.config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/playground/preload/vite.config.js b/packages/playground/preload/vite.config.js index 96fb82f51ed349..90684f41829953 100644 --- a/packages/playground/preload/vite.config.js +++ b/packages/playground/preload/vite.config.js @@ -3,6 +3,7 @@ const vuePlugin = require('@vitejs/plugin-vue') module.exports = { plugins: [vuePlugin()], build: { + minify: 'terser', terserOptions: { format: { beautify: true From af8ca602031daa99692fc2e29f9d6330409e4bc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=98=E6=A0=91=40=E9=98=BF=E9=87=8C?= Date: Mon, 18 Apr 2022 11:39:25 +0800 Subject: [PATCH 054/175] feat: enable optimizeDeps.esbuildOptions.loader (#6840) Co-authored-by: bluwy --- packages/vite/src/node/optimizer/index.ts | 5 +++-- packages/vite/src/node/optimizer/scan.ts | 11 ++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/vite/src/node/optimizer/index.ts b/packages/vite/src/node/optimizer/index.ts index 13c322610cf493..3828cb2fbce18b 100644 --- a/packages/vite/src/node/optimizer/index.ts +++ b/packages/vite/src/node/optimizer/index.ts @@ -417,11 +417,12 @@ export async function runOptimizeDeps( try { exportsData = parse(entryContent) as ExportsData } catch { + const loader = esbuildOptions.loader?.[path.extname(filePath)] || 'jsx' debug( - `Unable to parse dependency: ${id}. Trying again with a JSX transform.` + `Unable to parse dependency: ${id}. Trying again with a ${loader} transform.` ) const transformed = await transformWithEsbuild(entryContent, filePath, { - loader: 'jsx' + loader }) // Ensure that optimization won't fail by defaulting '.js' to the JSX parser. // This is useful for packages such as Gatsby. diff --git a/packages/vite/src/node/optimizer/scan.ts b/packages/vite/src/node/optimizer/scan.ts index e940617386eb35..ef59a35b1d22d3 100644 --- a/packages/vite/src/node/optimizer/scan.ts +++ b/packages/vite/src/node/optimizer/scan.ts @@ -463,21 +463,26 @@ function esbuildScanPlugin( contents = config.esbuild.jsxInject + `\n` + contents } + const loader = + config.optimizeDeps?.esbuildOptions?.loader?.[`.${ext}`] || + (ext as Loader) + if (contents.includes('import.meta.glob')) { return transformGlob( contents, id, config.root, - ext as Loader, + loader, resolve, config.logger ).then((contents) => ({ - loader: ext as Loader, + loader, contents })) } + return { - loader: ext as Loader, + loader, contents } }) From 54e9cdd9f913ba7b650bce6657b5ff666dd0b5a8 Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Mon, 18 Apr 2022 13:25:14 +0800 Subject: [PATCH 055/175] fix(create-vite): set skipLibCheck true (#7726) --- packages/create-vite/template-lit-ts/tsconfig.json | 3 ++- packages/create-vite/template-preact-ts/tsconfig.json | 2 +- packages/create-vite/template-react-ts/tsconfig.json | 2 +- packages/create-vite/template-vanilla-ts/tsconfig.json | 3 ++- packages/create-vite/template-vue-ts/tsconfig.json | 3 ++- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/create-vite/template-lit-ts/tsconfig.json b/packages/create-vite/template-lit-ts/tsconfig.json index 2ec691c81c2b38..91a731fd8619d4 100644 --- a/packages/create-vite/template-lit-ts/tsconfig.json +++ b/packages/create-vite/template-lit-ts/tsconfig.json @@ -15,7 +15,8 @@ "allowSyntheticDefaultImports": true, "experimentalDecorators": true, "forceConsistentCasingInFileNames": true, - "useDefineForClassFields": false + "useDefineForClassFields": false, + "skipLibCheck": true }, "include": ["src/**/*.ts"], "references": [{ "path": "./tsconfig.node.json" }] diff --git a/packages/create-vite/template-preact-ts/tsconfig.json b/packages/create-vite/template-preact-ts/tsconfig.json index fda60ae884247a..0a24dec18dd4f8 100644 --- a/packages/create-vite/template-preact-ts/tsconfig.json +++ b/packages/create-vite/template-preact-ts/tsconfig.json @@ -4,7 +4,7 @@ "useDefineForClassFields": true, "lib": ["DOM", "DOM.Iterable", "ESNext"], "allowJs": false, - "skipLibCheck": false, + "skipLibCheck": true, "esModuleInterop": false, "allowSyntheticDefaultImports": true, "strict": true, diff --git a/packages/create-vite/template-react-ts/tsconfig.json b/packages/create-vite/template-react-ts/tsconfig.json index c8bdc64082aa26..3d0a51a86e2024 100644 --- a/packages/create-vite/template-react-ts/tsconfig.json +++ b/packages/create-vite/template-react-ts/tsconfig.json @@ -4,7 +4,7 @@ "useDefineForClassFields": true, "lib": ["DOM", "DOM.Iterable", "ESNext"], "allowJs": false, - "skipLibCheck": false, + "skipLibCheck": true, "esModuleInterop": false, "allowSyntheticDefaultImports": true, "strict": true, diff --git a/packages/create-vite/template-vanilla-ts/tsconfig.json b/packages/create-vite/template-vanilla-ts/tsconfig.json index 05f80b91398b98..fbd022532d3096 100644 --- a/packages/create-vite/template-vanilla-ts/tsconfig.json +++ b/packages/create-vite/template-vanilla-ts/tsconfig.json @@ -13,7 +13,8 @@ "noEmit": true, "noUnusedLocals": true, "noUnusedParameters": true, - "noImplicitReturns": true + "noImplicitReturns": true, + "skipLibCheck": true }, "include": ["src"] } diff --git a/packages/create-vite/template-vue-ts/tsconfig.json b/packages/create-vite/template-vue-ts/tsconfig.json index 52205ea0029c99..bcc4abda4c57f0 100644 --- a/packages/create-vite/template-vue-ts/tsconfig.json +++ b/packages/create-vite/template-vue-ts/tsconfig.json @@ -10,7 +10,8 @@ "resolveJsonModule": true, "isolatedModules": true, "esModuleInterop": true, - "lib": ["esnext", "dom"] + "lib": ["esnext", "dom"], + "skipLibCheck": true }, "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"], "references": [{ "path": "./tsconfig.node.json" }] From 788d2ec1dc9853be4ecdef67d1a458a2b46ec9bf Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Mon, 18 Apr 2022 17:07:37 +0800 Subject: [PATCH 056/175] docs: explain skipLibCheck (#7785) --- docs/guide/features.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/guide/features.md b/docs/guide/features.md index ebed85cd2d529d..06d282ae94ecd7 100644 --- a/docs/guide/features.md +++ b/docs/guide/features.md @@ -53,6 +53,8 @@ It is because `esbuild` only performs transpilation without type information, it You must set `"isolatedModules": true` in your `tsconfig.json` under `compilerOptions`, so that TS will warn you against the features that do not work with isolated transpilation. +However, some libraries (e.g. [`vue`](https://github.com/vuejs/core/issues/1228)) don't work well with `"isolatedModules": true`. You can use `"skipLibCheck": true` to temporarily suppress the errors until it is fixed upstream. + #### `useDefineForClassFields` Starting from Vite 2.5.0, the default value will be `true` if the TypeScript target is `ESNext`. It is consistent with the [behavior of `tsc` 4.3.2 and later](https://github.com/microsoft/TypeScript/pull/42663). It is also the standard ECMAScript runtime behavior. From 6198911faeee3b915fc0d4ff24fbb918f3e1d558 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Tue, 19 Apr 2022 06:30:13 +0900 Subject: [PATCH 057/175] docs: import.meta.url is replaced even if ESM (#7794) --- docs/config/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/config/index.md b/docs/config/index.md index 346de1a78f7dc9..4f1b3efbd16198 100644 --- a/docs/config/index.md +++ b/docs/config/index.md @@ -28,7 +28,7 @@ vite --config my-config.js ``` ::: tip NOTE -Vite will replace `__filename`, `__dirname`, and `import.meta.url` in **CommonJS** and **TypeScript** config files. Using these as variable names will result in an error: +Vite will replace `__filename`, `__dirname`, and `import.meta.url` in config files and its deps. Using these as variable names will result in an error: ```js const __filename = "value" From 12d119434038f75d2017ce0e543b72416f2745f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Tue, 19 Apr 2022 06:31:38 +0900 Subject: [PATCH 058/175] fix: replace import.meta.url correctly (#7792) --- packages/vite/src/node/config.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/vite/src/node/config.ts b/packages/vite/src/node/config.ts index a30d84465e9990..556fcf7cbae77a 100644 --- a/packages/vite/src/node/config.ts +++ b/packages/vite/src/node/config.ts @@ -31,7 +31,7 @@ import { createLogger } from './logger' import type { DepOptimizationOptions } from './optimizer' import { createFilter } from '@rollup/pluginutils' import type { ResolvedBuildOptions } from '.' -import { parse as parseUrl } from 'url' +import { parse as parseUrl, pathToFileURL } from 'url' import type { JsonOptions } from './plugins/json' import type { PluginContainer } from './server/pluginContainer' import { createPluginContainer } from './server/pluginContainer' @@ -1008,7 +1008,7 @@ async function bundleConfigFile( contents: contents .replace( /\bimport\.meta\.url\b/g, - JSON.stringify(`file://${args.path}`) + JSON.stringify(pathToFileURL(args.path).href) ) .replace( /\b__dirname\b/g, From a7fd41660b06d258687a54fe73fef118bd73e1ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Tue, 19 Apr 2022 06:32:24 +0900 Subject: [PATCH 059/175] docs: add link to "Using Plugins" from Plugins section (#7793) --- docs/plugins/index.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/plugins/index.md b/docs/plugins/index.md index 6d81a060cf8883..0a8803ba2d3b9a 100644 --- a/docs/plugins/index.md +++ b/docs/plugins/index.md @@ -4,6 +4,8 @@ Vite aims to provide out-of-the-box support for common web development patterns. Before searching for a Vite or Compatible Rollup plugin, check out the [Features Guide](../guide/features.md). A lot of the cases where a plugin would be needed in a Rollup project are already covered in Vite. ::: +Check out [Using Plugins](../guide/using-plugins) for information on how to use plugins. + ## Official Plugins ### [@vitejs/plugin-vue](https://github.com/vitejs/vite/tree/main/packages/plugin-vue) From e5729bee1e3f0753dc3514757fa15e5533c387fe Mon Sep 17 00:00:00 2001 From: zoomdong <1344492820@qq.com> Date: Tue, 19 Apr 2022 05:35:36 +0800 Subject: [PATCH 060/175] chore: remove useless code in preact template (#7789) --- packages/create-vite/template-preact/src/app.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/create-vite/template-preact/src/app.jsx b/packages/create-vite/template-preact/src/app.jsx index 9d649444f686d9..64fe3eda94c933 100644 --- a/packages/create-vite/template-preact/src/app.jsx +++ b/packages/create-vite/template-preact/src/app.jsx @@ -1,6 +1,6 @@ import { Logo } from './logo' -export function App(props) { +export function App() { return ( <> From 474d5c257b2404b08fabbc8740532a26badfc348 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Kr=C3=BCger?= <2pi_r2@gmx.de> Date: Tue, 19 Apr 2022 10:01:12 +0200 Subject: [PATCH 061/175] fix: new SharedWorker syntax (#7800) --- packages/vite/src/node/plugins/workerImportMetaUrl.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vite/src/node/plugins/workerImportMetaUrl.ts b/packages/vite/src/node/plugins/workerImportMetaUrl.ts index c8ab20fe21694c..3d8970b746349c 100644 --- a/packages/vite/src/node/plugins/workerImportMetaUrl.ts +++ b/packages/vite/src/node/plugins/workerImportMetaUrl.ts @@ -106,7 +106,7 @@ export function workerImportMetaUrlPlugin(config: ResolvedConfig): Plugin { } let s: MagicString | undefined if ( - (code.includes('new Worker') || code.includes('new ShareWorker')) && + (code.includes('new Worker') || code.includes('new SharedWorker')) && code.includes('new URL') && code.includes(`import.meta.url`) ) { From 5f7fe004f03662e2f586791fe6c9199aa0a8c8fe Mon Sep 17 00:00:00 2001 From: zoomdong <1344492820@qq.com> Date: Tue, 19 Apr 2022 16:08:42 +0800 Subject: [PATCH 062/175] chore: code structure (#7790) --- packages/vite/src/node/server/index.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/vite/src/node/server/index.ts b/packages/vite/src/node/server/index.ts index bf13ba683a9b93..99aefea6de292a 100644 --- a/packages/vite/src/node/server/index.ts +++ b/packages/vite/src/node/server/index.ts @@ -300,8 +300,7 @@ export async function createServer( inlineConfig: InlineConfig = {} ): Promise { const config = await resolveConfig(inlineConfig, 'serve', 'development') - const root = config.root - const serverConfig = config.server + const { root, server: serverConfig } = config const httpsOptions = await resolveHttpsConfig( config.server.https, config.cacheDir From 7f96b2633309d5f02b6f44d7350baad8b7522be7 Mon Sep 17 00:00:00 2001 From: patak-dev Date: Tue, 19 Apr 2022 10:23:47 +0200 Subject: [PATCH 063/175] release: create-vite@2.9.2 --- packages/create-vite/CHANGELOG.md | 8 ++++++++ packages/create-vite/package.json | 2 +- packages/create-vite/template-lit-ts/package.json | 2 +- packages/create-vite/template-lit/package.json | 2 +- packages/create-vite/template-preact-ts/package.json | 2 +- packages/create-vite/template-preact/package.json | 2 +- packages/create-vite/template-react-ts/package.json | 2 +- packages/create-vite/template-react/package.json | 2 +- packages/create-vite/template-svelte-ts/package.json | 2 +- packages/create-vite/template-svelte/package.json | 2 +- packages/create-vite/template-vanilla-ts/package.json | 2 +- packages/create-vite/template-vanilla/package.json | 2 +- packages/create-vite/template-vue-ts/package.json | 2 +- packages/create-vite/template-vue/package.json | 2 +- 14 files changed, 21 insertions(+), 13 deletions(-) diff --git a/packages/create-vite/CHANGELOG.md b/packages/create-vite/CHANGELOG.md index cac7f2664ecaed..7379feb81239b8 100644 --- a/packages/create-vite/CHANGELOG.md +++ b/packages/create-vite/CHANGELOG.md @@ -1,3 +1,11 @@ +## 2.9.2 (2022-04-19) + +* chore: remove useless code in preact template (#7789) ([e5729be](https://github.com/vitejs/vite/commit/e5729be)), closes [#7789](https://github.com/vitejs/vite/issues/7789) +* fix(create-vite): bump `vue-tsc` to `0.34.7` (#7760) ([9a93233](https://github.com/vitejs/vite/commit/9a93233)), closes [#7760](https://github.com/vitejs/vite/issues/7760) +* fix(create-vite): set skipLibCheck true (#7726) ([54e9cdd](https://github.com/vitejs/vite/commit/54e9cdd)), closes [#7726](https://github.com/vitejs/vite/issues/7726) + + + ## 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) diff --git a/packages/create-vite/package.json b/packages/create-vite/package.json index dcaf3962c987cf..5a21b499d9b75d 100644 --- a/packages/create-vite/package.json +++ b/packages/create-vite/package.json @@ -1,6 +1,6 @@ { "name": "create-vite", - "version": "2.9.1", + "version": "2.9.2", "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 6a928d05bb9e84..eb6849d447795c 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.9.2", + "vite": "^2.9.5", "typescript": "^4.5.4" } } diff --git a/packages/create-vite/template-lit/package.json b/packages/create-vite/template-lit/package.json index 7889bec19759ff..6fc110706147f7 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.9.2" + "vite": "^2.9.5" } } diff --git a/packages/create-vite/template-preact-ts/package.json b/packages/create-vite/template-preact-ts/package.json index aaf8aea0372e52..ac90637925896f 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.9.2" + "vite": "^2.9.5" } } diff --git a/packages/create-vite/template-preact/package.json b/packages/create-vite/template-preact/package.json index 19198fc9e66d67..f58b6525abaa52 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.9.2" + "vite": "^2.9.5" } } diff --git a/packages/create-vite/template-react-ts/package.json b/packages/create-vite/template-react-ts/package.json index ea89f3a68d8c45..01d981f51c3414 100644 --- a/packages/create-vite/template-react-ts/package.json +++ b/packages/create-vite/template-react-ts/package.json @@ -16,6 +16,6 @@ "@types/react-dom": "^18.0.0", "@vitejs/plugin-react": "^1.3.0", "typescript": "^4.6.3", - "vite": "^2.9.2" + "vite": "^2.9.5" } } diff --git a/packages/create-vite/template-react/package.json b/packages/create-vite/template-react/package.json index f81b751dc8f30c..4215fdea104c30 100644 --- a/packages/create-vite/template-react/package.json +++ b/packages/create-vite/template-react/package.json @@ -15,6 +15,6 @@ "@types/react": "^18.0.0", "@types/react-dom": "^18.0.0", "@vitejs/plugin-react": "^1.3.0", - "vite": "^2.9.2" + "vite": "^2.9.5" } } diff --git a/packages/create-vite/template-svelte-ts/package.json b/packages/create-vite/template-svelte-ts/package.json index bed1e3caedeef0..ae5bf6219d8eee 100644 --- a/packages/create-vite/template-svelte-ts/package.json +++ b/packages/create-vite/template-svelte-ts/package.json @@ -17,6 +17,6 @@ "svelte-preprocess": "^4.9.8", "tslib": "^2.3.1", "typescript": "^4.5.4", - "vite": "^2.9.2" + "vite": "^2.9.5" } } diff --git a/packages/create-vite/template-svelte/package.json b/packages/create-vite/template-svelte/package.json index 661a174421d156..ac224a274d1c10 100644 --- a/packages/create-vite/template-svelte/package.json +++ b/packages/create-vite/template-svelte/package.json @@ -11,6 +11,6 @@ "devDependencies": { "@sveltejs/vite-plugin-svelte": "^1.0.0-next.30", "svelte": "^3.44.0", - "vite": "^2.9.2" + "vite": "^2.9.5" } } diff --git a/packages/create-vite/template-vanilla-ts/package.json b/packages/create-vite/template-vanilla-ts/package.json index adedc3d4e83a65..94a8ccc952012a 100644 --- a/packages/create-vite/template-vanilla-ts/package.json +++ b/packages/create-vite/template-vanilla-ts/package.json @@ -9,6 +9,6 @@ }, "devDependencies": { "typescript": "^4.5.4", - "vite": "^2.9.2" + "vite": "^2.9.5" } } diff --git a/packages/create-vite/template-vanilla/package.json b/packages/create-vite/template-vanilla/package.json index ee68e7cd13e903..ddc9844be1954f 100644 --- a/packages/create-vite/template-vanilla/package.json +++ b/packages/create-vite/template-vanilla/package.json @@ -8,6 +8,6 @@ "preview": "vite preview" }, "devDependencies": { - "vite": "^2.9.2" + "vite": "^2.9.5" } } diff --git a/packages/create-vite/template-vue-ts/package.json b/packages/create-vite/template-vue-ts/package.json index a3af0acf1ef7ab..c7383d48b09e3b 100644 --- a/packages/create-vite/template-vue-ts/package.json +++ b/packages/create-vite/template-vue-ts/package.json @@ -13,7 +13,7 @@ "devDependencies": { "@vitejs/plugin-vue": "^2.3.1", "typescript": "^4.5.4", - "vite": "^2.9.2", + "vite": "^2.9.5", "vue-tsc": "^0.34.7" } } diff --git a/packages/create-vite/template-vue/package.json b/packages/create-vite/template-vue/package.json index 531986717154ee..e7e9b681db608c 100644 --- a/packages/create-vite/template-vue/package.json +++ b/packages/create-vite/template-vue/package.json @@ -12,6 +12,6 @@ }, "devDependencies": { "@vitejs/plugin-vue": "^2.3.1", - "vite": "^2.9.2" + "vite": "^2.9.5" } } From 17f3be7056cc64c660503cdebdc67abd3990d0c2 Mon Sep 17 00:00:00 2001 From: yoho Date: Wed, 20 Apr 2022 00:38:00 +0800 Subject: [PATCH 064/175] chore: fix worker sourcemap output style (#7805) --- packages/vite/src/node/plugins/reporter.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/vite/src/node/plugins/reporter.ts b/packages/vite/src/node/plugins/reporter.ts index 4e568a756fa0ea..08650a86e2c38c 100644 --- a/packages/vite/src/node/plugins/reporter.ts +++ b/packages/vite/src/node/plugins/reporter.ts @@ -184,10 +184,15 @@ export function buildReporterPlugin(config: ResolvedConfig): Plugin { } } else if (chunk.source) { const isCSS = chunk.fileName.endsWith('.css') + const isMap = chunk.fileName.endsWith('.js.map') printFileInfo( chunk.fileName, chunk.source, - isCSS ? WriteType.CSS : WriteType.ASSET, + isCSS + ? WriteType.CSS + : isMap + ? WriteType.SOURCE_MAP + : WriteType.ASSET, longest, isCSS ? await getCompressedSize(chunk.source) : undefined ) From eba9d05d7adbb5d4dd25f14b085b15eb3488dfe4 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 19 Apr 2022 22:34:44 +0200 Subject: [PATCH 065/175] chore(deps): update all non-major dependencies (#7780) --- package.json | 18 +- packages/plugin-legacy/package.json | 2 +- packages/plugin-react/package.json | 2 +- packages/plugin-vue-jsx/package.json | 2 +- packages/plugin-vue/package.json | 4 +- packages/vite/package.json | 16 +- pnpm-lock.yaml | 468 ++++++++++++++++----------- 7 files changed, 301 insertions(+), 211 deletions(-) diff --git a/package.json b/package.json index de02e27949560c..a90c2c9a43b3fe 100644 --- a/package.json +++ b/package.json @@ -34,14 +34,14 @@ "ci-docs": "run-s build-vite build-plugin-vue build-docs" }, "devDependencies": { - "@microsoft/api-extractor": "^7.21.2", + "@microsoft/api-extractor": "^7.22.2", "@types/fs-extra": "^9.0.13", "@types/jest": "^27.4.1", - "@types/node": "^16.11.26", + "@types/node": "^16.11.27", "@types/prompts": "^2.0.14", "@types/semver": "^7.3.9", - "@typescript-eslint/eslint-plugin": "^5.18.0", - "@typescript-eslint/parser": "^5.18.0", + "@typescript-eslint/eslint-plugin": "^5.20.0", + "@typescript-eslint/parser": "^5.20.0", "conventional-changelog-cli": "^2.2.2", "cross-env": "^7.0.3", "esbuild": "^0.14.27", @@ -49,19 +49,19 @@ "eslint-define-config": "^1.3.0", "eslint-plugin-node": "^11.1.0", "execa": "^5.1.1", - "fs-extra": "^10.0.1", + "fs-extra": "^10.1.0", "jest": "^27.5.1", - "lint-staged": "^12.3.7", + "lint-staged": "^12.3.8", "minimist": "^1.2.6", "node-fetch": "^2.6.6", "npm-run-all": "^4.1.5", "picocolors": "^1.0.0", - "playwright-chromium": "^1.20.2", + "playwright-chromium": "^1.21.1", "prettier": "2.6.2", "prompts": "^2.4.2", "rimraf": "^3.0.2", "rollup": "^2.59.0", - "semver": "^7.3.6", + "semver": "^7.3.7", "simple-git-hooks": "^2.7.0", "sirv": "^2.0.2", "ts-jest": "^27.1.4", @@ -85,7 +85,7 @@ "eslint --ext .ts" ] }, - "packageManager": "pnpm@6.32.6", + "packageManager": "pnpm@6.32.9", "pnpm": { "overrides": { "vite": "workspace:*", diff --git a/packages/plugin-legacy/package.json b/packages/plugin-legacy/package.json index 4c6783abc04bc8..3734390a3cdf25 100644 --- a/packages/plugin-legacy/package.json +++ b/packages/plugin-legacy/package.json @@ -23,7 +23,7 @@ "homepage": "https://github.com/vitejs/vite/tree/main/packages/plugin-legacy#readme", "dependencies": { "@babel/standalone": "^7.17.9", - "core-js": "^3.21.1", + "core-js": "^3.22.0", "magic-string": "^0.26.1", "regenerator-runtime": "^0.13.9", "systemjs": "^6.12.1" diff --git a/packages/plugin-react/package.json b/packages/plugin-react/package.json index 6608eef784fa22..8c93db98aac027 100644 --- a/packages/plugin-react/package.json +++ b/packages/plugin-react/package.json @@ -38,7 +38,7 @@ "@babel/plugin-transform-react-jsx-development": "^7.16.7", "@babel/plugin-transform-react-jsx-self": "^7.16.7", "@babel/plugin-transform-react-jsx-source": "^7.16.7", - "@rollup/pluginutils": "^4.2.0", + "@rollup/pluginutils": "^4.2.1", "react-refresh": "^0.12.0", "resolve": "^1.22.0" } diff --git a/packages/plugin-vue-jsx/package.json b/packages/plugin-vue-jsx/package.json index 151d0a71ce648c..487d207a0df24d 100644 --- a/packages/plugin-vue-jsx/package.json +++ b/packages/plugin-vue-jsx/package.json @@ -25,7 +25,7 @@ "@babel/core": "^7.17.9", "@babel/plugin-syntax-import-meta": "^7.10.4", "@babel/plugin-transform-typescript": "^7.16.8", - "@rollup/pluginutils": "^4.2.0", + "@rollup/pluginutils": "^4.2.1", "@vue/babel-plugin-jsx": "^1.1.1", "hash-sum": "^2.0.0" } diff --git a/packages/plugin-vue/package.json b/packages/plugin-vue/package.json index 39b3bc87a8b1df..9f401ac7fa86b1 100644 --- a/packages/plugin-vue/package.json +++ b/packages/plugin-vue/package.json @@ -35,13 +35,13 @@ "vue": "^3.2.25" }, "devDependencies": { - "@rollup/pluginutils": "^4.2.0", + "@rollup/pluginutils": "^4.2.1", "@types/hash-sum": "^1.0.0", "debug": "^4.3.4", "hash-sum": "^2.0.0", "rollup": "^2.59.0", "slash": "^4.0.0", "source-map": "^0.6.1", - "vue": "^3.2.31" + "vue": "^3.2.33" } } diff --git a/packages/vite/package.json b/packages/vite/package.json index e575c5b4f6c907..50f8487ad55895 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -57,12 +57,12 @@ "@babel/types": "^7.17.0", "@jridgewell/trace-mapping": "^0.3.4", "@rollup/plugin-alias": "^3.1.9", - "@rollup/plugin-commonjs": "^21.0.3", - "@rollup/plugin-dynamic-import-vars": "^1.4.2", + "@rollup/plugin-commonjs": "^21.1.0", + "@rollup/plugin-dynamic-import-vars": "^1.4.3", "@rollup/plugin-json": "^4.1.0", - "@rollup/plugin-node-resolve": "13.1.3", - "@rollup/plugin-typescript": "^8.3.1", - "@rollup/pluginutils": "^4.2.0", + "@rollup/plugin-node-resolve": "13.2.1", + "@rollup/plugin-typescript": "^8.3.2", + "@rollup/pluginutils": "^4.2.1", "@types/convert-source-map": "^1.5.2", "@types/cross-spawn": "^6.0.2", "@types/debug": "^4.1.7", @@ -71,12 +71,12 @@ "@types/less": "^3.0.3", "@types/micromatch": "^4.0.2", "@types/mime": "^2.0.3", - "@types/node": "^16.11.26", + "@types/node": "^16.11.27", "@types/resolve": "^1.20.1", "@types/sass": "~1.43.1", "@types/stylus": "^0.48.37", "@types/ws": "^8.5.3", - "@vue/compiler-dom": "^3.2.31", + "@vue/compiler-dom": "^3.2.33", "acorn": "^8.7.0", "cac": "6.7.9", "chokidar": "^3.5.3", @@ -107,7 +107,7 @@ "postcss-load-config": "^3.1.4", "postcss-modules": "^4.3.1", "resolve.exports": "^1.1.0", - "rollup-plugin-license": "^2.6.1", + "rollup-plugin-license": "^2.7.0", "sirv": "^2.0.2", "source-map-js": "^1.0.2", "source-map-support": "^0.5.21", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 09d96eb30938d7..235dd8c48a30ca 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -10,14 +10,14 @@ importers: .: specifiers: - '@microsoft/api-extractor': ^7.21.2 + '@microsoft/api-extractor': ^7.22.2 '@types/fs-extra': ^9.0.13 '@types/jest': ^27.4.1 - '@types/node': ^16.11.26 + '@types/node': ^16.11.27 '@types/prompts': ^2.0.14 '@types/semver': ^7.3.9 - '@typescript-eslint/eslint-plugin': ^5.18.0 - '@typescript-eslint/parser': ^5.18.0 + '@typescript-eslint/eslint-plugin': ^5.20.0 + '@typescript-eslint/parser': ^5.20.0 conventional-changelog-cli: ^2.2.2 cross-env: ^7.0.3 esbuild: ^0.14.27 @@ -25,19 +25,19 @@ importers: eslint-define-config: ^1.3.0 eslint-plugin-node: ^11.1.0 execa: ^5.1.1 - fs-extra: ^10.0.1 + fs-extra: ^10.1.0 jest: ^27.5.1 - lint-staged: ^12.3.7 + lint-staged: ^12.3.8 minimist: ^1.2.6 node-fetch: ^2.6.6 npm-run-all: ^4.1.5 picocolors: ^1.0.0 - playwright-chromium: ^1.20.2 + playwright-chromium: ^1.21.1 prettier: 2.6.2 prompts: ^2.4.2 rimraf: ^3.0.2 rollup: ^2.59.0 - semver: ^7.3.6 + semver: ^7.3.7 simple-git-hooks: ^2.7.0 sirv: ^2.0.2 ts-jest: ^27.1.4 @@ -46,14 +46,14 @@ importers: vite: workspace:* vitepress: ^0.22.3 devDependencies: - '@microsoft/api-extractor': 7.21.2 + '@microsoft/api-extractor': 7.22.2 '@types/fs-extra': 9.0.13 '@types/jest': 27.4.1 - '@types/node': 16.11.26 + '@types/node': 16.11.27 '@types/prompts': 2.0.14 '@types/semver': 7.3.9 - '@typescript-eslint/eslint-plugin': 5.18.0_423061f51ca07e3dd1eb999a8074f5cd - '@typescript-eslint/parser': 5.18.0_eslint@8.13.0+typescript@4.5.4 + '@typescript-eslint/eslint-plugin': 5.20.0_0df7beb8e4d849cfe6bb8e844ccdebfd + '@typescript-eslint/parser': 5.20.0_eslint@8.13.0+typescript@4.5.4 conventional-changelog-cli: 2.2.2 cross-env: 7.0.3 esbuild: 0.14.27 @@ -61,23 +61,23 @@ importers: eslint-define-config: 1.3.0 eslint-plugin-node: 11.1.0_eslint@8.13.0 execa: 5.1.1 - fs-extra: 10.0.1 + fs-extra: 10.1.0 jest: 27.5.1_ts-node@10.4.0 - lint-staged: 12.3.7 + lint-staged: 12.3.8 minimist: 1.2.6 node-fetch: 2.6.6 npm-run-all: 4.1.5 picocolors: 1.0.0 - playwright-chromium: 1.20.2 + playwright-chromium: 1.21.1 prettier: 2.6.2 prompts: 2.4.2 rimraf: 3.0.2 rollup: 2.62.0 - semver: 7.3.6 + semver: 7.3.7 simple-git-hooks: 2.7.0 sirv: 2.0.2 ts-jest: 27.1.4_4dfe14e0e8266437469ae0475a5c09ac - ts-node: 10.4.0_44ef5af6cbbc24239b4e70b5c7b0d7a6 + ts-node: 10.4.0_8726306ae516cefbf62490d54d06d905 typescript: 4.5.4 vite: link:packages/vite vitepress: 0.22.3 @@ -744,13 +744,13 @@ importers: packages/plugin-legacy: specifiers: '@babel/standalone': ^7.17.9 - core-js: ^3.21.1 + core-js: ^3.22.0 magic-string: ^0.26.1 regenerator-runtime: ^0.13.9 systemjs: ^6.12.1 dependencies: '@babel/standalone': 7.17.9 - core-js: 3.21.1 + core-js: 3.22.0 magic-string: 0.26.1 regenerator-runtime: 0.13.9 systemjs: 6.12.1 @@ -762,7 +762,7 @@ importers: '@babel/plugin-transform-react-jsx-development': ^7.16.7 '@babel/plugin-transform-react-jsx-self': ^7.16.7 '@babel/plugin-transform-react-jsx-source': ^7.16.7 - '@rollup/pluginutils': ^4.2.0 + '@rollup/pluginutils': ^4.2.1 react-refresh: ^0.12.0 resolve: ^1.22.0 dependencies: @@ -771,43 +771,43 @@ importers: '@babel/plugin-transform-react-jsx-development': 7.16.7_@babel+core@7.17.9 '@babel/plugin-transform-react-jsx-self': 7.16.7_@babel+core@7.17.9 '@babel/plugin-transform-react-jsx-source': 7.16.7_@babel+core@7.17.9 - '@rollup/pluginutils': 4.2.0 + '@rollup/pluginutils': 4.2.1 react-refresh: 0.12.0 resolve: 1.22.0 packages/plugin-vue: specifiers: - '@rollup/pluginutils': ^4.2.0 + '@rollup/pluginutils': ^4.2.1 '@types/hash-sum': ^1.0.0 debug: ^4.3.4 hash-sum: ^2.0.0 rollup: ^2.59.0 slash: ^4.0.0 source-map: ^0.6.1 - vue: ^3.2.31 + vue: ^3.2.33 devDependencies: - '@rollup/pluginutils': 4.2.0 + '@rollup/pluginutils': 4.2.1 '@types/hash-sum': 1.0.0 debug: 4.3.4 hash-sum: 2.0.0 rollup: 2.62.0 slash: 4.0.0 source-map: 0.6.1 - vue: 3.2.31 + vue: 3.2.33 packages/plugin-vue-jsx: specifiers: '@babel/core': ^7.17.9 '@babel/plugin-syntax-import-meta': ^7.10.4 '@babel/plugin-transform-typescript': ^7.16.8 - '@rollup/pluginutils': ^4.2.0 + '@rollup/pluginutils': ^4.2.1 '@vue/babel-plugin-jsx': ^1.1.1 hash-sum: ^2.0.0 dependencies: '@babel/core': 7.17.9 '@babel/plugin-syntax-import-meta': 7.10.4_@babel+core@7.17.9 '@babel/plugin-transform-typescript': 7.16.8_@babel+core@7.17.9 - '@rollup/pluginutils': 4.2.0 + '@rollup/pluginutils': 4.2.1 '@vue/babel-plugin-jsx': 1.1.1_@babel+core@7.17.9 hash-sum: 2.0.0 @@ -818,12 +818,12 @@ importers: '@babel/types': ^7.17.0 '@jridgewell/trace-mapping': ^0.3.4 '@rollup/plugin-alias': ^3.1.9 - '@rollup/plugin-commonjs': ^21.0.3 - '@rollup/plugin-dynamic-import-vars': ^1.4.2 + '@rollup/plugin-commonjs': ^21.1.0 + '@rollup/plugin-dynamic-import-vars': ^1.4.3 '@rollup/plugin-json': ^4.1.0 - '@rollup/plugin-node-resolve': 13.1.3 - '@rollup/plugin-typescript': ^8.3.1 - '@rollup/pluginutils': ^4.2.0 + '@rollup/plugin-node-resolve': 13.2.1 + '@rollup/plugin-typescript': ^8.3.2 + '@rollup/pluginutils': ^4.2.1 '@types/convert-source-map': ^1.5.2 '@types/cross-spawn': ^6.0.2 '@types/debug': ^4.1.7 @@ -832,12 +832,12 @@ importers: '@types/less': ^3.0.3 '@types/micromatch': ^4.0.2 '@types/mime': ^2.0.3 - '@types/node': ^16.11.26 + '@types/node': ^16.11.27 '@types/resolve': ^1.20.1 '@types/sass': ~1.43.1 '@types/stylus': ^0.48.37 '@types/ws': ^8.5.3 - '@vue/compiler-dom': ^3.2.31 + '@vue/compiler-dom': ^3.2.33 acorn: ^8.7.0 cac: 6.7.9 chokidar: ^3.5.3 @@ -873,7 +873,7 @@ importers: resolve: ^1.22.0 resolve.exports: ^1.1.0 rollup: ^2.59.0 - rollup-plugin-license: ^2.6.1 + rollup-plugin-license: ^2.7.0 sirv: ^2.0.2 source-map-js: ^1.0.2 source-map-support: ^0.5.21 @@ -896,12 +896,12 @@ importers: '@babel/types': 7.17.0 '@jridgewell/trace-mapping': 0.3.4 '@rollup/plugin-alias': 3.1.9_rollup@2.62.0 - '@rollup/plugin-commonjs': 21.0.3_rollup@2.62.0 - '@rollup/plugin-dynamic-import-vars': 1.4.2_rollup@2.62.0 + '@rollup/plugin-commonjs': 21.1.0_rollup@2.62.0 + '@rollup/plugin-dynamic-import-vars': 1.4.3_rollup@2.62.0 '@rollup/plugin-json': 4.1.0_rollup@2.62.0 - '@rollup/plugin-node-resolve': 13.1.3_rollup@2.62.0 - '@rollup/plugin-typescript': 8.3.1_7c5ff569c0887b4f0035eb7cb6988163 - '@rollup/pluginutils': 4.2.0 + '@rollup/plugin-node-resolve': 13.2.1_rollup@2.62.0 + '@rollup/plugin-typescript': 8.3.2_7c5ff569c0887b4f0035eb7cb6988163 + '@rollup/pluginutils': 4.2.1 '@types/convert-source-map': 1.5.2 '@types/cross-spawn': 6.0.2 '@types/debug': 4.1.7 @@ -910,12 +910,12 @@ importers: '@types/less': 3.0.3 '@types/micromatch': 4.0.2 '@types/mime': 2.0.3 - '@types/node': 16.11.26 + '@types/node': 16.11.27 '@types/resolve': 1.20.1 '@types/sass': 1.43.1 '@types/stylus': 0.48.37 '@types/ws': 8.5.3 - '@vue/compiler-dom': 3.2.31 + '@vue/compiler-dom': 3.2.33 acorn: 8.7.0 cac: 6.7.9 chokidar: 3.5.3 @@ -946,7 +946,7 @@ importers: postcss-load-config: 3.1.4_postcss@8.4.12+ts-node@10.4.0 postcss-modules: 4.3.1_postcss@8.4.12 resolve.exports: 1.1.0 - rollup-plugin-license: 2.6.1_rollup@2.62.0 + rollup-plugin-license: 2.7.0_rollup@2.62.0 sirv: 2.0.2 source-map-js: 1.0.2 source-map-support: 0.5.21 @@ -2012,7 +2012,7 @@ packages: engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0} dependencies: '@jest/types': 27.5.1 - '@types/node': 16.11.26 + '@types/node': 16.11.27 chalk: 4.1.2 jest-message-util: 27.5.1 jest-util: 27.5.1 @@ -2033,7 +2033,7 @@ packages: '@jest/test-result': 27.5.1 '@jest/transform': 27.5.1 '@jest/types': 27.5.1 - '@types/node': 16.11.26 + '@types/node': 16.11.27 ansi-escapes: 4.3.2 chalk: 4.1.2 emittery: 0.8.1 @@ -2070,7 +2070,7 @@ packages: dependencies: '@jest/fake-timers': 27.5.1 '@jest/types': 27.5.1 - '@types/node': 16.11.26 + '@types/node': 16.11.27 jest-mock: 27.5.1 dev: true @@ -2080,7 +2080,7 @@ packages: dependencies: '@jest/types': 27.5.1 '@sinonjs/fake-timers': 8.1.0 - '@types/node': 16.11.26 + '@types/node': 16.11.27 jest-message-util: 27.5.1 jest-mock: 27.5.1 jest-util: 27.5.1 @@ -2109,7 +2109,7 @@ packages: '@jest/test-result': 27.5.1 '@jest/transform': 27.5.1 '@jest/types': 27.5.1 - '@types/node': 16.11.26 + '@types/node': 16.11.27 chalk: 4.1.2 collect-v8-coverage: 1.0.1 exit: 0.1.2 @@ -2178,7 +2178,7 @@ packages: jest-haste-map: 27.5.1 jest-regex-util: 27.5.1 jest-util: 27.5.1 - micromatch: 4.0.4 + micromatch: 4.0.5 pirates: 4.0.4 slash: 3.0.0 source-map: 0.6.1 @@ -2193,7 +2193,7 @@ packages: dependencies: '@types/istanbul-lib-coverage': 2.0.4 '@types/istanbul-reports': 3.0.1 - '@types/node': 16.11.26 + '@types/node': 16.11.27 '@types/yargs': 16.0.4 chalk: 4.1.2 dev: true @@ -2228,43 +2228,43 @@ packages: - supports-color dev: false - /@microsoft/api-extractor-model/7.16.1: - resolution: {integrity: sha512-+1mlvy/ji+mUuH7WdVZ6fTo/aCKfS6m37aAFVOFWLfkMvmR+I9SjPfiv9qOg83If7GOrk2HPiHHibv6kA80VTg==} + /@microsoft/api-extractor-model/7.17.1: + resolution: {integrity: sha512-DCDtD8TdEpNk2lW4JvXgwwpxKy70P0JLad55iahwO8A+C63KYsrHIpAzo0FUauh5pwJ0v5QVNIJ+OBgKGteemg==} dependencies: - '@microsoft/tsdoc': 0.13.2 - '@microsoft/tsdoc-config': 0.15.2 - '@rushstack/node-core-library': 3.45.2 + '@microsoft/tsdoc': 0.14.1 + '@microsoft/tsdoc-config': 0.16.1 + '@rushstack/node-core-library': 3.45.3 dev: true - /@microsoft/api-extractor/7.21.2: - resolution: {integrity: sha512-m0+YPaXVou01O/V9swugZG7Gn4mw6HSWY+uisf0j2JPRZcoEDyoYe4hg0ERKXOEf0hByOnMLT28nQ82v8ig9Yw==} + /@microsoft/api-extractor/7.22.2: + resolution: {integrity: sha512-G7vXz6UHz+qoaUGPf2k5Md4bSpHii9nFys3sIe3bmFUbmhAe+HfSB/dCn1PsLhW7tZfEXwMHTj7fbL5vcZkrEw==} hasBin: true dependencies: - '@microsoft/api-extractor-model': 7.16.1 - '@microsoft/tsdoc': 0.13.2 - '@microsoft/tsdoc-config': 0.15.2 - '@rushstack/node-core-library': 3.45.2 - '@rushstack/rig-package': 0.3.9 - '@rushstack/ts-command-line': 4.10.8 + '@microsoft/api-extractor-model': 7.17.1 + '@microsoft/tsdoc': 0.14.1 + '@microsoft/tsdoc-config': 0.16.1 + '@rushstack/node-core-library': 3.45.3 + '@rushstack/rig-package': 0.3.10 + '@rushstack/ts-command-line': 4.10.9 colors: 1.2.5 lodash: 4.17.21 resolve: 1.17.0 - semver: 7.3.6 + semver: 7.3.7 source-map: 0.6.1 typescript: 4.5.4 dev: true - /@microsoft/tsdoc-config/0.15.2: - resolution: {integrity: sha512-mK19b2wJHSdNf8znXSMYVShAHktVr/ib0Ck2FA3lsVBSEhSI/TfXT7DJQkAYgcztTuwazGcg58ZjYdk0hTCVrA==} + /@microsoft/tsdoc-config/0.16.1: + resolution: {integrity: sha512-2RqkwiD4uN6MLnHFljqBlZIXlt/SaUT6cuogU1w2ARw4nKuuppSmR0+s+NC+7kXBQykd9zzu0P4HtBpZT5zBpQ==} dependencies: - '@microsoft/tsdoc': 0.13.2 + '@microsoft/tsdoc': 0.14.1 ajv: 6.12.6 jju: 1.4.0 resolve: 1.19.0 dev: true - /@microsoft/tsdoc/0.13.2: - resolution: {integrity: sha512-WrHvO8PDL8wd8T2+zBGKrMwVL5IyzR3ryWUsl0PXgEV0QHup4mTLi0QcATefGI6Gx9Anu7vthPyyyLpY0EpiQg==} + /@microsoft/tsdoc/0.14.1: + resolution: {integrity: sha512-6Wci+Tp3CgPt/B9B0a3J4s3yMgLNSku6w5TV6mN+61C71UqsRBv2FUibBf3tPGlNxebgPHMEUzKpb1ggE8KCKw==} dev: true /@mrbbot/node-fetch/4.6.0: @@ -2336,8 +2336,8 @@ packages: slash: 3.0.0 dev: true - /@rollup/plugin-commonjs/21.0.3_rollup@2.62.0: - resolution: {integrity: sha512-ThGfwyvcLc6cfP/MWxA5ACF+LZCvsuhUq7V5134Az1oQWsiC7lNpLT4mJI86WQunK7BYmpUiHmMk2Op6OAHs0g==} + /@rollup/plugin-commonjs/21.1.0_rollup@2.62.0: + resolution: {integrity: sha512-6ZtHx3VHIp2ReNNDxHjuUml6ur+WcQ28N1yHgCQwsbNkQg2suhxGMDQGJOn/KuDxKtd1xuZP5xSTwBA4GQ8hbA==} engines: {node: '>= 8.0.0'} peerDependencies: rollup: ^2.38.3 @@ -2352,13 +2352,13 @@ packages: rollup: 2.62.0 dev: true - /@rollup/plugin-dynamic-import-vars/1.4.2_rollup@2.62.0: - resolution: {integrity: sha512-SEaS9Pf0RyaZ/oJ1knLZT+Fu0X6DlyTfUcoE7XKkiKJjNaB+8SLoHmDVRhomo5RpWHPyd+B00G/bE5R5+Q+HEg==} + /@rollup/plugin-dynamic-import-vars/1.4.3_rollup@2.62.0: + resolution: {integrity: sha512-VYP9BBVI0pcYpLp/DkFT8YP+EmqmWFMmWXoTObDH6OouERxJyPsIj0tC3HxhjNBOKgcRc7eV75IQItzELt7QSg==} engines: {node: '>= 10.0.0'} peerDependencies: rollup: ^1.20.0||^2.0.0 dependencies: - '@rollup/pluginutils': 4.2.0 + '@rollup/pluginutils': 4.2.1 estree-walker: 2.0.2 fast-glob: 3.2.11 magic-string: 0.25.7 @@ -2374,8 +2374,8 @@ packages: rollup: 2.62.0 dev: true - /@rollup/plugin-node-resolve/13.1.3_rollup@2.62.0: - resolution: {integrity: sha512-BdxNk+LtmElRo5d06MGY4zoepyrXX1tkzX2hrnPEZ53k78GuOMWLqmJDGIIOPwVRIFZrLQOo+Yr6KtCuLIA0AQ==} + /@rollup/plugin-node-resolve/13.2.1_rollup@2.62.0: + resolution: {integrity: sha512-btX7kzGvp1JwShQI9V6IM841YKNPYjKCvUbNrQ2EcVYbULtUd/GH6wZ/qdqH13j9pOHBER+EZXNN2L8RSJhVRA==} engines: {node: '>= 10.0.0'} peerDependencies: rollup: ^2.42.0 @@ -2389,8 +2389,8 @@ packages: rollup: 2.62.0 dev: true - /@rollup/plugin-typescript/8.3.1_7c5ff569c0887b4f0035eb7cb6988163: - resolution: {integrity: sha512-84rExe3ICUBXzqNX48WZV2Jp3OddjTMX97O2Py6D1KJaGSwWp0mDHXj+bCGNJqWHIEKDIT2U0sDjhP4czKi6cA==} + /@rollup/plugin-typescript/8.3.2_7c5ff569c0887b4f0035eb7cb6988163: + resolution: {integrity: sha512-MtgyR5LNHZr3GyN0tM7gNO9D0CS+Y+vflS4v/PHmrX17JCkHUYKvQ5jN5o3cz1YKllM3duXUqu3yOHwMPUxhDg==} engines: {node: '>=8.0.0'} peerDependencies: rollup: ^2.14.0 @@ -2416,15 +2416,15 @@ packages: rollup: 2.62.0 dev: true - /@rollup/pluginutils/4.2.0: - resolution: {integrity: sha512-2WUyJNRkyH5p487pGnn4tWAsxhEFKN/pT8CMgHshd5H+IXkOnKvKZwsz5ZWz+YCXkleZRAU5kwbfgF8CPfDRqA==} + /@rollup/pluginutils/4.2.1: + resolution: {integrity: sha512-iKnFXr7NkdZAIHiIWE+BX5ULi/ucVFYWD6TbAV+rZctiRTY2PL6tsIKhoIOaoskiWAkgu+VsbXgUVDNLHf+InQ==} engines: {node: '>= 8.0.0'} dependencies: estree-walker: 2.0.2 - picomatch: 2.3.0 + picomatch: 2.3.1 - /@rushstack/node-core-library/3.45.2: - resolution: {integrity: sha512-MJKdB6mxOoIkks3htGVCo7aiTzllm2I6Xua+KbTSb0cp7rBp8gTCOF/4d8R4HFMwpRdEdwzKgqMM6k9rAK73iw==} + /@rushstack/node-core-library/3.45.3: + resolution: {integrity: sha512-Rn0mxqC3MPb+YbvaeFcRWfcYHLwyZ99/ffYA8chpq5OpqoY+Mr1ycTbMvzl5AxWf1pYmi/2+Eo3iTOsQdYR8xw==} dependencies: '@types/node': 12.20.24 colors: 1.2.5 @@ -2432,20 +2432,20 @@ packages: import-lazy: 4.0.0 jju: 1.4.0 resolve: 1.17.0 - semver: 7.3.6 + semver: 7.3.7 timsort: 0.3.0 z-schema: 5.0.2 dev: true - /@rushstack/rig-package/0.3.9: - resolution: {integrity: sha512-z3Oxpfb4n9mGXwseX+ifpkmUf9B8Fy8oieVwg8eFgpCbzllkgOwEiwLKEnRWVQ8owFcd46NCKz+7ICH35CRsAw==} + /@rushstack/rig-package/0.3.10: + resolution: {integrity: sha512-4Z2HhXM4YBWOi4ZYFQNK6Yxz641v+cvc8NKiaNZh+RIdNb3D4Rfpy3XUkggbCozpfDriBfL1+KaXlJtfJfAIXw==} dependencies: resolve: 1.17.0 strip-json-comments: 3.1.1 dev: true - /@rushstack/ts-command-line/4.10.8: - resolution: {integrity: sha512-G7CQYY/m3aZU5fVxbebv35yDeua7sSumrDAB2pJp0d60ZEsxGkUQW8771CeMcGWwSKqT9PxPzKpmIakiWv54sA==} + /@rushstack/ts-command-line/4.10.9: + resolution: {integrity: sha512-TE3eZgHNVHOY3p8lp38FoNEJUr0+swPb24sCcYuwlC+MHgMGXyJNM+p7l3TKSBRiY01XShoL2k601oGwL00KlA==} dependencies: '@types/argparse': 1.0.38 argparse: 1.0.10 @@ -2534,7 +2534,7 @@ packages: /@types/cross-spawn/6.0.2: resolution: {integrity: sha512-KuwNhp3eza+Rhu8IFI5HUXRP0LIhqH5cAjubUvGXXthh4YYBuP2ntwEX+Cz8GJoZUHlKo247wPWOfA9LYEq4cw==} dependencies: - '@types/node': 16.11.26 + '@types/node': 16.11.27 dev: true /@types/debug/4.1.7: @@ -2554,19 +2554,19 @@ packages: /@types/etag/1.8.1: resolution: {integrity: sha512-bsKkeSqN7HYyYntFRAmzcwx/dKW4Wa+KVMTInANlI72PWLQmOpZu96j0OqHZGArW4VQwCmJPteQlXaUDeOB0WQ==} dependencies: - '@types/node': 16.11.26 + '@types/node': 16.11.27 dev: true /@types/fs-extra/9.0.13: resolution: {integrity: sha512-nEnwB++1u5lVDM2UI4c1+5R+FYaKfaAzS4OococimjVm3nQw3TuzH5UNsocrcTBbhnerblyHj4A49qXbIiZdpA==} dependencies: - '@types/node': 16.11.26 + '@types/node': 16.11.27 dev: true /@types/graceful-fs/4.1.5: resolution: {integrity: sha512-anKkLmZZ+xm4p8JWBf4hElkM4XR+EZeA2M9BAkkTldmcyDY4mbdIJnRghDJH3Ov5ooY7/UAoENtmdMSkaAd7Cw==} dependencies: - '@types/node': 16.11.26 + '@types/node': 16.11.27 dev: true /@types/hash-sum/1.0.0: @@ -2630,8 +2630,8 @@ packages: resolution: {integrity: sha512-qjd88DrCxupx/kJD5yQgZdcYKZKSIGBVDIBE1/LTGcNm3d2Np/jxojkdePDdfnBHJc5W7vSMpbJ1aB7p/Py69A==} dev: true - /@types/node/16.11.26: - resolution: {integrity: sha512-GZ7bu5A6+4DtG7q9GsoHXy3ALcgeIHP4NnL0Vv2wu0uUB/yQex26v0tf6/na1mm0+bS9Uw+0DFex7aaKr2qawQ==} + /@types/node/16.11.27: + resolution: {integrity: sha512-C1pD3kgLoZ56Uuy5lhfOxie4aZlA3UMGLX9rXteq4WitEZH6Rl80mwactt9QG0w0gLFlN/kLBTFnGXtDVWvWQw==} dev: true /@types/normalize-package-data/2.4.1: @@ -2648,13 +2648,13 @@ packages: /@types/prompts/2.0.14: resolution: {integrity: sha512-HZBd99fKxRWpYCErtm2/yxUZv6/PBI9J7N4TNFffl5JbrYMHBwF25DjQGTW3b3jmXq+9P6/8fCIb2ee57BFfYA==} dependencies: - '@types/node': 16.11.26 + '@types/node': 16.11.27 dev: true /@types/resolve/1.17.1: resolution: {integrity: sha512-yy7HuzQhj0dhGpD8RLXSZWEkLsV9ibvxvi6EiJ3bkqLAO1RGo0WbkWQiwpRlSFymTJRz0d3k5LM3kkx8ArDbLw==} dependencies: - '@types/node': 16.11.26 + '@types/node': 16.11.27 dev: true /@types/resolve/1.20.1: @@ -2664,7 +2664,7 @@ packages: /@types/sass/1.43.1: resolution: {integrity: sha512-BPdoIt1lfJ6B7rw35ncdwBZrAssjcwzI5LByIrYs+tpXlj/CAkuVdRsgZDdP4lq5EjyWzwxZCqAoFyHKFwp32g==} dependencies: - '@types/node': 16.11.26 + '@types/node': 16.11.27 dev: true /@types/semver/7.3.9: @@ -2682,13 +2682,13 @@ packages: /@types/stylus/0.48.37: resolution: {integrity: sha512-IkLnS/GzdDK3rgAmQwLr8LqPvUMa43SHlCnXqsfXNukwaIpiXBNgSHil3ro8aemhF4k4ZiMoa4URE7mwBHPJnQ==} dependencies: - '@types/node': 16.11.26 + '@types/node': 16.11.27 dev: true /@types/ws/8.5.3: resolution: {integrity: sha512-6YOoWjruKj1uLf3INHH7D3qTXwFfEsg1kf3c0uDdSBJwfa/llkwIjrAGV7j7mVgGNbzTQ3HiHKKDXl6bJPD97w==} dependencies: - '@types/node': 16.11.26 + '@types/node': 16.11.27 dev: true /@types/yargs-parser/20.2.1: @@ -2705,12 +2705,12 @@ packages: resolution: {integrity: sha512-8uALY5LTvSuHgloDVUvWP3pIauILm+8/0pDMokuDYIoNsOkSwd5AiHBTSEJjKTDcZr5z8UpgOWZkxBF4iJftoA==} requiresBuild: true dependencies: - '@types/node': 16.11.26 + '@types/node': 16.11.27 dev: true optional: true - /@typescript-eslint/eslint-plugin/5.18.0_423061f51ca07e3dd1eb999a8074f5cd: - resolution: {integrity: sha512-tzrmdGMJI/uii9/V6lurMo4/o+dMTKDH82LkNjhJ3adCW22YQydoRs5MwTiqxGF9CSYxPxQ7EYb4jLNlIs+E+A==} + /@typescript-eslint/eslint-plugin/5.20.0_0df7beb8e4d849cfe6bb8e844ccdebfd: + resolution: {integrity: sha512-fapGzoxilCn3sBtC6NtXZX6+P/Hef7VDbyfGqTTpzYydwhlkevB+0vE0EnmHPVTVSy68GUncyJ/2PcrFBeCo5Q==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: '@typescript-eslint/parser': ^5.0.0 @@ -2720,24 +2720,24 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/parser': 5.18.0_eslint@8.13.0+typescript@4.5.4 - '@typescript-eslint/scope-manager': 5.18.0 - '@typescript-eslint/type-utils': 5.18.0_eslint@8.13.0+typescript@4.5.4 - '@typescript-eslint/utils': 5.18.0_eslint@8.13.0+typescript@4.5.4 + '@typescript-eslint/parser': 5.20.0_eslint@8.13.0+typescript@4.5.4 + '@typescript-eslint/scope-manager': 5.20.0 + '@typescript-eslint/type-utils': 5.20.0_eslint@8.13.0+typescript@4.5.4 + '@typescript-eslint/utils': 5.20.0_eslint@8.13.0+typescript@4.5.4 debug: 4.3.4 eslint: 8.13.0 functional-red-black-tree: 1.0.1 ignore: 5.2.0 regexpp: 3.2.0 - semver: 7.3.6 + semver: 7.3.7 tsutils: 3.21.0_typescript@4.5.4 typescript: 4.5.4 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/parser/5.18.0_eslint@8.13.0+typescript@4.5.4: - resolution: {integrity: sha512-+08nYfurBzSSPndngnHvFw/fniWYJ5ymOrn/63oMIbgomVQOvIDhBoJmYZ9lwQOCnQV9xHGvf88ze3jFGUYooQ==} + /@typescript-eslint/parser/5.20.0_eslint@8.13.0+typescript@4.5.4: + resolution: {integrity: sha512-UWKibrCZQCYvobmu3/N8TWbEeo/EPQbS41Ux1F9XqPzGuV7pfg6n50ZrFo6hryynD8qOTTfLHtHjjdQtxJ0h/w==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 @@ -2746,9 +2746,9 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/scope-manager': 5.18.0 - '@typescript-eslint/types': 5.18.0 - '@typescript-eslint/typescript-estree': 5.18.0_typescript@4.5.4 + '@typescript-eslint/scope-manager': 5.20.0 + '@typescript-eslint/types': 5.20.0 + '@typescript-eslint/typescript-estree': 5.20.0_typescript@4.5.4 debug: 4.3.4 eslint: 8.13.0 typescript: 4.5.4 @@ -2756,16 +2756,16 @@ packages: - supports-color dev: true - /@typescript-eslint/scope-manager/5.18.0: - resolution: {integrity: sha512-C0CZML6NyRDj+ZbMqh9FnPscg2PrzSaVQg3IpTmpe0NURMVBXlghGZgMYqBw07YW73i0MCqSDqv2SbywnCS8jQ==} + /@typescript-eslint/scope-manager/5.20.0: + resolution: {integrity: sha512-h9KtuPZ4D/JuX7rpp1iKg3zOH0WNEa+ZIXwpW/KWmEFDxlA/HSfCMhiyF1HS/drTICjIbpA6OqkAhrP/zkCStg==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dependencies: - '@typescript-eslint/types': 5.18.0 - '@typescript-eslint/visitor-keys': 5.18.0 + '@typescript-eslint/types': 5.20.0 + '@typescript-eslint/visitor-keys': 5.20.0 dev: true - /@typescript-eslint/type-utils/5.18.0_eslint@8.13.0+typescript@4.5.4: - resolution: {integrity: sha512-vcn9/6J5D6jtHxpEJrgK8FhaM8r6J1/ZiNu70ZUJN554Y3D9t3iovi6u7JF8l/e7FcBIxeuTEidZDR70UuCIfA==} + /@typescript-eslint/type-utils/5.20.0_eslint@8.13.0+typescript@4.5.4: + resolution: {integrity: sha512-WxNrCwYB3N/m8ceyoGCgbLmuZwupvzN0rE8NBuwnl7APgjv24ZJIjkNzoFBXPRCGzLNkoU/WfanW0exvp/+3Iw==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: eslint: '*' @@ -2774,7 +2774,7 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/utils': 5.18.0_eslint@8.13.0+typescript@4.5.4 + '@typescript-eslint/utils': 5.20.0_eslint@8.13.0+typescript@4.5.4 debug: 4.3.4 eslint: 8.13.0 tsutils: 3.21.0_typescript@4.5.4 @@ -2783,13 +2783,13 @@ packages: - supports-color dev: true - /@typescript-eslint/types/5.18.0: - resolution: {integrity: sha512-bhV1+XjM+9bHMTmXi46p1Led5NP6iqQcsOxgx7fvk6gGiV48c6IynY0apQb7693twJDsXiVzNXTflhplmaiJaw==} + /@typescript-eslint/types/5.20.0: + resolution: {integrity: sha512-+d8wprF9GyvPwtoB4CxBAR/s0rpP25XKgnOvMf/gMXYDvlUC3rPFHupdTQ/ow9vn7UDe5rX02ovGYQbv/IUCbg==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true - /@typescript-eslint/typescript-estree/5.18.0_typescript@4.5.4: - resolution: {integrity: sha512-wa+2VAhOPpZs1bVij9e5gyVu60ReMi/KuOx4LKjGx2Y3XTNUDJgQ+5f77D49pHtqef/klglf+mibuHs9TrPxdQ==} + /@typescript-eslint/typescript-estree/5.20.0_typescript@4.5.4: + resolution: {integrity: sha512-36xLjP/+bXusLMrT9fMMYy1KJAGgHhlER2TqpUVDYUQg4w0q/NW/sg4UGAgVwAqb8V4zYg43KMUpM8vV2lve6w==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: typescript: '*' @@ -2797,28 +2797,28 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/types': 5.18.0 - '@typescript-eslint/visitor-keys': 5.18.0 + '@typescript-eslint/types': 5.20.0 + '@typescript-eslint/visitor-keys': 5.20.0 debug: 4.3.4 globby: 11.0.4 is-glob: 4.0.3 - semver: 7.3.6 + semver: 7.3.7 tsutils: 3.21.0_typescript@4.5.4 typescript: 4.5.4 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/utils/5.18.0_eslint@8.13.0+typescript@4.5.4: - resolution: {integrity: sha512-+hFGWUMMri7OFY26TsOlGa+zgjEy1ssEipxpLjtl4wSll8zy85x0GrUSju/FHdKfVorZPYJLkF3I4XPtnCTewA==} + /@typescript-eslint/utils/5.20.0_eslint@8.13.0+typescript@4.5.4: + resolution: {integrity: sha512-lHONGJL1LIO12Ujyx8L8xKbwWSkoUKFSO+0wDAqGXiudWB2EO7WEUT+YZLtVbmOmSllAjLb9tpoIPwpRe5Tn6w==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 dependencies: '@types/json-schema': 7.0.9 - '@typescript-eslint/scope-manager': 5.18.0 - '@typescript-eslint/types': 5.18.0 - '@typescript-eslint/typescript-estree': 5.18.0_typescript@4.5.4 + '@typescript-eslint/scope-manager': 5.20.0 + '@typescript-eslint/types': 5.20.0 + '@typescript-eslint/typescript-estree': 5.20.0_typescript@4.5.4 eslint: 8.13.0 eslint-scope: 5.1.1 eslint-utils: 3.0.0_eslint@8.13.0 @@ -2827,11 +2827,11 @@ packages: - typescript dev: true - /@typescript-eslint/visitor-keys/5.18.0: - resolution: {integrity: sha512-Hf+t+dJsjAKpKSkg3EHvbtEpFFb/1CiOHnvI8bjHgOD4/wAw3gKrA0i94LrbekypiZVanJu3McWJg7rWDMzRTg==} + /@typescript-eslint/visitor-keys/5.20.0: + resolution: {integrity: sha512-1flRpNF+0CAQkMNlTJ6L/Z5jiODG/e5+7mk6XwtPOUS3UrTz3UOiAg9jG2VtKsWI6rZQfy4C6a232QNRZTRGlg==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dependencies: - '@typescript-eslint/types': 5.18.0 + '@typescript-eslint/types': 5.20.0 eslint-visitor-keys: 3.3.0 dev: true @@ -2872,6 +2872,15 @@ packages: estree-walker: 2.0.2 source-map: 0.6.1 + /@vue/compiler-core/3.2.33: + resolution: {integrity: sha512-AAmr52ji3Zhk7IKIuigX2osWWsb2nQE5xsdFYjdnmtQ4gymmqXbjLvkSE174+fF3A3kstYrTgGkqgOEbsdLDpw==} + dependencies: + '@babel/parser': 7.17.9 + '@vue/shared': 3.2.33 + estree-walker: 2.0.2 + source-map: 0.6.1 + dev: true + /@vue/compiler-dom/3.2.26: resolution: {integrity: sha512-smBfaOW6mQDxcT3p9TKT6mE22vjxjJL50GFVJiI0chXYGU/xzC05QRGrW3HHVuJrmLTLx5zBhsZ2dIATERbarg==} dependencies: @@ -2884,6 +2893,13 @@ packages: '@vue/compiler-core': 3.2.31 '@vue/shared': 3.2.31 + /@vue/compiler-dom/3.2.33: + resolution: {integrity: sha512-GhiG1C8X98Xz9QUX/RlA6/kgPBWJkjq0Rq6//5XTAGSYrTMBgcLpP9+CnlUg1TFxnnCVughAG+KZl28XJqw8uQ==} + dependencies: + '@vue/compiler-core': 3.2.33 + '@vue/shared': 3.2.33 + dev: true + /@vue/compiler-sfc/3.2.26: resolution: {integrity: sha512-ePpnfktV90UcLdsDQUh2JdiTuhV0Skv2iYXxfNMOK/F3Q+2BO0AulcVcfoksOpTJGmhhfosWfMyEaEf0UaWpIw==} dependencies: @@ -2912,6 +2928,21 @@ packages: postcss: 8.4.12 source-map: 0.6.1 + /@vue/compiler-sfc/3.2.33: + resolution: {integrity: sha512-H8D0WqagCr295pQjUYyO8P3IejM3vEzeCO1apzByAEaAR/WimhMYczHfZVvlCE/9yBaEu/eu9RdiWr0kF8b71Q==} + dependencies: + '@babel/parser': 7.17.9 + '@vue/compiler-core': 3.2.33 + '@vue/compiler-dom': 3.2.33 + '@vue/compiler-ssr': 3.2.33 + '@vue/reactivity-transform': 3.2.33 + '@vue/shared': 3.2.33 + estree-walker: 2.0.2 + magic-string: 0.25.7 + postcss: 8.4.12 + source-map: 0.6.1 + dev: true + /@vue/compiler-ssr/3.2.26: resolution: {integrity: sha512-2mywLX0ODc4Zn8qBoA2PDCsLEZfpUGZcyoFRLSOjyGGK6wDy2/5kyDOWtf0S0UvtoyVq95OTSGIALjZ4k2q/ag==} dependencies: @@ -2924,6 +2955,13 @@ packages: '@vue/compiler-dom': 3.2.31 '@vue/shared': 3.2.31 + /@vue/compiler-ssr/3.2.33: + resolution: {integrity: sha512-XQh1Xdk3VquDpXsnoCd7JnMoWec9CfAzQDQsaMcSU79OrrO2PNR0ErlIjm/mGq3GmBfkQjzZACV+7GhfRB8xMQ==} + dependencies: + '@vue/compiler-dom': 3.2.33 + '@vue/shared': 3.2.33 + dev: true + /@vue/devtools-api/6.0.0-beta.21.1: resolution: {integrity: sha512-FqC4s3pm35qGVeXRGOjTsRzlkJjrBLriDS9YXbflHLsfA9FrcKzIyWnLXoNm+/7930E8rRakXuAc2QkC50swAw==} dev: false @@ -2946,6 +2984,16 @@ packages: estree-walker: 2.0.2 magic-string: 0.25.7 + /@vue/reactivity-transform/3.2.33: + resolution: {integrity: sha512-4UL5KOIvSQb254aqenW4q34qMXbfZcmEsV/yVidLUgvwYQQ/D21bGX3DlgPUGI3c4C+iOnNmDCkIxkILoX/Pyw==} + dependencies: + '@babel/parser': 7.17.9 + '@vue/compiler-core': 3.2.33 + '@vue/shared': 3.2.33 + estree-walker: 2.0.2 + magic-string: 0.25.7 + dev: true + /@vue/reactivity/3.2.26: resolution: {integrity: sha512-h38bxCZLW6oFJVDlCcAiUKFnXI8xP8d+eO0pcDxx+7dQfSPje2AO6M9S9QO6MrxQB7fGP0DH0dYQ8ksf6hrXKQ==} dependencies: @@ -2956,6 +3004,12 @@ packages: dependencies: '@vue/shared': 3.2.31 + /@vue/reactivity/3.2.33: + resolution: {integrity: sha512-62Sq0mp9/0bLmDuxuLD5CIaMG2susFAGARLuZ/5jkU1FCf9EDbwUuF+BO8Ub3Rbodx0ziIecM/NsmyjardBxfQ==} + dependencies: + '@vue/shared': 3.2.33 + dev: true + /@vue/runtime-core/3.2.26: resolution: {integrity: sha512-BcYi7qZ9Nn+CJDJrHQ6Zsmxei2hDW0L6AB4vPvUQGBm2fZyC0GXd/4nVbyA2ubmuhctD5RbYY8L+5GUJszv9mQ==} dependencies: @@ -2968,6 +3022,13 @@ packages: '@vue/reactivity': 3.2.31 '@vue/shared': 3.2.31 + /@vue/runtime-core/3.2.33: + resolution: {integrity: sha512-N2D2vfaXsBPhzCV3JsXQa2NECjxP3eXgZlFqKh4tgakp3iX6LCGv76DLlc+IfFZq+TW10Y8QUfeihXOupJ1dGw==} + dependencies: + '@vue/reactivity': 3.2.33 + '@vue/shared': 3.2.33 + dev: true + /@vue/runtime-dom/3.2.26: resolution: {integrity: sha512-dY56UIiZI+gjc4e8JQBwAifljyexfVCkIAu/WX8snh8vSOt/gMSEGwPRcl2UpYpBYeyExV8WCbgvwWRNt9cHhQ==} dependencies: @@ -2982,6 +3043,14 @@ packages: '@vue/shared': 3.2.31 csstype: 2.6.19 + /@vue/runtime-dom/3.2.33: + resolution: {integrity: sha512-LSrJ6W7CZTSUygX5s8aFkraDWlO6K4geOwA3quFF2O+hC3QuAMZt/0Xb7JKE3C4JD4pFwCSO7oCrZmZ0BIJUnw==} + dependencies: + '@vue/runtime-core': 3.2.33 + '@vue/shared': 3.2.33 + csstype: 2.6.19 + dev: true + /@vue/server-renderer/3.2.26_vue@3.2.26: resolution: {integrity: sha512-Jp5SggDUvvUYSBIvYEhy76t4nr1vapY/FIFloWmQzn7UxqaHrrBpbxrqPcTrSgGrcaglj0VBp22BKJNre4aA1w==} peerDependencies: @@ -3000,12 +3069,26 @@ packages: '@vue/shared': 3.2.31 vue: 3.2.31 + /@vue/server-renderer/3.2.33_vue@3.2.33: + resolution: {integrity: sha512-4jpJHRD4ORv8PlbYi+/MfP8ec1okz6rybe36MdpkDrGIdEItHEUyaHSKvz+ptNEyQpALmmVfRteHkU9F8vxOew==} + peerDependencies: + vue: 3.2.33 + dependencies: + '@vue/compiler-ssr': 3.2.33 + '@vue/shared': 3.2.33 + vue: 3.2.33 + dev: true + /@vue/shared/3.2.26: resolution: {integrity: sha512-vPV6Cq+NIWbH5pZu+V+2QHE9y1qfuTq49uNWw4f7FDEeZaDU2H2cx5jcUZOAKW7qTrUS4k6qZPbMy1x4N96nbA==} /@vue/shared/3.2.31: resolution: {integrity: sha512-ymN2pj6zEjiKJZbrf98UM2pfDd6F2H7ksKw7NDt/ZZ1fh5Ei39X5tABugtT03ZRlWd9imccoK0hE8hpjpU7irQ==} + /@vue/shared/3.2.33: + resolution: {integrity: sha512-UBc1Pg1T3yZ97vsA2ueER0F6GbJebLHYlEi4ou1H5YL4KWvMOOWwpYo9/QpWq93wxKG6Wo13IY74Hcn/f7c7Bg==} + dev: true + /@wessberg/stringutil/1.0.19: resolution: {integrity: sha512-9AZHVXWlpN8Cn9k5BC/O0Dzb9E9xfEMXzYrNunwvkUTvuK7xgQPVRZpLo+jWCOZ5r8oBa8NIrHuPEu1hzbb6bg==} engines: {node: '>=8.0.0'} @@ -3272,7 +3355,7 @@ packages: /axios/0.24.0: resolution: {integrity: sha512-Q6cWsys88HoPgAaFAVUb0WpPk0O8iTeisR9IMqy9G8AbO4NlpVknrnQS03zzF9PGAWgO3cgletO3VjV/P7VztA==} dependencies: - follow-redirects: 1.14.6 + follow-redirects: 1.14.6_debug@4.3.4 transitivePeerDependencies: - debug dev: false @@ -3998,8 +4081,8 @@ packages: is-what: 3.14.1 dev: true - /core-js/3.21.1: - resolution: {integrity: sha512-FRq5b/VMrWlrmCzwRrpDYNxyHP9BcAZC+xHJaqTgIE5091ZV1NTmyh0sGOg5XqpnHvR0svdy0sv1gWA1zmhxig==} + /core-js/3.22.0: + resolution: {integrity: sha512-8h9jBweRjMiY+ORO7bdWSeWfHhLPO7whobj7Z2Bl0IDo00C228EdGgH7FE4jGumbEjzcFfkfW8bXgdkEDhnwHQ==} requiresBuild: true dev: false @@ -5085,7 +5168,7 @@ packages: resolution: {integrity: sha512-8/sOawo8tJ4QOBX8YlQBMxL8+RLZfxMQOif9o0KUKTNTjMYElWPE0r/m5VNFxTRd0NSw8qSy8dajrwX4RYI1Hw==} dev: true - /follow-redirects/1.14.6: + /follow-redirects/1.14.6_debug@4.3.4: resolution: {integrity: sha512-fhUl5EwSJbbl8AR+uYL2KQDxLkdSjZGR36xy46AO7cOMTrCMON6Sa28FmAnC2tRTDbd/Uuzz3aJBv7EBN7JH8A==} engines: {node: '>=4.0'} peerDependencies: @@ -5093,6 +5176,8 @@ packages: peerDependenciesMeta: debug: optional: true + dependencies: + debug: 4.3.4 /form-data/3.0.1: resolution: {integrity: sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==} @@ -5133,8 +5218,8 @@ packages: universalify: 2.0.0 dev: false - /fs-extra/10.0.1: - resolution: {integrity: sha512-NbdoVMZso2Lsrn/QwLXOy6rm0ufY2zEOKCDzJR/0kBsb0E6qed0P3iYK+Ath3BfvXEeu4JhEtXLgILx5psUfag==} + /fs-extra/10.1.0: + resolution: {integrity: sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==} engines: {node: '>=12'} dependencies: graceful-fs: 4.2.9 @@ -5493,7 +5578,7 @@ packages: engines: {node: '>=8.0.0'} dependencies: eventemitter3: 4.0.7 - follow-redirects: 1.14.6 + follow-redirects: 1.14.6_debug@4.3.4 requires-port: 1.0.0 transitivePeerDependencies: - debug @@ -5919,7 +6004,7 @@ packages: '@jest/environment': 27.5.1 '@jest/test-result': 27.5.1 '@jest/types': 27.5.1 - '@types/node': 16.11.26 + '@types/node': 16.11.27 chalk: 4.1.2 co: 4.6.0 dedent: 0.7.0 @@ -6002,7 +6087,7 @@ packages: pretty-format: 27.5.1 slash: 3.0.0 strip-json-comments: 3.1.1 - ts-node: 10.4.0_44ef5af6cbbc24239b4e70b5c7b0d7a6 + ts-node: 10.4.0_8726306ae516cefbf62490d54d06d905 transitivePeerDependencies: - bufferutil - canvas @@ -6045,7 +6130,7 @@ packages: '@jest/environment': 27.5.1 '@jest/fake-timers': 27.5.1 '@jest/types': 27.5.1 - '@types/node': 16.11.26 + '@types/node': 16.11.27 jest-mock: 27.5.1 jest-util: 27.5.1 jsdom: 16.7.0 @@ -6063,7 +6148,7 @@ packages: '@jest/environment': 27.5.1 '@jest/fake-timers': 27.5.1 '@jest/types': 27.5.1 - '@types/node': 16.11.26 + '@types/node': 16.11.27 jest-mock: 27.5.1 jest-util: 27.5.1 dev: true @@ -6079,7 +6164,7 @@ packages: dependencies: '@jest/types': 27.5.1 '@types/graceful-fs': 4.1.5 - '@types/node': 16.11.26 + '@types/node': 16.11.27 anymatch: 3.1.2 fb-watchman: 2.0.1 graceful-fs: 4.2.9 @@ -6087,7 +6172,7 @@ packages: jest-serializer: 27.5.1 jest-util: 27.5.1 jest-worker: 27.5.1 - micromatch: 4.0.4 + micromatch: 4.0.5 walker: 1.0.8 optionalDependencies: fsevents: 2.3.2 @@ -6101,7 +6186,7 @@ packages: '@jest/source-map': 27.5.1 '@jest/test-result': 27.5.1 '@jest/types': 27.5.1 - '@types/node': 16.11.26 + '@types/node': 16.11.27 chalk: 4.1.2 co: 4.6.0 expect: 27.5.1 @@ -6145,7 +6230,7 @@ packages: '@types/stack-utils': 2.0.1 chalk: 4.1.2 graceful-fs: 4.2.9 - micromatch: 4.0.4 + micromatch: 4.0.5 pretty-format: 27.5.1 slash: 3.0.0 stack-utils: 2.0.5 @@ -6156,7 +6241,7 @@ packages: engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0} dependencies: '@jest/types': 27.5.1 - '@types/node': 16.11.26 + '@types/node': 16.11.27 dev: true /jest-pnp-resolver/1.2.2_jest-resolve@27.5.1: @@ -6212,7 +6297,7 @@ packages: '@jest/test-result': 27.5.1 '@jest/transform': 27.5.1 '@jest/types': 27.5.1 - '@types/node': 16.11.26 + '@types/node': 16.11.27 chalk: 4.1.2 emittery: 0.8.1 graceful-fs: 4.2.9 @@ -6269,7 +6354,7 @@ packages: resolution: {integrity: sha512-jZCyo6iIxO1aqUxpuBlwTDMkzOAJS4a3eYz3YzgxxVQFwLeSA7Jfq5cbqCY+JLvTDrWirgusI/0KwxKMgrdf7w==} engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0} dependencies: - '@types/node': 16.11.26 + '@types/node': 16.11.27 graceful-fs: 4.2.9 dev: true @@ -6298,7 +6383,7 @@ packages: jest-util: 27.5.1 natural-compare: 1.4.0 pretty-format: 27.5.1 - semver: 7.3.6 + semver: 7.3.7 transitivePeerDependencies: - supports-color dev: true @@ -6308,7 +6393,7 @@ packages: engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0} dependencies: '@jest/types': 27.5.1 - '@types/node': 16.11.26 + '@types/node': 16.11.27 chalk: 4.1.2 ci-info: 3.3.0 graceful-fs: 4.2.9 @@ -6333,7 +6418,7 @@ packages: dependencies: '@jest/test-result': 27.5.1 '@jest/types': 27.5.1 - '@types/node': 16.11.26 + '@types/node': 16.11.27 ansi-escapes: 4.3.2 chalk: 4.1.2 jest-util: 27.5.1 @@ -6344,7 +6429,7 @@ packages: resolution: {integrity: sha512-7vuh85V5cdDofPyxn58nrPjBktZo0u9x1g8WtjQol+jZDaE+fhN+cIvTj11GndBnMnyfrUOG1sZQxCdjKh+DKg==} engines: {node: '>= 10.13.0'} dependencies: - '@types/node': 16.11.26 + '@types/node': 16.11.27 merge-stream: 2.0.0 supports-color: 8.1.1 dev: true @@ -6578,8 +6663,8 @@ packages: /lines-and-columns/1.2.4: resolution: {integrity: sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==} - /lint-staged/12.3.7: - resolution: {integrity: sha512-/S4D726e2GIsDVWIk1XGvheCaDm1SJRQp8efamZFWJxQMVEbOwSysp7xb49Oo73KYCdy97mIWinhlxcoNqIfIQ==} + /lint-staged/12.3.8: + resolution: {integrity: sha512-0+UpNaqIwKRSGAFOCcpuYNIv/j5QGVC+xUVvmSdxHO+IfIGoHbFLo3XcPmV/LLnsVj5EAncNHVtlITSoY5qWGQ==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} hasBin: true dependencies: @@ -6590,7 +6675,7 @@ packages: execa: 5.1.1 lilconfig: 2.0.4 listr2: 4.0.2 - micromatch: 4.0.4 + micromatch: 4.0.5 normalize-path: 3.0.0 object-inspect: 1.12.0 pidtree: 0.5.0 @@ -6720,11 +6805,6 @@ packages: dependencies: yallist: 4.0.0 - /lru-cache/7.8.1: - resolution: {integrity: sha512-E1v547OCgJvbvevfjgK9sNKIVXO96NnsTsFPBlg4ZxjhsJSODoH9lk8Bm0OxvHNm6Vm5Yqkl/1fErDxhYL8Skg==} - engines: {node: '>=12'} - dev: true - /magic-string/0.25.7: resolution: {integrity: sha512-4CrMT5DOHTDk4HYDlzmwu4FVCcIYI8gauveasrdCu2IKIFOJ3f0v/8MDGJCDL9oD2ppz/Av1b0Nj345H9M+XIA==} dependencies: @@ -6979,8 +7059,8 @@ packages: engines: {node: '>=0.10.0'} dev: true - /moment/2.29.1: - resolution: {integrity: sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ==} + /moment/2.29.2: + resolution: {integrity: sha512-UgzG4rvxYpN15jgCmVJwac49h9ly9NurikMWGPdVxm8GZD6XjkKPxDTjQQ43gtGgnV3X0cAyWDdP2Wexoquifg==} dev: true /mrmime/1.0.0: @@ -7112,7 +7192,7 @@ packages: dependencies: hosted-git-info: 4.0.2 is-core-module: 2.8.1 - semver: 7.3.6 + semver: 7.3.7 validate-npm-package-license: 3.0.4 dev: true @@ -7310,8 +7390,8 @@ packages: engines: {node: '>=6'} dev: true - /package-name-regex/2.0.5: - resolution: {integrity: sha512-F0lX+FBs/Bo7KWY6EuUXj+oarXU0Og1R2Zdg3F/fVcNw3pPQAKFKxUrugno0Ds5NUztlx/gRLnQW9MF+7VTqAw==} + /package-name-regex/2.0.6: + resolution: {integrity: sha512-gFL35q7kbE/zBaPA3UKhp2vSzcPYx2ecbYuwv1ucE9Il6IIgBDweBlH8D68UFGZic2MkllKa2KHCfC1IQBQUYA==} engines: {node: '>=12'} dev: true @@ -7473,21 +7553,21 @@ packages: find-up: 4.1.0 dev: true - /playwright-chromium/1.20.2: - resolution: {integrity: sha512-KsiPLRC1v56qLWqjzeEoDZNVW/eFrP5ad0PFQAa74u5EwnnId89LgOHEZFy487tt3xJdv3Ayyfdn8zwsUpS3Qg==} + /playwright-chromium/1.21.1: + resolution: {integrity: sha512-bbqFFpcTs+3amiofja/KvTmZ+FZnMNEOuGkRyJk2p6DV9EbgRYVrlzzgLtMnX2DwaX3ZZ23MukGuQ+bVKOdsnw==} engines: {node: '>=12'} hasBin: true requiresBuild: true dependencies: - playwright-core: 1.20.2 + playwright-core: 1.21.1 transitivePeerDependencies: - bufferutil - supports-color - utf-8-validate dev: true - /playwright-core/1.20.2: - resolution: {integrity: sha512-iV6+HftSPalynkq0CYJala1vaTOq7+gU9BRfKCdM9bAxNq/lFLrwbluug2Wt5OoUwbMABcnTThIEm3/qUhCdJQ==} + /playwright-core/1.21.1: + resolution: {integrity: sha512-SbK5dEsai9ZUKlxcinqegorBq4GnftXd4/GfW+pLsdQIQWrLCM/JNh6YQ2Rf2enVykXCejtoXW8L5vJXBBVSJQ==} engines: {node: '>=12'} hasBin: true dependencies: @@ -7567,7 +7647,7 @@ packages: dependencies: import-cwd: 3.0.0 lilconfig: 2.0.4 - ts-node: 10.4.0_44ef5af6cbbc24239b4e70b5c7b0d7a6 + ts-node: 10.4.0_8726306ae516cefbf62490d54d06d905 yaml: 1.10.2 dev: false @@ -7583,7 +7663,7 @@ packages: dependencies: lilconfig: 2.0.4 postcss: 8.4.12 - ts-node: 10.4.0_44ef5af6cbbc24239b4e70b5c7b0d7a6 + ts-node: 10.4.0_8726306ae516cefbf62490d54d06d905 yaml: 1.10.2 dev: false @@ -7601,7 +7681,7 @@ packages: dependencies: lilconfig: 2.0.5 postcss: 8.4.12 - ts-node: 10.4.0_44ef5af6cbbc24239b4e70b5c7b0d7a6 + ts-node: 10.4.0_8726306ae516cefbf62490d54d06d905 yaml: 1.10.2 dev: true @@ -8269,8 +8349,8 @@ packages: dependencies: glob: 7.2.0 - /rollup-plugin-license/2.6.1_rollup@2.62.0: - resolution: {integrity: sha512-JPtlXF0tZKyHztKJsyd3HHmQFSkXei+596Xrb/a/bHIdDhvFuNSKimCKkQpoXyspfeVQk7CNay1MyGpFHAXjvg==} + /rollup-plugin-license/2.7.0_rollup@2.62.0: + resolution: {integrity: sha512-0H1Fbuf85rvpadpmAaairdahzQHY0zHtcXkOFV5EStjX9aMCO2Hz5AQp/zZe+K/PB3o6As7R9uzcb8Pw1K94dg==} engines: {node: '>=10.0.0'} peerDependencies: rollup: ^1.0.0 || ^2.0.0 @@ -8278,10 +8358,10 @@ packages: commenting: 1.1.0 glob: 7.2.0 lodash: 4.17.21 - magic-string: 0.25.7 + magic-string: 0.26.1 mkdirp: 1.0.4 - moment: 2.29.1 - package-name-regex: 2.0.5 + moment: 2.29.2 + package-name-regex: 2.0.6 rollup: 2.62.0 spdx-expression-validate: 2.0.0 spdx-satisfies: 5.0.1 @@ -8381,12 +8461,12 @@ packages: lru-cache: 6.0.0 dev: false - /semver/7.3.6: - resolution: {integrity: sha512-HZWqcgwLsjaX1HBD31msI/rXktuIhS+lWvdE4kN9z+8IVT4Itc7vqU2WvYsyD6/sjYCt4dEKH/m1M3dwI9CC5w==} - engines: {node: ^10.0.0 || ^12.0.0 || ^14.0.0 || >=16.0.0} + /semver/7.3.7: + resolution: {integrity: sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==} + engines: {node: '>=10'} hasBin: true dependencies: - lru-cache: 7.8.1 + lru-cache: 6.0.0 dev: true /send/0.17.2: @@ -9161,12 +9241,12 @@ packages: json5: 2.2.1 lodash.memoize: 4.1.2 make-error: 1.3.6 - semver: 7.3.6 + semver: 7.3.7 typescript: 4.5.4 yargs-parser: 20.2.9 dev: true - /ts-node/10.4.0_44ef5af6cbbc24239b4e70b5c7b0d7a6: + /ts-node/10.4.0_8726306ae516cefbf62490d54d06d905: resolution: {integrity: sha512-g0FlPvvCXSIO1JDF6S232P5jPYqBkRL9qly81ZgAOSU7rwI0stphCgd2kLiCrU9DjQCrJMWEqcNSjQL02s6d8A==} hasBin: true peerDependencies: @@ -9185,7 +9265,7 @@ packages: '@tsconfig/node12': 1.0.9 '@tsconfig/node14': 1.0.1 '@tsconfig/node16': 1.0.2 - '@types/node': 16.11.26 + '@types/node': 16.11.27 acorn: 8.7.0 acorn-walk: 8.2.0 arg: 4.1.3 @@ -9463,6 +9543,16 @@ packages: '@vue/server-renderer': 3.2.31_vue@3.2.31 '@vue/shared': 3.2.31 + /vue/3.2.33: + resolution: {integrity: sha512-si1ExAlDUrLSIg/V7D/GgA4twJwfsfgG+t9w10z38HhL/HA07132pUQ2KuwAo8qbCyMJ9e6OqrmWrOCr+jW7ZQ==} + dependencies: + '@vue/compiler-dom': 3.2.33 + '@vue/compiler-sfc': 3.2.33 + '@vue/runtime-dom': 3.2.33 + '@vue/server-renderer': 3.2.33_vue@3.2.33 + '@vue/shared': 3.2.33 + dev: true + /vuex/4.0.2_vue@3.2.26: resolution: {integrity: sha512-M6r8uxELjZIK8kTKDGgZTYX/ahzblnzC4isU1tpmEuOIIKmV+TRdc+H4s8ds2NuZ7wpUTdGRzJRtoj+lI+pc0Q==} peerDependencies: From 9c6501d9c363eaa3c1e7708d531fb2a92b633db6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Wed, 20 Apr 2022 06:03:19 +0900 Subject: [PATCH 066/175] docs: make it clear that array format can only be used for inline postcss config (#7815) --- docs/config/index.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/config/index.md b/docs/config/index.md index 4f1b3efbd16198..bab7df7a144987 100644 --- a/docs/config/index.md +++ b/docs/config/index.md @@ -306,7 +306,11 @@ export default defineConfig(({ command, mode }) => { - **Type:** `string | (postcss.ProcessOptions & { plugins?: postcss.Plugin[] })` - Inline PostCSS config (expects the same format as `postcss.config.js`), or a custom directory to search PostCSS config from (default is project root). The search is done using [postcss-load-config](https://github.com/postcss/postcss-load-config) and only the supported config file names are loaded. + Inline PostCSS config or a custom directory to search PostCSS config from (default is project root). + + For inline PostCSS config, it expects the same format as `postcss.config.js`. But for `plugins` property, only [array format](https://github.com/postcss/postcss-load-config/blob/main/README.md#array) can be used. + + The search is done using [postcss-load-config](https://github.com/postcss/postcss-load-config) and only the supported config file names are loaded. Note if an inline config is provided, Vite will not search for other PostCSS config sources. From f4148482089504516d85e234d9f231fcf41e3d20 Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Wed, 20 Apr 2022 16:00:05 +0800 Subject: [PATCH 067/175] ci: use action-semantic-pull-request (#7826) --- .github/workflows/semantic-pull-request.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .github/workflows/semantic-pull-request.yml diff --git a/.github/workflows/semantic-pull-request.yml b/.github/workflows/semantic-pull-request.yml new file mode 100644 index 00000000000000..df554b38e75246 --- /dev/null +++ b/.github/workflows/semantic-pull-request.yml @@ -0,0 +1,18 @@ +name: Semantic Pull Request + +on: + pull_request_target: + types: + - opened + - edited + - synchronize + +jobs: + main: + runs-on: ubuntu-latest + name: Semantic Pull Request + steps: + - name: Validate PR title + uses: amannn/action-semantic-pull-request@v4 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 709776f544adfddd7ac8e5b77a821bc3c86357fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Wed, 20 Apr 2022 18:12:43 +0900 Subject: [PATCH 068/175] fix: modulepreload polyfill only during build (fix #4786) (#7816) --- .../__tests__/backend-integration.spec.ts | 6 ++++++ .../backend-integration/frontend/entrypoints/main.ts | 2 ++ packages/vite/src/node/plugins/modulePreloadPolyfill.ts | 3 ++- scripts/jestPerTestSetup.ts | 8 ++++++++ 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/packages/playground/backend-integration/__tests__/backend-integration.spec.ts b/packages/playground/backend-integration/__tests__/backend-integration.spec.ts index 3e189972f4baed..7eebc9c27ff05a 100644 --- a/packages/playground/backend-integration/__tests__/backend-integration.spec.ts +++ b/packages/playground/backend-integration/__tests__/backend-integration.spec.ts @@ -32,6 +32,12 @@ if (isBuild) { expect(htmlEntry.assets.length).toEqual(1) }) } else { + test('No ReferenceError', async () => { + browserErrors.forEach((error) => { + expect(error.name).not.toBe('ReferenceError') + }) + }) + describe('CSS HMR', () => { test('preserve the base in CSS HMR', async () => { await untilUpdated(() => getColor('body'), 'black') // sanity check diff --git a/packages/playground/backend-integration/frontend/entrypoints/main.ts b/packages/playground/backend-integration/frontend/entrypoints/main.ts index b95a989ada81c2..f5a332191dd9e4 100644 --- a/packages/playground/backend-integration/frontend/entrypoints/main.ts +++ b/packages/playground/backend-integration/frontend/entrypoints/main.ts @@ -1,3 +1,5 @@ +import 'vite/modulepreload-polyfill' + export const colorClass = 'text-black' export function colorHeading() { diff --git a/packages/vite/src/node/plugins/modulePreloadPolyfill.ts b/packages/vite/src/node/plugins/modulePreloadPolyfill.ts index 0ad1ed2e0d30a4..4f0b3389fcc2c3 100644 --- a/packages/vite/src/node/plugins/modulePreloadPolyfill.ts +++ b/packages/vite/src/node/plugins/modulePreloadPolyfill.ts @@ -5,7 +5,8 @@ import { isModernFlag } from './importAnalysisBuild' export const modulePreloadPolyfillId = 'vite/modulepreload-polyfill' export function modulePreloadPolyfillPlugin(config: ResolvedConfig): Plugin { - const skip = config.build.ssr + // `isModernFlag` is only available during build since it is resolved by `vite:build-import-analysis` + const skip = config.command !== 'build' || config.build.ssr let polyfillString: string | undefined return { diff --git a/scripts/jestPerTestSetup.ts b/scripts/jestPerTestSetup.ts index fcdca77ee9a6eb..43258b3c8b0d6e 100644 --- a/scripts/jestPerTestSetup.ts +++ b/scripts/jestPerTestSetup.ts @@ -24,6 +24,7 @@ declare global { const page: Page | undefined const browserLogs: string[] + const browserErrors: Error[] const serverLogs: string[] const viteTestUrl: string | undefined const watcher: RollupWatcher | undefined @@ -34,6 +35,7 @@ declare const global: { page?: Page browserLogs: string[] + browserErrors: Error[] serverLogs: string[] viteTestUrl?: string watcher?: RollupWatcher @@ -56,6 +58,11 @@ const onConsole = (msg: ConsoleMessage) => { logs.push(msg.text()) } +const errors: Error[] = (global.browserErrors = []) +const onPageError = (error: Error) => { + errors.push(error) +} + beforeAll(async () => { const page = global.page if (!page) { @@ -63,6 +70,7 @@ beforeAll(async () => { } try { page.on('console', onConsole) + page.on('pageerror', onPageError) const testPath = expect.getState().testPath const testName = slash(testPath).match(/playground\/([\w-]+)\//)?.[1] From fde54c9a9c01c114bbac94312666ec3e291edcd3 Mon Sep 17 00:00:00 2001 From: yoho Date: Wed, 20 Apr 2022 23:25:53 +0800 Subject: [PATCH 069/175] docs: test env different from production (#7710) Co-authored-by: Bjorn Lu --- CONTRIBUTING.md | 2 ++ scripts/jestPerTestSetup.ts | 1 + 2 files changed, 3 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f086627de5cfe0..c7020c97a84c80 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -95,6 +95,8 @@ test('should work', async () => { Some common test helpers, e.g. `testDir`, `isBuild` or `editFile` are available in `packages/playground/testUtils.ts`. +Note: The test build environment uses a [different default set of Vite config](https://github.com/vitejs/vite/blob/9c6501d9c363eaa3c1e7708d531fb2a92b633db6/scripts/jestPerTestSetup.ts#L102-L122) to skip transpilation during tests to make it faster. This may produce a different result compared to the default production build. + ### Extending the Test Suite To add new tests, you should find a related playground to the fix or feature (or create a new one). As an example, static assets loading are tested in the [assets playground](https://github.com/vitejs/vite/tree/main/packages/playground/assets). In this Vite App, there is a test for `?raw` imports, with [a section is defined in the `index.html` for it](https://github.com/vitejs/vite/blob/71215533ac60e8ff566dc3467feabfc2c71a01e2/packages/playground/assets/index.html#L121): diff --git a/scripts/jestPerTestSetup.ts b/scripts/jestPerTestSetup.ts index 43258b3c8b0d6e..f4c9db03627c7c 100644 --- a/scripts/jestPerTestSetup.ts +++ b/scripts/jestPerTestSetup.ts @@ -123,6 +123,7 @@ beforeAll(async () => { } }, build: { + // esbuild do not minify ES lib output since that would remove pure annotations and break tree-shaking // skip transpilation during tests to make it faster target: 'esnext' }, From 0b2d307a086d4359822ef1373c884fd2cbdcb953 Mon Sep 17 00:00:00 2001 From: Fran Dios Date: Thu, 21 Apr 2022 01:19:11 +0200 Subject: [PATCH 070/175] fix: ssr.noExternal with boolean values (#7813) --- packages/playground/ssr-webworker/vite.config.js | 11 ++++++++++- packages/vite/src/node/config.ts | 3 ++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/playground/ssr-webworker/vite.config.js b/packages/playground/ssr-webworker/vite.config.js index 80cc1784cdc565..91a0571380608e 100644 --- a/packages/playground/ssr-webworker/vite.config.js +++ b/packages/playground/ssr-webworker/vite.config.js @@ -10,9 +10,18 @@ module.exports = { }, ssr: { target: 'webworker', - noExternal: true + noExternal: ['this-should-be-replaced-by-the-boolean'] }, plugins: [ + { + config() { + return { + ssr: { + noExternal: true + } + } + } + }, { config() { return { diff --git a/packages/vite/src/node/config.ts b/packages/vite/src/node/config.ts index 556fcf7cbae77a..d242ac632c220e 100644 --- a/packages/vite/src/node/config.ts +++ b/packages/vite/src/node/config.ts @@ -745,7 +745,8 @@ function mergeConfigRecursively( } else if (key === 'assetsInclude' && rootPath === '') { merged[key] = [].concat(existing, value) continue - } else if (key === 'noExternal' && existing === true) { + } else if (key === 'noExternal' && (existing === true || value === true)) { + merged[key] = true continue } From 1d468c8e6f02b0d0e362aa2d6542af1e1f55ab45 Mon Sep 17 00:00:00 2001 From: yoho Date: Thu, 21 Apr 2022 07:21:54 +0800 Subject: [PATCH 071/175] fix: escape character in string regexp match (#7834) --- .../src/node/__tests__/cleanString.spec.ts | 19 +++++++++++++++++++ packages/vite/src/node/cleanString.ts | 12 ++++++++++-- packages/vite/src/node/plugins/css.ts | 17 ++++++++++------- packages/vite/src/node/plugins/html.ts | 3 ++- 4 files changed, 41 insertions(+), 10 deletions(-) diff --git a/packages/vite/src/node/__tests__/cleanString.spec.ts b/packages/vite/src/node/__tests__/cleanString.spec.ts index 1065a2d4985ceb..b77f4c0fb5fbad 100644 --- a/packages/vite/src/node/__tests__/cleanString.spec.ts +++ b/packages/vite/src/node/__tests__/cleanString.spec.ts @@ -32,6 +32,25 @@ test('strings', () => { expect(clean).toMatch('const b = "\0\0\0\0"') }) +test('escape character', () => { + const clean = emptyString(` + '1\\'1' + "1\\"1" + "1\\"1\\"1" + "1\\'1'\\"1" + "1'1'" + "1'\\'1\\''\\"1\\"\\"" + '1"\\"1\\""\\"1\\"\\"' + '""1""' + '"""1"""' + '""""1""""' + "''1''" + "'''1'''" + "''''1''''" + `) + expect(clean).not.toMatch('1') +}) + test('strings comment nested', () => { expect( emptyString(` diff --git a/packages/vite/src/node/cleanString.ts b/packages/vite/src/node/cleanString.ts index 05163ea055b631..2b7cba41aef66b 100644 --- a/packages/vite/src/node/cleanString.ts +++ b/packages/vite/src/node/cleanString.ts @@ -2,7 +2,8 @@ import type { RollupError } from 'rollup' // bank on the non-overlapping nature of regex matches and combine all filters into one giant regex // /`([^`\$\{\}]|\$\{(`|\g<1>)*\})*`/g can match nested string template // but js not support match expression(\g<0>). so clean string template(`...`) in other ways. -const cleanerRE = /"[^"]*"|'[^']*'|\/\*(.|[\r\n])*?\*\/|\/\/.*/g +const cleanerRE = + /"([^"]|(?<=\\)")*"|'([^']|(?<=\\)')*'|\/\*(.|[\r\n])*?\*\/|\/\/.*/g const blankReplacer = (s: string) => ' '.repeat(s.length) const stringBlankReplacer = (s: string) => @@ -25,9 +26,16 @@ export function emptyString(raw: string): string { } const enum LexerState { + // template string inTemplateString, inInterpolationExpression, - inObjectExpression + inObjectExpression, + // strings + inSingleQuoteString, + inDoubleQuoteString, + // comments + inMultilineCommentsRE, + inSinglelineCommentsRE } function replaceAt( diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index 2f5ab3df58b46a..83e18aabecdb33 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -1122,7 +1122,7 @@ export async function hoistAtRules(css: string) { // to top when multiple files are concatenated. // match until semicolon that's not in quotes s.replace( - /@import\s*(?:url\([^\)]*\)|"[^"]*"|'[^']*'|[^;]*).*?;/gm, + /@import\s*(?:url\([^\)]*\)|"([^"]|(?<=\\)")*"|'([^']|(?<=\\)')*'|[^;]*).*?;/gm, (match) => { s.appendLeft(0, match) return '' @@ -1131,13 +1131,16 @@ export async function hoistAtRules(css: string) { // #6333 // CSS @charset must be the top-first in the file, hoist the first to top let foundCharset = false - s.replace(/@charset\s*(?:"[^"]*"|'[^']*'|[^;]*).*?;/gm, (match) => { - if (!foundCharset) { - s.prepend(match) - foundCharset = true + s.replace( + /@charset\s*(?:"([^"]|(?<=\\)")*"|'([^']|(?<=\\)')*'|[^;]*).*?;/gm, + (match) => { + if (!foundCharset) { + s.prepend(match) + foundCharset = true + } + return '' } - return '' - }) + ) return s.toString() } diff --git a/packages/vite/src/node/plugins/html.ts b/packages/vite/src/node/plugins/html.ts index 5c86b6c0ac6073..e8df0825ddb3fa 100644 --- a/packages/vite/src/node/plugins/html.ts +++ b/packages/vite/src/node/plugins/html.ts @@ -46,7 +46,8 @@ interface ScriptAssetsUrl { const htmlProxyRE = /\?html-proxy=?[&inline\-css]*&index=(\d+)\.(js|css)$/ const inlineCSSRE = /__VITE_INLINE_CSS__([^_]+_\d+)__/g // Do not allow preceding '.', but do allow preceding '...' for spread operations -const inlineImportRE = /(? htmlProxyRE.test(id) From 72abe488b5ce52d21977c9ba35d6c590e47dbe05 Mon Sep 17 00:00:00 2001 From: chris-zhu <1633711653@qq.com> Date: Thu, 21 Apr 2022 18:49:59 +0800 Subject: [PATCH 072/175] docs(api-hmr): update hmr hot type (#7787) --- docs/guide/api-hmr.md | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/docs/guide/api-hmr.md b/docs/guide/api-hmr.md index 46eabab04e8868..1cba492e6613c1 100644 --- a/docs/guide/api-hmr.md +++ b/docs/guide/api-hmr.md @@ -10,21 +10,27 @@ Vite exposes its manual HMR API via the special `import.meta.hot` object: ```ts interface ImportMeta { - readonly hot?: { - readonly data: any + readonly hot?: ViteHotContext +} + +interface ViteHotContext { + readonly data: any - accept(): void - accept(cb: (mod: any) => void): void - accept(dep: string, cb: (mod: any) => void): void - accept(deps: string[], cb: (mods: any[]) => void): void + accept(): void + accept(cb: (mod: any) => void): void + accept(dep: string, cb: (mod: any) => void): void + accept(deps: readonly string[], cb: (mods: any[]) => void): void - prune(cb: () => void): void - dispose(cb: (data: any) => void): void - decline(): void - invalidate(): void + dispose(cb: (data: any) => void): void + decline(): void + invalidate(): void - on(event: string, cb: (...args: any[]) => void): void - } + // `InferCustomEventPayload` provides types for built-in Vite events + on( + event: T, + cb: (payload: InferCustomEventPayload) => void + ): void + send(event: T, data?: InferCustomEventPayload): void } ``` From e29d1d92f7810c5160aac2f1e56f7b03bfa4c933 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 21 Apr 2022 16:32:19 +0200 Subject: [PATCH 073/175] chore(deps): update all non-major dependencies (#7847) --- package.json | 4 +-- packages/plugin-legacy/package.json | 2 +- packages/vite/package.json | 2 +- pnpm-lock.yaml | 49 ++++++++++++++++------------- 4 files changed, 31 insertions(+), 26 deletions(-) diff --git a/package.json b/package.json index a90c2c9a43b3fe..701da1e4ef7887 100644 --- a/package.json +++ b/package.json @@ -46,12 +46,12 @@ "cross-env": "^7.0.3", "esbuild": "^0.14.27", "eslint": "^8.13.0", - "eslint-define-config": "^1.3.0", + "eslint-define-config": "^1.4.0", "eslint-plugin-node": "^11.1.0", "execa": "^5.1.1", "fs-extra": "^10.1.0", "jest": "^27.5.1", - "lint-staged": "^12.3.8", + "lint-staged": "^12.4.0", "minimist": "^1.2.6", "node-fetch": "^2.6.6", "npm-run-all": "^4.1.5", diff --git a/packages/plugin-legacy/package.json b/packages/plugin-legacy/package.json index 3734390a3cdf25..adc97e974f2d37 100644 --- a/packages/plugin-legacy/package.json +++ b/packages/plugin-legacy/package.json @@ -23,7 +23,7 @@ "homepage": "https://github.com/vitejs/vite/tree/main/packages/plugin-legacy#readme", "dependencies": { "@babel/standalone": "^7.17.9", - "core-js": "^3.22.0", + "core-js": "^3.22.2", "magic-string": "^0.26.1", "regenerator-runtime": "^0.13.9", "systemjs": "^6.12.1" diff --git a/packages/vite/package.json b/packages/vite/package.json index 50f8487ad55895..0fd8b867dfe042 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -55,7 +55,7 @@ "@ampproject/remapping": "^2.1.2", "@babel/parser": "^7.17.9", "@babel/types": "^7.17.0", - "@jridgewell/trace-mapping": "^0.3.4", + "@jridgewell/trace-mapping": "^0.3.9", "@rollup/plugin-alias": "^3.1.9", "@rollup/plugin-commonjs": "^21.1.0", "@rollup/plugin-dynamic-import-vars": "^1.4.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 235dd8c48a30ca..140dabd1e04eb5 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -22,12 +22,12 @@ importers: cross-env: ^7.0.3 esbuild: ^0.14.27 eslint: ^8.13.0 - eslint-define-config: ^1.3.0 + eslint-define-config: ^1.4.0 eslint-plugin-node: ^11.1.0 execa: ^5.1.1 fs-extra: ^10.1.0 jest: ^27.5.1 - lint-staged: ^12.3.8 + lint-staged: ^12.4.0 minimist: ^1.2.6 node-fetch: ^2.6.6 npm-run-all: ^4.1.5 @@ -58,12 +58,12 @@ importers: cross-env: 7.0.3 esbuild: 0.14.27 eslint: 8.13.0 - eslint-define-config: 1.3.0 + eslint-define-config: 1.4.0 eslint-plugin-node: 11.1.0_eslint@8.13.0 execa: 5.1.1 fs-extra: 10.1.0 jest: 27.5.1_ts-node@10.4.0 - lint-staged: 12.3.8 + lint-staged: 12.4.0 minimist: 1.2.6 node-fetch: 2.6.6 npm-run-all: 4.1.5 @@ -744,13 +744,13 @@ importers: packages/plugin-legacy: specifiers: '@babel/standalone': ^7.17.9 - core-js: ^3.22.0 + core-js: ^3.22.2 magic-string: ^0.26.1 regenerator-runtime: ^0.13.9 systemjs: ^6.12.1 dependencies: '@babel/standalone': 7.17.9 - core-js: 3.22.0 + core-js: 3.22.2 magic-string: 0.26.1 regenerator-runtime: 0.13.9 systemjs: 6.12.1 @@ -816,7 +816,7 @@ importers: '@ampproject/remapping': ^2.1.2 '@babel/parser': ^7.17.9 '@babel/types': ^7.17.0 - '@jridgewell/trace-mapping': ^0.3.4 + '@jridgewell/trace-mapping': ^0.3.9 '@rollup/plugin-alias': ^3.1.9 '@rollup/plugin-commonjs': ^21.1.0 '@rollup/plugin-dynamic-import-vars': ^1.4.3 @@ -894,7 +894,7 @@ importers: '@ampproject/remapping': 2.1.2 '@babel/parser': 7.17.9 '@babel/types': 7.17.0 - '@jridgewell/trace-mapping': 0.3.4 + '@jridgewell/trace-mapping': 0.3.9 '@rollup/plugin-alias': 3.1.9_rollup@2.62.0 '@rollup/plugin-commonjs': 21.1.0_rollup@2.62.0 '@rollup/plugin-dynamic-import-vars': 1.4.3_rollup@2.62.0 @@ -1080,7 +1080,7 @@ packages: resolution: {integrity: sha512-hoyByceqwKirw7w3Z7gnIIZC3Wx3J484Y3L/cMpXFbr7d9ZQj2mODrirNzcJa+SM3UlpWXYvKV4RlRpFXlWgXg==} engines: {node: '>=6.0.0'} dependencies: - '@jridgewell/trace-mapping': 0.3.4 + '@jridgewell/trace-mapping': 0.3.9 /@babel/code-frame/7.16.0: resolution: {integrity: sha512-IF4EOMEV+bfYwOmNxGzSnjR2EmQod7f1UXOpZM3l4i4o4QNwzjtJAu/HxdjHq0aYBvdqMuQEY1eg0nqW9ZPORA==} @@ -2210,6 +2210,13 @@ packages: dependencies: '@jridgewell/resolve-uri': 3.0.5 '@jridgewell/sourcemap-codec': 1.4.10 + dev: true + + /@jridgewell/trace-mapping/0.3.9: + resolution: {integrity: sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==} + dependencies: + '@jridgewell/resolve-uri': 3.0.5 + '@jridgewell/sourcemap-codec': 1.4.10 /@mapbox/node-pre-gyp/1.0.8: resolution: {integrity: sha512-CMGKi28CF+qlbXh26hDe6NxCd7amqeAzEqnS6IHeO6LoaKyM/n+Xw3HT1COdq8cuioOdlKdqn/hCmqPUOMOywg==} @@ -3355,7 +3362,7 @@ packages: /axios/0.24.0: resolution: {integrity: sha512-Q6cWsys88HoPgAaFAVUb0WpPk0O8iTeisR9IMqy9G8AbO4NlpVknrnQS03zzF9PGAWgO3cgletO3VjV/P7VztA==} dependencies: - follow-redirects: 1.14.6_debug@4.3.4 + follow-redirects: 1.14.6 transitivePeerDependencies: - debug dev: false @@ -4081,8 +4088,8 @@ packages: is-what: 3.14.1 dev: true - /core-js/3.22.0: - resolution: {integrity: sha512-8h9jBweRjMiY+ORO7bdWSeWfHhLPO7whobj7Z2Bl0IDo00C228EdGgH7FE4jGumbEjzcFfkfW8bXgdkEDhnwHQ==} + /core-js/3.22.2: + resolution: {integrity: sha512-Z5I2vzDnEIqO2YhELVMFcL1An2CIsFe9Q7byZhs8c/QxummxZlAHw33TUHbIte987LkisOgL0LwQ1P9D6VISnA==} requiresBuild: true dev: false @@ -4787,9 +4794,9 @@ packages: source-map: 0.6.1 dev: true - /eslint-define-config/1.3.0: - resolution: {integrity: sha512-sFbHUnaXdJfG74c0EfFjXajjM3ugDVOMteKBnddCHQP5eas6p3nmS7PbSVhyZ8Y9DaNNtFbzlovdGmVdTwrHcw==} - engines: {node: '>= 16.9.0', npm: '>= 7.0.0', pnpm: '>= 6.32.2'} + /eslint-define-config/1.4.0: + resolution: {integrity: sha512-DJGEdzX4fkdkhPSzPgOpBbBjhT+b9DcgbAgxfrEUcipVWlSuesQJriKffHz1JF5mhKFm7PGoiZz4D2nb4GslNA==} + engines: {node: '>= 14.6.0', npm: '>= 6.0.0', pnpm: '>= 6.32.9'} dev: true /eslint-plugin-es/3.0.1_eslint@8.13.0: @@ -5168,7 +5175,7 @@ packages: resolution: {integrity: sha512-8/sOawo8tJ4QOBX8YlQBMxL8+RLZfxMQOif9o0KUKTNTjMYElWPE0r/m5VNFxTRd0NSw8qSy8dajrwX4RYI1Hw==} dev: true - /follow-redirects/1.14.6_debug@4.3.4: + /follow-redirects/1.14.6: resolution: {integrity: sha512-fhUl5EwSJbbl8AR+uYL2KQDxLkdSjZGR36xy46AO7cOMTrCMON6Sa28FmAnC2tRTDbd/Uuzz3aJBv7EBN7JH8A==} engines: {node: '>=4.0'} peerDependencies: @@ -5176,8 +5183,6 @@ packages: peerDependenciesMeta: debug: optional: true - dependencies: - debug: 4.3.4 /form-data/3.0.1: resolution: {integrity: sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==} @@ -5578,7 +5583,7 @@ packages: engines: {node: '>=8.0.0'} dependencies: eventemitter3: 4.0.7 - follow-redirects: 1.14.6_debug@4.3.4 + follow-redirects: 1.14.6 requires-port: 1.0.0 transitivePeerDependencies: - debug @@ -6082,7 +6087,7 @@ packages: jest-runner: 27.5.1 jest-util: 27.5.1 jest-validate: 27.5.1 - micromatch: 4.0.4 + micromatch: 4.0.5 parse-json: 5.2.0 pretty-format: 27.5.1 slash: 3.0.0 @@ -6663,8 +6668,8 @@ packages: /lines-and-columns/1.2.4: resolution: {integrity: sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==} - /lint-staged/12.3.8: - resolution: {integrity: sha512-0+UpNaqIwKRSGAFOCcpuYNIv/j5QGVC+xUVvmSdxHO+IfIGoHbFLo3XcPmV/LLnsVj5EAncNHVtlITSoY5qWGQ==} + /lint-staged/12.4.0: + resolution: {integrity: sha512-3X7MR0h9b7qf4iXf/1n7RlVAx+EzpAZXoCEMhVSpaBlgKDfH2ewf+QUm7BddFyq29v4dgPP+8+uYpWuSWx035A==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} hasBin: true dependencies: From d7540c8bd43c889253dc1e8ed040a20f9959e083 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Thu, 21 Apr 2022 23:32:45 +0900 Subject: [PATCH 074/175] fix: update sourcemap in importAnalysisBuild (#7825) --- .../src/node/plugins/importAnalysisBuild.ts | 61 +++++++++++++++---- packages/vite/src/node/server/sourcemap.ts | 2 +- packages/vite/src/node/utils.ts | 7 ++- 3 files changed, 53 insertions(+), 17 deletions(-) diff --git a/packages/vite/src/node/plugins/importAnalysisBuild.ts b/packages/vite/src/node/plugins/importAnalysisBuild.ts index 91ce663b9f8111..9f4c75025fff27 100644 --- a/packages/vite/src/node/plugins/importAnalysisBuild.ts +++ b/packages/vite/src/node/plugins/importAnalysisBuild.ts @@ -4,10 +4,12 @@ import type { Plugin } from '../plugin' import MagicString from 'magic-string' import type { ImportSpecifier } from 'es-module-lexer' import { init, parse as parseImports } from 'es-module-lexer' -import type { OutputChunk } from 'rollup' +import type { OutputChunk, SourceMap } from 'rollup' import { isCSSRequest, removedPureCssFilesCache } from './css' import { transformImportGlob } from '../importGlob' -import { bareImportRE } from '../utils' +import { bareImportRE, combineSourcemaps } from '../utils' +import type { RawSourceMap } from '@ampproject/remapping' +import { genSourceMapUrl } from '../server/sourcemap' /** * A flag for injected helpers. This flag will be set to `false` if the output @@ -20,7 +22,7 @@ export const preloadMarker = `__VITE_PRELOAD__` export const preloadBaseMarker = `__VITE_PRELOAD_BASE__` const preloadHelperId = 'vite/preload-helper' -const preloadMarkerRE = new RegExp(`"${preloadMarker}"`, 'g') +const preloadMarkerWithQuote = `"${preloadMarker}"` as const /** * Helper for preloading CSS and direct imports of async chunks in parallel to @@ -263,8 +265,10 @@ export function buildImportAnalysisPlugin(config: ResolvedConfig): Plugin { this.error(e, e.idx) } + const s = new MagicString(code) + const rewroteMarkerStartPos = new Set() // position of the leading double quote + if (imports.length) { - const s = new MagicString(code) for (let index = 0; index < imports.length; index++) { // To handle escape sequences in specifier strings, the .n field will be provided where possible. const { @@ -324,16 +328,16 @@ export function buildImportAnalysisPlugin(config: ResolvedConfig): Plugin { addDeps(normalizedFile) } - let markPos = code.indexOf(preloadMarker, end) + let markerStartPos = code.indexOf(preloadMarkerWithQuote, end) // fix issue #3051 - if (markPos === -1 && imports.length === 1) { - markPos = code.indexOf(preloadMarker) + if (markerStartPos === -1 && imports.length === 1) { + markerStartPos = code.indexOf(preloadMarkerWithQuote) } - if (markPos > 0) { + if (markerStartPos > 0) { s.overwrite( - markPos - 1, - markPos + preloadMarker.length + 1, + markerStartPos, + markerStartPos + preloadMarkerWithQuote.length, // the dep list includes the main chunk, so only need to // preload when there are actual other deps. deps.size > 1 || @@ -343,15 +347,46 @@ export function buildImportAnalysisPlugin(config: ResolvedConfig): Plugin { : `[]`, { contentOnly: true } ) + rewroteMarkerStartPos.add(markerStartPos) } } - chunk.code = s.toString() - // TODO source map } // there may still be markers due to inlined dynamic imports, remove // all the markers regardless - chunk.code = chunk.code.replace(preloadMarkerRE, 'void 0') + let markerStartPos = code.indexOf(preloadMarkerWithQuote) + while (markerStartPos >= 0) { + if (!rewroteMarkerStartPos.has(markerStartPos)) { + s.overwrite( + markerStartPos, + markerStartPos + preloadMarkerWithQuote.length, + 'void 0', + { contentOnly: true } + ) + } + + markerStartPos = code.indexOf( + preloadMarkerWithQuote, + markerStartPos + preloadMarkerWithQuote.length + ) + } + + if (s.hasChanged()) { + chunk.code = s.toString() + if (config.build.sourcemap && chunk.map) { + const nextMap = s.generateMap({ + source: chunk.fileName, + hires: true + }) + const map = combineSourcemaps( + chunk.fileName, + [nextMap as RawSourceMap, chunk.map as RawSourceMap], + false + ) as SourceMap + map.toUrl = () => genSourceMapUrl(map) + chunk.map = map + } + } } } } diff --git a/packages/vite/src/node/server/sourcemap.ts b/packages/vite/src/node/server/sourcemap.ts index dc77c4a4714298..0b9bcf9284754b 100644 --- a/packages/vite/src/node/server/sourcemap.ts +++ b/packages/vite/src/node/server/sourcemap.ts @@ -61,7 +61,7 @@ export async function injectSourcesContent( } } -function genSourceMapUrl(map: SourceMap | string | undefined) { +export function genSourceMapUrl(map: SourceMap | string | undefined) { if (typeof map !== 'string') { map = JSON.stringify(map) } diff --git a/packages/vite/src/node/utils.ts b/packages/vite/src/node/utils.ts index 16391df8c73df3..e7a20afbdd5ae7 100644 --- a/packages/vite/src/node/utils.ts +++ b/packages/vite/src/node/utils.ts @@ -605,7 +605,8 @@ const nullSourceMap: RawSourceMap = { } export function combineSourcemaps( filename: string, - sourcemapList: Array + sourcemapList: Array, + excludeContent = true ): RawSourceMap { if ( sourcemapList.length === 0 || @@ -635,7 +636,7 @@ export function combineSourcemaps( const useArrayInterface = sourcemapList.slice(0, -1).find((m) => m.sources.length !== 1) === undefined if (useArrayInterface) { - map = remapping(sourcemapList, () => null, true) + map = remapping(sourcemapList, () => null, excludeContent) } else { map = remapping( sourcemapList[0], @@ -646,7 +647,7 @@ export function combineSourcemaps( return null } }, - true + excludeContent ) } if (!map.file) { From ba43c29a7920ab8356b3fcb16ca3a11dc7e5713e Mon Sep 17 00:00:00 2001 From: yoho Date: Fri, 22 Apr 2022 14:18:07 +0800 Subject: [PATCH 075/175] fix: style use string instead of js import (#7786) --- .../playground/worker/__tests__/es/es-worker.spec.ts | 2 +- .../playground/worker/__tests__/iife/worker.spec.ts | 2 +- .../sourcemap-hidden/sourcemap-hidden-worker.spec.ts | 2 +- .../sourcemap-inline/sourcemap-inline-worker.spec.ts | 2 +- .../__tests__/sourcemap/sourcemap-worker.spec.ts | 2 +- packages/vite/src/node/plugins/html.ts | 11 +++++++++-- 6 files changed, 14 insertions(+), 7 deletions(-) diff --git a/packages/playground/worker/__tests__/es/es-worker.spec.ts b/packages/playground/worker/__tests__/es/es-worker.spec.ts index c7fd0d6c19e4bc..a815596721c268 100644 --- a/packages/playground/worker/__tests__/es/es-worker.spec.ts +++ b/packages/playground/worker/__tests__/es/es-worker.spec.ts @@ -60,7 +60,7 @@ if (isBuild) { // assert correct files test('inlined code generation', async () => { const files = fs.readdirSync(assetsDir) - expect(files.length).toBe(22) + expect(files.length).toBe(21) const index = files.find((f) => f.includes('main-module')) const content = fs.readFileSync(path.resolve(assetsDir, index), 'utf-8') const worker = files.find((f) => f.includes('my-worker')) diff --git a/packages/playground/worker/__tests__/iife/worker.spec.ts b/packages/playground/worker/__tests__/iife/worker.spec.ts index fa9f72fe76131c..9be78d57edd702 100644 --- a/packages/playground/worker/__tests__/iife/worker.spec.ts +++ b/packages/playground/worker/__tests__/iife/worker.spec.ts @@ -63,7 +63,7 @@ if (isBuild) { // assert correct files test('inlined code generation', async () => { const files = fs.readdirSync(assetsDir) - expect(files.length).toBe(13) + expect(files.length).toBe(12) const index = files.find((f) => f.includes('main-module')) const content = fs.readFileSync(path.resolve(assetsDir, index), 'utf-8') const worker = files.find((f) => f.includes('my-worker')) diff --git a/packages/playground/worker/__tests__/sourcemap-hidden/sourcemap-hidden-worker.spec.ts b/packages/playground/worker/__tests__/sourcemap-hidden/sourcemap-hidden-worker.spec.ts index d846a5de2311d0..1797ac5269e411 100644 --- a/packages/playground/worker/__tests__/sourcemap-hidden/sourcemap-hidden-worker.spec.ts +++ b/packages/playground/worker/__tests__/sourcemap-hidden/sourcemap-hidden-worker.spec.ts @@ -9,7 +9,7 @@ if (isBuild) { test('sourcemap generation for web workers', async () => { const files = fs.readdirSync(assetsDir) // should have 2 worker chunk - expect(files.length).toBe(25) + expect(files.length).toBe(24) const index = files.find((f) => f.includes('main-module')) const content = fs.readFileSync(path.resolve(assetsDir, index), 'utf-8') const indexSourcemap = getSourceMapUrl(content) diff --git a/packages/playground/worker/__tests__/sourcemap-inline/sourcemap-inline-worker.spec.ts b/packages/playground/worker/__tests__/sourcemap-inline/sourcemap-inline-worker.spec.ts index ceda7dae1fec7c..89af0878213ab9 100644 --- a/packages/playground/worker/__tests__/sourcemap-inline/sourcemap-inline-worker.spec.ts +++ b/packages/playground/worker/__tests__/sourcemap-inline/sourcemap-inline-worker.spec.ts @@ -9,7 +9,7 @@ if (isBuild) { test('sourcemap generation for web workers', async () => { const files = fs.readdirSync(assetsDir) // should have 2 worker chunk - expect(files.length).toBe(13) + expect(files.length).toBe(12) const index = files.find((f) => f.includes('main-module')) const content = fs.readFileSync(path.resolve(assetsDir, index), 'utf-8') const indexSourcemap = getSourceMapUrl(content) diff --git a/packages/playground/worker/__tests__/sourcemap/sourcemap-worker.spec.ts b/packages/playground/worker/__tests__/sourcemap/sourcemap-worker.spec.ts index 54e4f1cb9f2d58..24af73d5e3edfa 100644 --- a/packages/playground/worker/__tests__/sourcemap/sourcemap-worker.spec.ts +++ b/packages/playground/worker/__tests__/sourcemap/sourcemap-worker.spec.ts @@ -9,7 +9,7 @@ if (isBuild) { test('sourcemap generation for web workers', async () => { const files = fs.readdirSync(assetsDir) // should have 2 worker chunk - expect(files.length).toBe(25) + expect(files.length).toBe(24) const index = files.find((f) => f.includes('main-module')) const content = fs.readFileSync(path.resolve(assetsDir, index), 'utf-8') const indexSourcemap = getSourceMapUrl(content) diff --git a/packages/vite/src/node/plugins/html.ts b/packages/vite/src/node/plugins/html.ts index e8df0825ddb3fa..ed4250f1965869 100644 --- a/packages/vite/src/node/plugins/html.ts +++ b/packages/vite/src/node/plugins/html.ts @@ -391,8 +391,15 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin { addToHTMLProxyCache(config, filePath, inlineModuleIndex, { code: styleNode.content }) - js += `\nimport "${id}?html-proxy&index=${inlineModuleIndex}.css"` - shouldRemove = true + js += `\nimport "${id}?html-proxy&inline-css&index=${inlineModuleIndex}.css"` + + // will transform in `applyHtmlTransforms` + s.overwrite( + styleNode.loc.start.offset, + styleNode.loc.end.offset, + `__VITE_INLINE_CSS__${cleanUrl(id)}_${inlineModuleIndex}__`, + { contentOnly: true } + ) } if (shouldRemove) { From fc89057b406fc85e01a1d4fd08f128e9b6bcba5a Mon Sep 17 00:00:00 2001 From: Shinigami Date: Fri, 22 Apr 2022 21:20:57 +0200 Subject: [PATCH 076/175] fix: node v18 support (#7812) --- .github/workflows/ci.yml | 7 ++- package.json | 2 +- packages/vite/package.json | 2 +- packages/vite/src/node/logger.ts | 10 +++- pnpm-lock.yaml | 80 ++++++++++++++++---------------- 5 files changed, 57 insertions(+), 44 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cde7dfb03825ed..2832dab118e279 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,12 +27,17 @@ jobs: strategy: matrix: os: [ubuntu-latest] - node_version: [12, 14, 16, 17] + node_version: [12, 14, 16, 17, 18] include: - os: macos-latest node_version: 16 + - os: macos-latest + node_version: 18 - os: windows-latest node_version: 16 + # Maybe bug with jest on windows and node-v18 + # - os: windows-latest + # node_version: 18 fail-fast: false name: "Build&Test: node-${{ matrix.node_version }}, ${{ matrix.os }}" diff --git a/package.json b/package.json index 701da1e4ef7887..1bfa2c4e77619c 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "@microsoft/api-extractor": "^7.22.2", "@types/fs-extra": "^9.0.13", "@types/jest": "^27.4.1", - "@types/node": "^16.11.27", + "@types/node": "^17.0.25", "@types/prompts": "^2.0.14", "@types/semver": "^7.3.9", "@typescript-eslint/eslint-plugin": "^5.20.0", diff --git a/packages/vite/package.json b/packages/vite/package.json index 0fd8b867dfe042..2d65cc1c330cad 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -71,7 +71,7 @@ "@types/less": "^3.0.3", "@types/micromatch": "^4.0.2", "@types/mime": "^2.0.3", - "@types/node": "^16.11.27", + "@types/node": "^17.0.25", "@types/resolve": "^1.20.1", "@types/sass": "~1.43.1", "@types/stylus": "^0.48.37", diff --git a/packages/vite/src/node/logger.ts b/packages/vite/src/node/logger.ts index b6cf76f2aaa432..8ece2dd8746b7f 100644 --- a/packages/vite/src/node/logger.ts +++ b/packages/vite/src/node/logger.ts @@ -190,7 +190,15 @@ function printServerUrls( } else { Object.values(os.networkInterfaces()) .flatMap((nInterface) => nInterface ?? []) - .filter((detail) => detail && detail.address && detail.family === 'IPv4') + .filter( + (detail) => + detail && + detail.address && + // Node < v18 + ((typeof detail.family === 'string' && detail.family === 'IPv4') || + // Node >= v18 + (typeof detail.family === 'number' && detail.family === 4)) + ) .map((detail) => { const type = detail.address.includes('127.0.0.1') ? 'Local: ' diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 140dabd1e04eb5..ad65e136bd1b56 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -13,7 +13,7 @@ importers: '@microsoft/api-extractor': ^7.22.2 '@types/fs-extra': ^9.0.13 '@types/jest': ^27.4.1 - '@types/node': ^16.11.27 + '@types/node': ^17.0.25 '@types/prompts': ^2.0.14 '@types/semver': ^7.3.9 '@typescript-eslint/eslint-plugin': ^5.20.0 @@ -49,7 +49,7 @@ importers: '@microsoft/api-extractor': 7.22.2 '@types/fs-extra': 9.0.13 '@types/jest': 27.4.1 - '@types/node': 16.11.27 + '@types/node': 17.0.25 '@types/prompts': 2.0.14 '@types/semver': 7.3.9 '@typescript-eslint/eslint-plugin': 5.20.0_0df7beb8e4d849cfe6bb8e844ccdebfd @@ -77,7 +77,7 @@ importers: simple-git-hooks: 2.7.0 sirv: 2.0.2 ts-jest: 27.1.4_4dfe14e0e8266437469ae0475a5c09ac - ts-node: 10.4.0_8726306ae516cefbf62490d54d06d905 + ts-node: 10.4.0_233d9fcfccc8abc8f146a08357d842da typescript: 4.5.4 vite: link:packages/vite vitepress: 0.22.3 @@ -832,7 +832,7 @@ importers: '@types/less': ^3.0.3 '@types/micromatch': ^4.0.2 '@types/mime': ^2.0.3 - '@types/node': ^16.11.27 + '@types/node': ^17.0.25 '@types/resolve': ^1.20.1 '@types/sass': ~1.43.1 '@types/stylus': ^0.48.37 @@ -910,7 +910,7 @@ importers: '@types/less': 3.0.3 '@types/micromatch': 4.0.2 '@types/mime': 2.0.3 - '@types/node': 16.11.27 + '@types/node': 17.0.25 '@types/resolve': 1.20.1 '@types/sass': 1.43.1 '@types/stylus': 0.48.37 @@ -2012,7 +2012,7 @@ packages: engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0} dependencies: '@jest/types': 27.5.1 - '@types/node': 16.11.27 + '@types/node': 17.0.25 chalk: 4.1.2 jest-message-util: 27.5.1 jest-util: 27.5.1 @@ -2033,7 +2033,7 @@ packages: '@jest/test-result': 27.5.1 '@jest/transform': 27.5.1 '@jest/types': 27.5.1 - '@types/node': 16.11.27 + '@types/node': 17.0.25 ansi-escapes: 4.3.2 chalk: 4.1.2 emittery: 0.8.1 @@ -2070,7 +2070,7 @@ packages: dependencies: '@jest/fake-timers': 27.5.1 '@jest/types': 27.5.1 - '@types/node': 16.11.27 + '@types/node': 17.0.25 jest-mock: 27.5.1 dev: true @@ -2080,7 +2080,7 @@ packages: dependencies: '@jest/types': 27.5.1 '@sinonjs/fake-timers': 8.1.0 - '@types/node': 16.11.27 + '@types/node': 17.0.25 jest-message-util: 27.5.1 jest-mock: 27.5.1 jest-util: 27.5.1 @@ -2109,7 +2109,7 @@ packages: '@jest/test-result': 27.5.1 '@jest/transform': 27.5.1 '@jest/types': 27.5.1 - '@types/node': 16.11.27 + '@types/node': 17.0.25 chalk: 4.1.2 collect-v8-coverage: 1.0.1 exit: 0.1.2 @@ -2193,7 +2193,7 @@ packages: dependencies: '@types/istanbul-lib-coverage': 2.0.4 '@types/istanbul-reports': 3.0.1 - '@types/node': 16.11.27 + '@types/node': 17.0.25 '@types/yargs': 16.0.4 chalk: 4.1.2 dev: true @@ -2541,7 +2541,7 @@ packages: /@types/cross-spawn/6.0.2: resolution: {integrity: sha512-KuwNhp3eza+Rhu8IFI5HUXRP0LIhqH5cAjubUvGXXthh4YYBuP2ntwEX+Cz8GJoZUHlKo247wPWOfA9LYEq4cw==} dependencies: - '@types/node': 16.11.27 + '@types/node': 17.0.25 dev: true /@types/debug/4.1.7: @@ -2561,19 +2561,19 @@ packages: /@types/etag/1.8.1: resolution: {integrity: sha512-bsKkeSqN7HYyYntFRAmzcwx/dKW4Wa+KVMTInANlI72PWLQmOpZu96j0OqHZGArW4VQwCmJPteQlXaUDeOB0WQ==} dependencies: - '@types/node': 16.11.27 + '@types/node': 17.0.25 dev: true /@types/fs-extra/9.0.13: resolution: {integrity: sha512-nEnwB++1u5lVDM2UI4c1+5R+FYaKfaAzS4OococimjVm3nQw3TuzH5UNsocrcTBbhnerblyHj4A49qXbIiZdpA==} dependencies: - '@types/node': 16.11.27 + '@types/node': 17.0.25 dev: true /@types/graceful-fs/4.1.5: resolution: {integrity: sha512-anKkLmZZ+xm4p8JWBf4hElkM4XR+EZeA2M9BAkkTldmcyDY4mbdIJnRghDJH3Ov5ooY7/UAoENtmdMSkaAd7Cw==} dependencies: - '@types/node': 16.11.27 + '@types/node': 17.0.25 dev: true /@types/hash-sum/1.0.0: @@ -2637,8 +2637,8 @@ packages: resolution: {integrity: sha512-qjd88DrCxupx/kJD5yQgZdcYKZKSIGBVDIBE1/LTGcNm3d2Np/jxojkdePDdfnBHJc5W7vSMpbJ1aB7p/Py69A==} dev: true - /@types/node/16.11.27: - resolution: {integrity: sha512-C1pD3kgLoZ56Uuy5lhfOxie4aZlA3UMGLX9rXteq4WitEZH6Rl80mwactt9QG0w0gLFlN/kLBTFnGXtDVWvWQw==} + /@types/node/17.0.25: + resolution: {integrity: sha512-wANk6fBrUwdpY4isjWrKTufkrXdu1D2YHCot2fD/DfWxF5sMrVSA+KN7ydckvaTCh0HiqX9IVl0L5/ZoXg5M7w==} dev: true /@types/normalize-package-data/2.4.1: @@ -2655,13 +2655,13 @@ packages: /@types/prompts/2.0.14: resolution: {integrity: sha512-HZBd99fKxRWpYCErtm2/yxUZv6/PBI9J7N4TNFffl5JbrYMHBwF25DjQGTW3b3jmXq+9P6/8fCIb2ee57BFfYA==} dependencies: - '@types/node': 16.11.27 + '@types/node': 17.0.25 dev: true /@types/resolve/1.17.1: resolution: {integrity: sha512-yy7HuzQhj0dhGpD8RLXSZWEkLsV9ibvxvi6EiJ3bkqLAO1RGo0WbkWQiwpRlSFymTJRz0d3k5LM3kkx8ArDbLw==} dependencies: - '@types/node': 16.11.27 + '@types/node': 17.0.25 dev: true /@types/resolve/1.20.1: @@ -2671,7 +2671,7 @@ packages: /@types/sass/1.43.1: resolution: {integrity: sha512-BPdoIt1lfJ6B7rw35ncdwBZrAssjcwzI5LByIrYs+tpXlj/CAkuVdRsgZDdP4lq5EjyWzwxZCqAoFyHKFwp32g==} dependencies: - '@types/node': 16.11.27 + '@types/node': 17.0.25 dev: true /@types/semver/7.3.9: @@ -2689,13 +2689,13 @@ packages: /@types/stylus/0.48.37: resolution: {integrity: sha512-IkLnS/GzdDK3rgAmQwLr8LqPvUMa43SHlCnXqsfXNukwaIpiXBNgSHil3ro8aemhF4k4ZiMoa4URE7mwBHPJnQ==} dependencies: - '@types/node': 16.11.27 + '@types/node': 17.0.25 dev: true /@types/ws/8.5.3: resolution: {integrity: sha512-6YOoWjruKj1uLf3INHH7D3qTXwFfEsg1kf3c0uDdSBJwfa/llkwIjrAGV7j7mVgGNbzTQ3HiHKKDXl6bJPD97w==} dependencies: - '@types/node': 16.11.27 + '@types/node': 17.0.25 dev: true /@types/yargs-parser/20.2.1: @@ -2712,7 +2712,7 @@ packages: resolution: {integrity: sha512-8uALY5LTvSuHgloDVUvWP3pIauILm+8/0pDMokuDYIoNsOkSwd5AiHBTSEJjKTDcZr5z8UpgOWZkxBF4iJftoA==} requiresBuild: true dependencies: - '@types/node': 16.11.27 + '@types/node': 17.0.25 dev: true optional: true @@ -6009,7 +6009,7 @@ packages: '@jest/environment': 27.5.1 '@jest/test-result': 27.5.1 '@jest/types': 27.5.1 - '@types/node': 16.11.27 + '@types/node': 17.0.25 chalk: 4.1.2 co: 4.6.0 dedent: 0.7.0 @@ -6092,7 +6092,7 @@ packages: pretty-format: 27.5.1 slash: 3.0.0 strip-json-comments: 3.1.1 - ts-node: 10.4.0_8726306ae516cefbf62490d54d06d905 + ts-node: 10.4.0_233d9fcfccc8abc8f146a08357d842da transitivePeerDependencies: - bufferutil - canvas @@ -6135,7 +6135,7 @@ packages: '@jest/environment': 27.5.1 '@jest/fake-timers': 27.5.1 '@jest/types': 27.5.1 - '@types/node': 16.11.27 + '@types/node': 17.0.25 jest-mock: 27.5.1 jest-util: 27.5.1 jsdom: 16.7.0 @@ -6153,7 +6153,7 @@ packages: '@jest/environment': 27.5.1 '@jest/fake-timers': 27.5.1 '@jest/types': 27.5.1 - '@types/node': 16.11.27 + '@types/node': 17.0.25 jest-mock: 27.5.1 jest-util: 27.5.1 dev: true @@ -6169,7 +6169,7 @@ packages: dependencies: '@jest/types': 27.5.1 '@types/graceful-fs': 4.1.5 - '@types/node': 16.11.27 + '@types/node': 17.0.25 anymatch: 3.1.2 fb-watchman: 2.0.1 graceful-fs: 4.2.9 @@ -6191,7 +6191,7 @@ packages: '@jest/source-map': 27.5.1 '@jest/test-result': 27.5.1 '@jest/types': 27.5.1 - '@types/node': 16.11.27 + '@types/node': 17.0.25 chalk: 4.1.2 co: 4.6.0 expect: 27.5.1 @@ -6246,7 +6246,7 @@ packages: engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0} dependencies: '@jest/types': 27.5.1 - '@types/node': 16.11.27 + '@types/node': 17.0.25 dev: true /jest-pnp-resolver/1.2.2_jest-resolve@27.5.1: @@ -6302,7 +6302,7 @@ packages: '@jest/test-result': 27.5.1 '@jest/transform': 27.5.1 '@jest/types': 27.5.1 - '@types/node': 16.11.27 + '@types/node': 17.0.25 chalk: 4.1.2 emittery: 0.8.1 graceful-fs: 4.2.9 @@ -6359,7 +6359,7 @@ packages: resolution: {integrity: sha512-jZCyo6iIxO1aqUxpuBlwTDMkzOAJS4a3eYz3YzgxxVQFwLeSA7Jfq5cbqCY+JLvTDrWirgusI/0KwxKMgrdf7w==} engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0} dependencies: - '@types/node': 16.11.27 + '@types/node': 17.0.25 graceful-fs: 4.2.9 dev: true @@ -6398,7 +6398,7 @@ packages: engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0} dependencies: '@jest/types': 27.5.1 - '@types/node': 16.11.27 + '@types/node': 17.0.25 chalk: 4.1.2 ci-info: 3.3.0 graceful-fs: 4.2.9 @@ -6423,7 +6423,7 @@ packages: dependencies: '@jest/test-result': 27.5.1 '@jest/types': 27.5.1 - '@types/node': 16.11.27 + '@types/node': 17.0.25 ansi-escapes: 4.3.2 chalk: 4.1.2 jest-util: 27.5.1 @@ -6434,7 +6434,7 @@ packages: resolution: {integrity: sha512-7vuh85V5cdDofPyxn58nrPjBktZo0u9x1g8WtjQol+jZDaE+fhN+cIvTj11GndBnMnyfrUOG1sZQxCdjKh+DKg==} engines: {node: '>= 10.13.0'} dependencies: - '@types/node': 16.11.27 + '@types/node': 17.0.25 merge-stream: 2.0.0 supports-color: 8.1.1 dev: true @@ -7652,7 +7652,7 @@ packages: dependencies: import-cwd: 3.0.0 lilconfig: 2.0.4 - ts-node: 10.4.0_8726306ae516cefbf62490d54d06d905 + ts-node: 10.4.0_233d9fcfccc8abc8f146a08357d842da yaml: 1.10.2 dev: false @@ -7668,7 +7668,7 @@ packages: dependencies: lilconfig: 2.0.4 postcss: 8.4.12 - ts-node: 10.4.0_8726306ae516cefbf62490d54d06d905 + ts-node: 10.4.0_233d9fcfccc8abc8f146a08357d842da yaml: 1.10.2 dev: false @@ -7686,7 +7686,7 @@ packages: dependencies: lilconfig: 2.0.5 postcss: 8.4.12 - ts-node: 10.4.0_8726306ae516cefbf62490d54d06d905 + ts-node: 10.4.0_233d9fcfccc8abc8f146a08357d842da yaml: 1.10.2 dev: true @@ -9251,7 +9251,7 @@ packages: yargs-parser: 20.2.9 dev: true - /ts-node/10.4.0_8726306ae516cefbf62490d54d06d905: + /ts-node/10.4.0_233d9fcfccc8abc8f146a08357d842da: resolution: {integrity: sha512-g0FlPvvCXSIO1JDF6S232P5jPYqBkRL9qly81ZgAOSU7rwI0stphCgd2kLiCrU9DjQCrJMWEqcNSjQL02s6d8A==} hasBin: true peerDependencies: @@ -9270,7 +9270,7 @@ packages: '@tsconfig/node12': 1.0.9 '@tsconfig/node14': 1.0.1 '@tsconfig/node16': 1.0.2 - '@types/node': 16.11.27 + '@types/node': 17.0.25 acorn: 8.7.0 acorn-walk: 8.2.0 arg: 4.1.3 From ecc78bca4a15a25764375b2a7166cf06401e9ffd Mon Sep 17 00:00:00 2001 From: yoho <907415276@qq.com> Date: Sun, 24 Apr 2022 16:35:04 +0800 Subject: [PATCH 077/175] fix: clean string regexp (#7871) --- packages/vite/src/node/__tests__/cleanString.spec.ts | 11 +++++++++++ packages/vite/src/node/cleanString.ts | 5 +++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/vite/src/node/__tests__/cleanString.spec.ts b/packages/vite/src/node/__tests__/cleanString.spec.ts index b77f4c0fb5fbad..f307c4816b7cd3 100644 --- a/packages/vite/src/node/__tests__/cleanString.spec.ts +++ b/packages/vite/src/node/__tests__/cleanString.spec.ts @@ -1,3 +1,4 @@ +import { assetAttrsConfig } from './../plugins/html' import { emptyString } from '../../node/cleanString' test('comments', () => { @@ -51,6 +52,16 @@ test('escape character', () => { expect(clean).not.toMatch('1') }) +test('regexp affect', () => { + const clean = emptyString(` + /'/ + '1' + /"/ + "1" + `) + expect(clean).not.toMatch('1') +}) + test('strings comment nested', () => { expect( emptyString(` diff --git a/packages/vite/src/node/cleanString.ts b/packages/vite/src/node/cleanString.ts index 2b7cba41aef66b..3d623dce79c0d3 100644 --- a/packages/vite/src/node/cleanString.ts +++ b/packages/vite/src/node/cleanString.ts @@ -2,8 +2,9 @@ import type { RollupError } from 'rollup' // bank on the non-overlapping nature of regex matches and combine all filters into one giant regex // /`([^`\$\{\}]|\$\{(`|\g<1>)*\})*`/g can match nested string template // but js not support match expression(\g<0>). so clean string template(`...`) in other ways. -const cleanerRE = - /"([^"]|(?<=\\)")*"|'([^']|(?<=\\)')*'|\/\*(.|[\r\n])*?\*\/|\/\/.*/g +const stringsRE = /"([^"\r\n]|(?<=\\)")*"|'([^'\r\n]|(?<=\\)')*'/.source +const commentsRE = /\/\*(.|[\r\n])*?\*\/|\/\/.*/.source +const cleanerRE = new RegExp(`${stringsRE}|${commentsRE}`, 'g') const blankReplacer = (s: string) => ' '.repeat(s.length) const stringBlankReplacer = (s: string) => From 1f7855c1f691b588854d295d3dbffff759826c51 Mon Sep 17 00:00:00 2001 From: Rom Date: Mon, 25 Apr 2022 11:55:13 +0200 Subject: [PATCH 078/175] fix: HMR propagation of HTML changes (fix #7870) (#7895) --- packages/playground/hmr/__tests__/hmr.spec.ts | 18 +++++++++++++++--- .../hmr/{dynamic-import => counter}/dep.ts | 0 .../hmr/{dynamic-import => counter}/index.html | 0 .../hmr/{dynamic-import => counter}/index.ts | 0 packages/vite/src/node/server/moduleGraph.ts | 7 +++++++ 5 files changed, 22 insertions(+), 3 deletions(-) rename packages/playground/hmr/{dynamic-import => counter}/dep.ts (100%) rename packages/playground/hmr/{dynamic-import => counter}/index.html (100%) rename packages/playground/hmr/{dynamic-import => counter}/index.ts (100%) diff --git a/packages/playground/hmr/__tests__/hmr.spec.ts b/packages/playground/hmr/__tests__/hmr.spec.ts index 7325c9fe47943a..40b2bdf31b7956 100644 --- a/packages/playground/hmr/__tests__/hmr.spec.ts +++ b/packages/playground/hmr/__tests__/hmr.spec.ts @@ -162,7 +162,7 @@ if (!isBuild) { }) test('not loaded dynamic import', async () => { - await page.goto(viteTestUrl + '/dynamic-import/index.html') + await page.goto(viteTestUrl + '/counter/index.html') let btn = await page.$('button') expect(await btn.textContent()).toBe('Counter 0') @@ -170,7 +170,7 @@ if (!isBuild) { expect(await btn.textContent()).toBe('Counter 1') // Modifying `index.ts` triggers a page reload, as expected - editFile('dynamic-import/index.ts', (code) => code) + editFile('counter/index.ts', (code) => code) await page.waitForNavigation() btn = await page.$('button') expect(await btn.textContent()).toBe('Counter 0') @@ -184,7 +184,7 @@ if (!isBuild) { // (Note that, a dynamic import that is never loaded and that does not // define `accept.module.hot.accept` may wrongfully trigger a full page // reload, see discussion at #7561.) - editFile('dynamic-import/dep.ts', (code) => code) + editFile('counter/dep.ts', (code) => code) try { await page.waitForNavigation({ timeout: 1000 }) } catch (err) { @@ -194,4 +194,16 @@ if (!isBuild) { btn = await page.$('button') expect(await btn.textContent()).toBe('Counter 1') }) + + test('HTML', async () => { + await page.goto(viteTestUrl + '/counter/index.html') + let btn = await page.$('button') + expect(await btn.textContent()).toBe('Counter 0') + editFile('counter/index.html', (code) => + code.replace('Counter', 'Compteur') + ) + await page.waitForNavigation() + btn = await page.$('button') + expect(await btn.textContent()).toBe('Compteur 0') + }) } diff --git a/packages/playground/hmr/dynamic-import/dep.ts b/packages/playground/hmr/counter/dep.ts similarity index 100% rename from packages/playground/hmr/dynamic-import/dep.ts rename to packages/playground/hmr/counter/dep.ts diff --git a/packages/playground/hmr/dynamic-import/index.html b/packages/playground/hmr/counter/index.html similarity index 100% rename from packages/playground/hmr/dynamic-import/index.html rename to packages/playground/hmr/counter/index.html diff --git a/packages/playground/hmr/dynamic-import/index.ts b/packages/playground/hmr/counter/index.ts similarity index 100% rename from packages/playground/hmr/dynamic-import/index.ts rename to packages/playground/hmr/counter/index.ts diff --git a/packages/vite/src/node/server/moduleGraph.ts b/packages/vite/src/node/server/moduleGraph.ts index e470fafb05d8fd..a6c5bfa0ab121f 100644 --- a/packages/vite/src/node/server/moduleGraph.ts +++ b/packages/vite/src/node/server/moduleGraph.ts @@ -2,6 +2,7 @@ import { extname } from 'path' import type { ModuleInfo, PartialResolvedId } from 'rollup' import { parse as parseUrl } from 'url' import { isDirectCSSRequest } from '../plugins/css' +import { isHTMLRequest } from '../plugins/html' import { cleanUrl, normalizePath, @@ -37,6 +38,12 @@ export class ModuleNode { constructor(url: string) { this.url = url this.type = isDirectCSSRequest(url) ? 'css' : 'js' + // #7870 + // The `isSelfAccepting` value is set by importAnalysis, but HTML + // assets don't go through importAnalysis. + if (isHTMLRequest(url)) { + this.isSelfAccepting = false + } } } From 54728e388dca032903569e6de6dbaa2e6f886279 Mon Sep 17 00:00:00 2001 From: jsyanyang <94437201+jsyanyang@users.noreply.github.com> Date: Mon, 25 Apr 2022 18:43:17 +0800 Subject: [PATCH 079/175] fix: spelling mistakes (#7883) --- packages/vite/src/node/server/ws.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/vite/src/node/server/ws.ts b/packages/vite/src/node/server/ws.ts index 6d4e66ec1a22ae..17187ca6e282ac 100644 --- a/packages/vite/src/node/server/ws.ts +++ b/packages/vite/src/node/server/ws.ts @@ -149,7 +149,7 @@ export function createWebSocketServer( if (!parsed || parsed.type !== 'custom' || !parsed.event) return const listeners = customListeners.get(parsed.event) if (!listeners?.size) return - const client = getSocketClent(socket) + const client = getSocketClient(socket) listeners.forEach((listener) => listener(parsed.data, client)) }) socket.send(JSON.stringify({ type: 'connected' })) @@ -170,7 +170,7 @@ export function createWebSocketServer( // Provide a wrapper to the ws client so we can send messages in JSON format // To be consistent with server.ws.send - function getSocketClent(socket: WebSocketRaw) { + function getSocketClient(socket: WebSocketRaw) { if (!clientsMap.has(socket)) { clientsMap.set(socket, { send: (...args) => { @@ -217,7 +217,7 @@ export function createWebSocketServer( }) as WebSocketServer['off'], get clients() { - return new Set(Array.from(wss.clients).map(getSocketClent)) + return new Set(Array.from(wss.clients).map(getSocketClient)) }, send(...args: any[]) { From 0d2089c6876bcc04a46c3f7947ce4effc91dd9fd Mon Sep 17 00:00:00 2001 From: Rom Date: Mon, 25 Apr 2022 12:47:18 +0200 Subject: [PATCH 080/175] fix: set `isSelfAccepting` to `false` for any asset not processed by importAnalysis (#7898) --- packages/vite/src/node/plugins/importAnalysis.ts | 5 +++-- packages/vite/src/node/server/moduleGraph.ts | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/vite/src/node/plugins/importAnalysis.ts b/packages/vite/src/node/plugins/importAnalysis.ts index 31e9cd76faa8a0..d8bf59225fd49a 100644 --- a/packages/vite/src/node/plugins/importAnalysis.ts +++ b/packages/vite/src/node/plugins/importAnalysis.ts @@ -59,7 +59,8 @@ const debug = createDebugger('vite:import-analysis') const clientDir = normalizePath(CLIENT_DIR) const skipRE = /\.(map|json)$/ -const canSkip = (id: string) => skipRE.test(id) || isDirectCSSRequest(id) +export const canSkipImportAnalysis = (id: string) => + skipRE.test(id) || isDirectCSSRequest(id) const optimizedDepChunkRE = /\/chunk-[A-Z0-9]{8}\.js/ const optimizedDepDynamicRE = /-[A-Z0-9]{8}\.js/ @@ -131,7 +132,7 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin { const ssr = options?.ssr === true const prettyImporter = prettifyUrl(importer, root) - if (canSkip(importer)) { + if (canSkipImportAnalysis(importer)) { isDebug && debug(colors.dim(`[skipped] ${prettyImporter}`)) return null } diff --git a/packages/vite/src/node/server/moduleGraph.ts b/packages/vite/src/node/server/moduleGraph.ts index a6c5bfa0ab121f..9c9f0d84bb738f 100644 --- a/packages/vite/src/node/server/moduleGraph.ts +++ b/packages/vite/src/node/server/moduleGraph.ts @@ -11,6 +11,7 @@ import { } from '../utils' import { FS_PREFIX } from '../constants' import type { TransformResult } from './transformRequest' +import { canSkipImportAnalysis } from '../plugins/importAnalysis' export class ModuleNode { /** @@ -39,9 +40,9 @@ export class ModuleNode { this.url = url this.type = isDirectCSSRequest(url) ? 'css' : 'js' // #7870 - // The `isSelfAccepting` value is set by importAnalysis, but HTML + // The `isSelfAccepting` value is set by importAnalysis, but some // assets don't go through importAnalysis. - if (isHTMLRequest(url)) { + if (isHTMLRequest(url) || canSkipImportAnalysis(url)) { this.isSelfAccepting = false } } From e474381646b1b7c8802787ae3838241a890230a5 Mon Sep 17 00:00:00 2001 From: Rongjian Zhang Date: Tue, 26 Apr 2022 02:54:18 +0800 Subject: [PATCH 081/175] fix: preview jsdoc params (#7903) --- packages/vite/src/node/preview.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/vite/src/node/preview.ts b/packages/vite/src/node/preview.ts index c00f62a9cb8f0c..c1670c5d7efa72 100644 --- a/packages/vite/src/node/preview.ts +++ b/packages/vite/src/node/preview.ts @@ -55,8 +55,6 @@ export interface PreviewServer { /** * Starts the Vite server in preview mode, to simulate a production deployment - * @param config - the resolved Vite config - * @param serverOptions - what host and port to use * @experimental */ export async function preview( From 3edd1af56e980aef56641a5a51cf2932bb580d41 Mon Sep 17 00:00:00 2001 From: Johannes Date: Tue, 26 Apr 2022 06:23:34 +0100 Subject: [PATCH 082/175] docs: update link to postcss-nesting repo (#7885) --- docs/guide/features.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guide/features.md b/docs/guide/features.md index 06d282ae94ecd7..1a8c03bbd0be22 100644 --- a/docs/guide/features.md +++ b/docs/guide/features.md @@ -187,7 +187,7 @@ document.getElementById('foo').className = applyColor ### CSS Pre-processors -Because Vite targets modern browsers only, it is recommended to use native CSS variables with PostCSS plugins that implement CSSWG drafts (e.g. [postcss-nesting](https://github.com/jonathantneal/postcss-nesting)) and author plain, future-standards-compliant CSS. +Because Vite targets modern browsers only, it is recommended to use native CSS variables with PostCSS plugins that implement CSSWG drafts (e.g. [postcss-nesting](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-nesting)) and author plain, future-standards-compliant CSS. That said, Vite does provide built-in support for `.scss`, `.sass`, `.less`, `.styl` and `.stylus` files. There is no need to install Vite-specific plugins for them, but the corresponding pre-processor itself must be installed: From ef903d607c73f0ad003afa7f02613663d9ca7561 Mon Sep 17 00:00:00 2001 From: patak-dev Date: Tue, 26 Apr 2022 17:30:00 +0200 Subject: [PATCH 083/175] release: v2.9.6 --- packages/vite/CHANGELOG.md | 25 +++++++++++++++++++++++++ packages/vite/package.json | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/packages/vite/CHANGELOG.md b/packages/vite/CHANGELOG.md index 084a6363109266..c2dc1488d84b21 100644 --- a/packages/vite/CHANGELOG.md +++ b/packages/vite/CHANGELOG.md @@ -1,3 +1,28 @@ +## 2.9.6 (2022-04-26) + +* fix: `apply` condition skipped for nested plugins (#7741) ([1f2ca53](https://github.com/vitejs/vite/commit/1f2ca53)), closes [#7741](https://github.com/vitejs/vite/issues/7741) +* fix: clean string regexp (#7871) ([ecc78bc](https://github.com/vitejs/vite/commit/ecc78bc)), closes [#7871](https://github.com/vitejs/vite/issues/7871) +* fix: escape character in string regexp match (#7834) ([1d468c8](https://github.com/vitejs/vite/commit/1d468c8)), closes [#7834](https://github.com/vitejs/vite/issues/7834) +* fix: HMR propagation of HTML changes (fix #7870) (#7895) ([1f7855c](https://github.com/vitejs/vite/commit/1f7855c)), closes [#7870](https://github.com/vitejs/vite/issues/7870) [#7895](https://github.com/vitejs/vite/issues/7895) +* fix: modulepreload polyfill only during build (fix #4786) (#7816) ([709776f](https://github.com/vitejs/vite/commit/709776f)), closes [#4786](https://github.com/vitejs/vite/issues/4786) [#7816](https://github.com/vitejs/vite/issues/7816) +* fix: new SharedWorker syntax (#7800) ([474d5c2](https://github.com/vitejs/vite/commit/474d5c2)), closes [#7800](https://github.com/vitejs/vite/issues/7800) +* fix: node v18 support (#7812) ([fc89057](https://github.com/vitejs/vite/commit/fc89057)), closes [#7812](https://github.com/vitejs/vite/issues/7812) +* fix: preview jsdoc params (#7903) ([e474381](https://github.com/vitejs/vite/commit/e474381)), closes [#7903](https://github.com/vitejs/vite/issues/7903) +* fix: replace import.meta.url correctly (#7792) ([12d1194](https://github.com/vitejs/vite/commit/12d1194)), closes [#7792](https://github.com/vitejs/vite/issues/7792) +* fix: set `isSelfAccepting` to `false` for any asset not processed by importAnalysis (#7898) ([0d2089c](https://github.com/vitejs/vite/commit/0d2089c)), closes [#7898](https://github.com/vitejs/vite/issues/7898) +* fix: spelling mistakes (#7883) ([54728e3](https://github.com/vitejs/vite/commit/54728e3)), closes [#7883](https://github.com/vitejs/vite/issues/7883) +* fix: ssr.noExternal with boolean values (#7813) ([0b2d307](https://github.com/vitejs/vite/commit/0b2d307)), closes [#7813](https://github.com/vitejs/vite/issues/7813) +* fix: style use string instead of js import (#7786) ([ba43c29](https://github.com/vitejs/vite/commit/ba43c29)), closes [#7786](https://github.com/vitejs/vite/issues/7786) +* fix: update sourcemap in importAnalysisBuild (#7825) ([d7540c8](https://github.com/vitejs/vite/commit/d7540c8)), closes [#7825](https://github.com/vitejs/vite/issues/7825) +* fix(ssr): rewrite dynamic class method name (fix #7751) (#7757) ([b89974a](https://github.com/vitejs/vite/commit/b89974a)), closes [#7751](https://github.com/vitejs/vite/issues/7751) [#7757](https://github.com/vitejs/vite/issues/7757) +* chore: code structure (#7790) ([5f7fe00](https://github.com/vitejs/vite/commit/5f7fe00)), closes [#7790](https://github.com/vitejs/vite/issues/7790) +* chore: fix worker sourcemap output style (#7805) ([17f3be7](https://github.com/vitejs/vite/commit/17f3be7)), closes [#7805](https://github.com/vitejs/vite/issues/7805) +* chore(deps): update all non-major dependencies (#7780) ([eba9d05](https://github.com/vitejs/vite/commit/eba9d05)), closes [#7780](https://github.com/vitejs/vite/issues/7780) +* chore(deps): update all non-major dependencies (#7847) ([e29d1d9](https://github.com/vitejs/vite/commit/e29d1d9)), closes [#7847](https://github.com/vitejs/vite/issues/7847) +* feat: enable optimizeDeps.esbuildOptions.loader (#6840) ([af8ca60](https://github.com/vitejs/vite/commit/af8ca60)), closes [#6840](https://github.com/vitejs/vite/issues/6840) + + + ## 2.9.5 (2022-04-14) * fix: revert #7582, fix #7721 and #7736 (#7737) ([fa86d69](https://github.com/vitejs/vite/commit/fa86d69)), closes [#7721](https://github.com/vitejs/vite/issues/7721) [#7736](https://github.com/vitejs/vite/issues/7736) [#7737](https://github.com/vitejs/vite/issues/7737) diff --git a/packages/vite/package.json b/packages/vite/package.json index 2d65cc1c330cad..b2caecf4e228ca 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -1,6 +1,6 @@ { "name": "vite", - "version": "2.9.5", + "version": "2.9.6", "license": "MIT", "author": "Evan You", "description": "Native-ESM powered web dev build tool", From b092697fd1d91710f16ffe7dcca4001fb794dcec Mon Sep 17 00:00:00 2001 From: yoho <907415276@qq.com> Date: Wed, 27 Apr 2022 03:45:07 +0800 Subject: [PATCH 084/175] fix(worker): import.meta.* (#7706) --- .../worker/__tests__/es/es-worker.spec.ts | 27 +++++++++++++++-- .../worker/__tests__/iife/worker.spec.ts | 24 +++++++++++---- .../sourcemap-hidden-worker.spec.ts | 2 +- .../sourcemap-inline-worker.spec.ts | 2 +- .../sourcemap/sourcemap-worker.spec.ts | 2 +- .../worker/classic-shared-worker.js | 3 ++ packages/playground/worker/classic-worker.js | 3 ++ .../emit-chunk-dynamic-import-worker.js | 5 +++- .../worker/emit-chunk-nested-worker.js | 3 ++ .../worker/emit-chunk-sub-worker.js | 3 ++ .../worker/importMetaGlob.worker.js | 8 +++++ .../worker/importMetaGlobEager.worker.js | 8 +++++ packages/playground/worker/index.html | 29 ++++++++++++++++++- .../playground/worker/module-and-worker.js | 5 +++- .../worker/modules/{module.js => module0.js} | 0 packages/playground/worker/modules/module2.js | 2 +- packages/playground/worker/modules/module3.js | 2 +- .../playground/worker/my-shared-worker.ts | 3 ++ packages/playground/worker/my-worker.ts | 3 ++ .../worker/possible-ts-output-worker.mjs | 3 ++ packages/playground/worker/sub-worker.js | 5 +++- .../playground/worker/url-shared-worker.js | 5 +++- packages/playground/worker/url-worker.js | 5 +++- .../playground/worker/worker-nested-worker.js | 22 ++++++++++++-- .../worker/worker/main-format-es.js | 9 ++++++ .../playground/worker/worker/main-module.js | 16 ++++++++++ .../src/node/plugins/importAnalysisBuild.ts | 19 ++++++++---- packages/vite/src/node/plugins/worker.ts | 29 ++++++++++++------- 28 files changed, 209 insertions(+), 38 deletions(-) create mode 100644 packages/playground/worker/importMetaGlob.worker.js create mode 100644 packages/playground/worker/importMetaGlobEager.worker.js rename packages/playground/worker/modules/{module.js => module0.js} (100%) diff --git a/packages/playground/worker/__tests__/es/es-worker.spec.ts b/packages/playground/worker/__tests__/es/es-worker.spec.ts index a815596721c268..27f81b010df74f 100644 --- a/packages/playground/worker/__tests__/es/es-worker.spec.ts +++ b/packages/playground/worker/__tests__/es/es-worker.spec.ts @@ -51,8 +51,12 @@ test.concurrent.each([[true], [false]])('shared worker', async (doTick) => { await waitSharedWorkerTick(page) }) -test('worker emitted', async () => { - await untilUpdated(() => page.textContent('.nested-worker'), 'pong') +test('worker emitted and import.meta.url in nested worker (serve)', async () => { + expect(await page.textContent('.nested-worker')).toMatch('/worker-nested') + expect(await page.textContent('.nested-worker-module')).toMatch('/sub-worker') + expect(await page.textContent('.nested-worker-constructor')).toMatch( + '"type":"constructor"' + ) }) if (isBuild) { @@ -60,7 +64,7 @@ if (isBuild) { // assert correct files test('inlined code generation', async () => { const files = fs.readdirSync(assetsDir) - expect(files.length).toBe(21) + expect(files.length).toBe(26) const index = files.find((f) => f.includes('main-module')) const content = fs.readFileSync(path.resolve(assetsDir, index), 'utf-8') const worker = files.find((f) => f.includes('my-worker')) @@ -79,6 +83,15 @@ if (isBuild) { expect(content).toMatch(`(window.URL||window.webkitURL).createObjectURL`) expect(content).toMatch(`window.Blob`) }) + + test('worker emitted and import.meta.url in nested worker (build)', async () => { + expect(await page.textContent('.nested-worker-module')).toMatch( + '"type":"module"' + ) + expect(await page.textContent('.nested-worker-constructor')).toMatch( + '"type":"constructor"' + ) + }) } test('module worker', async () => { @@ -100,3 +113,11 @@ test('emit chunk', async () => { '"A string/es/"' ) }) + +test('import.meta.glob in worker', async () => { + expect(await page.textContent('.importMetaGlob-worker')).toMatch('["') +}) + +test('import.meta.globEager in worker', async () => { + expect(await page.textContent('.importMetaGlobEager-worker')).toMatch('["') +}) diff --git a/packages/playground/worker/__tests__/iife/worker.spec.ts b/packages/playground/worker/__tests__/iife/worker.spec.ts index 9be78d57edd702..16750a893cb073 100644 --- a/packages/playground/worker/__tests__/iife/worker.spec.ts +++ b/packages/playground/worker/__tests__/iife/worker.spec.ts @@ -51,10 +51,11 @@ test.concurrent.each([[true], [false]])('shared worker', async (doTick) => { await waitSharedWorkerTick(page) }) -test('worker emitted and import.meta.url in nested worker', async () => { - await untilUpdated( - () => page.textContent('.nested-worker'), - 'pong http://localhost:3000/iife/sub-worker.js?worker_file' +test('worker emitted and import.meta.url in nested worker (serve)', async () => { + expect(await page.textContent('.nested-worker')).toMatch('/worker-nested') + expect(await page.textContent('.nested-worker-module')).toMatch('/sub-worker') + expect(await page.textContent('.nested-worker-constructor')).toMatch( + '"type":"constructor"' ) }) @@ -63,7 +64,7 @@ if (isBuild) { // assert correct files test('inlined code generation', async () => { const files = fs.readdirSync(assetsDir) - expect(files.length).toBe(12) + expect(files.length).toBe(13) const index = files.find((f) => f.includes('main-module')) const content = fs.readFileSync(path.resolve(assetsDir, index), 'utf-8') const worker = files.find((f) => f.includes('my-worker')) @@ -82,6 +83,15 @@ if (isBuild) { expect(content).toMatch(`(window.URL||window.webkitURL).createObjectURL`) expect(content).toMatch(`window.Blob`) }) + + test('worker emitted and import.meta.url in nested worker (build)', async () => { + expect(await page.textContent('.nested-worker-module')).toMatch( + '"type":"module"' + ) + expect(await page.textContent('.nested-worker-constructor')).toMatch( + '"type":"constructor"' + ) + }) } test('module worker', async () => { @@ -94,3 +104,7 @@ test('classic worker', async () => { expect(await page.textContent('.classic-worker')).toMatch('A classic') expect(await page.textContent('.classic-shared-worker')).toMatch('A classic') }) + +test('import.meta.globEager in worker', async () => { + expect(await page.textContent('.importMetaGlobEager-worker')).toMatch('["') +}) diff --git a/packages/playground/worker/__tests__/sourcemap-hidden/sourcemap-hidden-worker.spec.ts b/packages/playground/worker/__tests__/sourcemap-hidden/sourcemap-hidden-worker.spec.ts index 1797ac5269e411..e4cb3318ebd5f5 100644 --- a/packages/playground/worker/__tests__/sourcemap-hidden/sourcemap-hidden-worker.spec.ts +++ b/packages/playground/worker/__tests__/sourcemap-hidden/sourcemap-hidden-worker.spec.ts @@ -9,7 +9,7 @@ if (isBuild) { test('sourcemap generation for web workers', async () => { const files = fs.readdirSync(assetsDir) // should have 2 worker chunk - expect(files.length).toBe(24) + expect(files.length).toBe(26) const index = files.find((f) => f.includes('main-module')) const content = fs.readFileSync(path.resolve(assetsDir, index), 'utf-8') const indexSourcemap = getSourceMapUrl(content) diff --git a/packages/playground/worker/__tests__/sourcemap-inline/sourcemap-inline-worker.spec.ts b/packages/playground/worker/__tests__/sourcemap-inline/sourcemap-inline-worker.spec.ts index 89af0878213ab9..ceda7dae1fec7c 100644 --- a/packages/playground/worker/__tests__/sourcemap-inline/sourcemap-inline-worker.spec.ts +++ b/packages/playground/worker/__tests__/sourcemap-inline/sourcemap-inline-worker.spec.ts @@ -9,7 +9,7 @@ if (isBuild) { test('sourcemap generation for web workers', async () => { const files = fs.readdirSync(assetsDir) // should have 2 worker chunk - expect(files.length).toBe(12) + expect(files.length).toBe(13) const index = files.find((f) => f.includes('main-module')) const content = fs.readFileSync(path.resolve(assetsDir, index), 'utf-8') const indexSourcemap = getSourceMapUrl(content) diff --git a/packages/playground/worker/__tests__/sourcemap/sourcemap-worker.spec.ts b/packages/playground/worker/__tests__/sourcemap/sourcemap-worker.spec.ts index 24af73d5e3edfa..04cc079b4bc289 100644 --- a/packages/playground/worker/__tests__/sourcemap/sourcemap-worker.spec.ts +++ b/packages/playground/worker/__tests__/sourcemap/sourcemap-worker.spec.ts @@ -9,7 +9,7 @@ if (isBuild) { test('sourcemap generation for web workers', async () => { const files = fs.readdirSync(assetsDir) // should have 2 worker chunk - expect(files.length).toBe(24) + expect(files.length).toBe(26) const index = files.find((f) => f.includes('main-module')) const content = fs.readFileSync(path.resolve(assetsDir, index), 'utf-8') const indexSourcemap = getSourceMapUrl(content) diff --git a/packages/playground/worker/classic-shared-worker.js b/packages/playground/worker/classic-shared-worker.js index 8bd39e194f0618..e629208f05cf0a 100644 --- a/packages/playground/worker/classic-shared-worker.js +++ b/packages/playground/worker/classic-shared-worker.js @@ -4,3 +4,6 @@ self.onconnect = (event) => { const port = event.ports[0] port.postMessage(self.constant) } + +// for sourcemap +console.log('classic-shared-worker.js') diff --git a/packages/playground/worker/classic-worker.js b/packages/playground/worker/classic-worker.js index 0700428ee0c80b..238857acf00a58 100644 --- a/packages/playground/worker/classic-worker.js +++ b/packages/playground/worker/classic-worker.js @@ -3,3 +3,6 @@ importScripts(`/${self.location.pathname.split("/")[1]}/classic.js`) self.addEventListener('message', () => { self.postMessage(self.constant) }) + +// for sourcemap +console.log("classic-worker.js") diff --git a/packages/playground/worker/emit-chunk-dynamic-import-worker.js b/packages/playground/worker/emit-chunk-dynamic-import-worker.js index f96e0b15d26497..9c3ede1faa2ed9 100644 --- a/packages/playground/worker/emit-chunk-dynamic-import-worker.js +++ b/packages/playground/worker/emit-chunk-dynamic-import-worker.js @@ -1,3 +1,6 @@ -import('./modules/module').then((module) => { +import('./modules/module0').then((module) => { self.postMessage(module.default + import.meta.env.BASE_URL) }) + +// for sourcemap +console.log('emit-chunk-dynamic-import-worker.js') diff --git a/packages/playground/worker/emit-chunk-nested-worker.js b/packages/playground/worker/emit-chunk-nested-worker.js index 6cb72b9488cfaf..629322033f3d9b 100644 --- a/packages/playground/worker/emit-chunk-nested-worker.js +++ b/packages/playground/worker/emit-chunk-nested-worker.js @@ -26,3 +26,6 @@ import('./module-and-worker').then((res) => { data: res.module }) }) + +// for sourcemap +console.log('emit-chunk-nested-worker.js') diff --git a/packages/playground/worker/emit-chunk-sub-worker.js b/packages/playground/worker/emit-chunk-sub-worker.js index 5d20becc781dd7..60d302e20bbb8a 100644 --- a/packages/playground/worker/emit-chunk-sub-worker.js +++ b/packages/playground/worker/emit-chunk-sub-worker.js @@ -6,3 +6,6 @@ Promise.all([ const _data = { ...data[0], ...data[1], ...data[2] } self.postMessage(_data) }) + +// for sourcemap +console.log('emit-chunk-sub-worker.js') diff --git a/packages/playground/worker/importMetaGlob.worker.js b/packages/playground/worker/importMetaGlob.worker.js new file mode 100644 index 00000000000000..074a986c9bd808 --- /dev/null +++ b/packages/playground/worker/importMetaGlob.worker.js @@ -0,0 +1,8 @@ +const modules = import.meta.glob('./modules/*js') + +self.onmessage = function (e) { + self.postMessage(Object.keys(modules)) +} + +// for sourcemap +console.log('importMetaGlob.worker.js') diff --git a/packages/playground/worker/importMetaGlobEager.worker.js b/packages/playground/worker/importMetaGlobEager.worker.js new file mode 100644 index 00000000000000..7947f65ab8c7f9 --- /dev/null +++ b/packages/playground/worker/importMetaGlobEager.worker.js @@ -0,0 +1,8 @@ +const modules = import.meta.globEager('./modules/*js') + +self.onmessage = function (e) { + self.postMessage(Object.keys(modules)) +} + +// for sourcemap +console.log('importMetaGlobEager.worker.js') diff --git a/packages/playground/worker/index.html b/packages/playground/worker/index.html index 602aa3d06bfcac..b0c524305fc33e 100644 --- a/packages/playground/worker/index.html +++ b/packages/playground/worker/index.html @@ -40,11 +40,25 @@

format iife:

- import NestedWorker from './worker-nested-worker?worker' - nested worker + import NestedWorker from './worker-nested-worker?worker' - import.meta.url .nested-worker

+

+ import NestedWorker from './worker-nested-worker?worker' - nested module + worker + .nested-worker-module +

+ + +

+ import NestedWorker from './worker-nested-worker?worker' - nested worker + constructor + .nested-worker-constructor +

+ +

new Worker(new URL('./classic-worker.js', import.meta.url)) .classic-worker @@ -58,9 +72,22 @@

format iife:

+

+ use import.meta.globEager in iife worker + .importMetaGlobEager-worker +

+ +
+

+

+ use import.meta.glob in es worker + .importMetaGlob-worker +

+ +

worker emit chunk
module and worker:worker in worker file
diff --git a/packages/playground/worker/module-and-worker.js b/packages/playground/worker/module-and-worker.js index 659e556f08e4a6..036dcdf4edf11d 100644 --- a/packages/playground/worker/module-and-worker.js +++ b/packages/playground/worker/module-and-worker.js @@ -1,5 +1,8 @@ -import constant from './modules/module' +import constant from './modules/module0' self.postMessage(constant) export const module = 'module and worker' + +// for sourcemap +console.log('module-and-worker.js') diff --git a/packages/playground/worker/modules/module.js b/packages/playground/worker/modules/module0.js similarity index 100% rename from packages/playground/worker/modules/module.js rename to packages/playground/worker/modules/module0.js diff --git a/packages/playground/worker/modules/module2.js b/packages/playground/worker/modules/module2.js index 60447933b8b16e..70c0fc94586ffd 100644 --- a/packages/playground/worker/modules/module2.js +++ b/packages/playground/worker/modules/module2.js @@ -1,3 +1,3 @@ -export * from './module' +export * from './module0' export * from './module1' export const msg2 = 'module2' diff --git a/packages/playground/worker/modules/module3.js b/packages/playground/worker/modules/module3.js index 33355423bc030e..65f7e274da3242 100644 --- a/packages/playground/worker/modules/module3.js +++ b/packages/playground/worker/modules/module3.js @@ -1,2 +1,2 @@ -export * from './module' +export * from './module0' export const msg3 = 'module3' diff --git a/packages/playground/worker/my-shared-worker.ts b/packages/playground/worker/my-shared-worker.ts index cd5b24f265b955..caab5257394266 100644 --- a/packages/playground/worker/my-shared-worker.ts +++ b/packages/playground/worker/my-shared-worker.ts @@ -14,3 +14,6 @@ onconnect = (event) => { } } } + +// for sourcemap +console.log('my-shared-worker.js') diff --git a/packages/playground/worker/my-worker.ts b/packages/playground/worker/my-worker.ts index dd6061885128c7..553754f4901030 100644 --- a/packages/playground/worker/my-worker.ts +++ b/packages/playground/worker/my-worker.ts @@ -6,3 +6,6 @@ self.onmessage = (e) => { self.postMessage({ msg, mode, bundleWithPlugin }) } } + +// for sourcemap +console.log('my-worker.js') diff --git a/packages/playground/worker/possible-ts-output-worker.mjs b/packages/playground/worker/possible-ts-output-worker.mjs index 25f1a447617cd9..db76614bc78267 100644 --- a/packages/playground/worker/possible-ts-output-worker.mjs +++ b/packages/playground/worker/possible-ts-output-worker.mjs @@ -5,3 +5,6 @@ self.onmessage = (e) => { self.postMessage({ msg, mode }) } } + +// for sourcemap +console.log('possible-ts-output-worker.mjs') diff --git a/packages/playground/worker/sub-worker.js b/packages/playground/worker/sub-worker.js index eff49dfbb46ba6..37d5d4effabb27 100644 --- a/packages/playground/worker/sub-worker.js +++ b/packages/playground/worker/sub-worker.js @@ -1,5 +1,8 @@ self.onmessage = (event) => { if (event.data === 'ping') { - self.postMessage(`pong ${import.meta.url}`) + self.postMessage(`pong ${self.location.href}`) } } + +// for sourcemap +console.log('sub-worker.js') diff --git a/packages/playground/worker/url-shared-worker.js b/packages/playground/worker/url-shared-worker.js index 3535d5c277ec84..9ef32c58f6c64b 100644 --- a/packages/playground/worker/url-shared-worker.js +++ b/packages/playground/worker/url-shared-worker.js @@ -1,6 +1,9 @@ -import constant from './modules/module' +import constant from './modules/module0' self.onconnect = (event) => { const port = event.ports[0] port.postMessage(constant) } + +// for sourcemap +console.log('url-shared-worker.js') diff --git a/packages/playground/worker/url-worker.js b/packages/playground/worker/url-worker.js index c25cbefdff89ec..1ba50225ee339d 100644 --- a/packages/playground/worker/url-worker.js +++ b/packages/playground/worker/url-worker.js @@ -1 +1,4 @@ -self.postMessage('A string' + import.meta.env.BASE_URL + import.meta.url) +self.postMessage('A string' + import.meta.env.BASE_URL + self.location.url) + +// for sourcemap +console.log('url-worker.js') diff --git a/packages/playground/worker/worker-nested-worker.js b/packages/playground/worker/worker-nested-worker.js index 6d4d1e4969005f..e74d1db760409b 100644 --- a/packages/playground/worker/worker-nested-worker.js +++ b/packages/playground/worker/worker-nested-worker.js @@ -8,6 +8,24 @@ self.onmessage = (event) => { } } -subWorker.onmessage = (event) => { - self.postMessage(event.data) +self.postMessage(self.location.href) + +subWorker.onmessage = (ev) => { + self.postMessage({ + type: 'module', + data: ev.data + }) } + +const classicWorker = new Worker(new URL('./url-worker.js', import.meta.url), { + type: 'module' +}) +classicWorker.addEventListener('message', (ev) => { + self.postMessage({ + type: 'constructor', + data: ev.data + }) +}) + +// for sourcemap +console.log('worker-nested-worker.js') diff --git a/packages/playground/worker/worker/main-format-es.js b/packages/playground/worker/worker/main-format-es.js index 801c13469151a3..e418c82a136927 100644 --- a/packages/playground/worker/worker/main-format-es.js +++ b/packages/playground/worker/worker/main-format-es.js @@ -1,5 +1,6 @@ // run when format es import NestedWorker from '../emit-chunk-nested-worker?worker' +import ImportMetaGlobWorker from '../importMetaGlob.worker?worker' function text(el, text) { document.querySelector(el).textContent = text @@ -39,3 +40,11 @@ const moduleWorker = new Worker( moduleWorker.addEventListener('message', (ev) => { text('.module-and-worker-worker', JSON.stringify(ev.data)) }) + +const importMetaGlobWorker = new ImportMetaGlobWorker() + +importMetaGlobWorker.postMessage('1') + +importMetaGlobWorker.addEventListener('message', (e) => { + text('.importMetaGlob-worker', JSON.stringify(e.data)) +}) diff --git a/packages/playground/worker/worker/main-module.js b/packages/playground/worker/worker/main-module.js index 417cf1728c4b09..6284ca63686e99 100644 --- a/packages/playground/worker/worker/main-module.js +++ b/packages/playground/worker/worker/main-module.js @@ -3,6 +3,7 @@ import InlineWorker from '../my-worker?worker&inline' import mySharedWorker from '../my-shared-worker?sharedworker&name=shared' import TSOutputWorker from '../possible-ts-output-worker?worker' import NestedWorker from '../worker-nested-worker?worker' +import ImportMetaGlobEagerWorker from '../importMetaGlobEager.worker?worker' import { mode } from '../modules/workerImport' function text(el, text) { @@ -56,6 +57,13 @@ const nestedWorker = new NestedWorker() nestedWorker.addEventListener('message', (ev) => { if (typeof ev.data === 'string') { text('.nested-worker', JSON.stringify(ev.data)) + } else if (typeof ev.data === 'object') { + const data = ev.data + if (data.type === 'module') { + text('.nested-worker-module', JSON.stringify(ev.data)) + } else if (data.type === 'constructor') { + text('.nested-worker-constructor', JSON.stringify(ev.data)) + } } }) nestedWorker.postMessage('ping') @@ -83,3 +91,11 @@ w2.port.addEventListener('message', (ev) => { text('.shared-worker-import-meta-url', JSON.stringify(ev.data)) }) w2.port.start() + +const importMetaGlobEagerWorker = new ImportMetaGlobEagerWorker() + +importMetaGlobEagerWorker.postMessage('1') + +importMetaGlobEagerWorker.addEventListener('message', (e) => { + text('.importMetaGlobEager-worker', JSON.stringify(e.data)) +}) diff --git a/packages/vite/src/node/plugins/importAnalysisBuild.ts b/packages/vite/src/node/plugins/importAnalysisBuild.ts index 9f4c75025fff27..ff315d008f57a5 100644 --- a/packages/vite/src/node/plugins/importAnalysisBuild.ts +++ b/packages/vite/src/node/plugins/importAnalysisBuild.ts @@ -87,8 +87,8 @@ function preload(baseModule: () => Promise<{}>, deps?: string[]) { */ export function buildImportAnalysisPlugin(config: ResolvedConfig): Plugin { const ssr = !!config.build.ssr - const insertPreload = !(ssr || !!config.build.lib) const isWorker = config.isWorker + const insertPreload = !(ssr || !!config.build.lib || isWorker) const scriptRel = config.build.polyfillModulePreload ? `'modulepreload'` @@ -123,11 +123,6 @@ export function buildImportAnalysisPlugin(config: ResolvedConfig): Plugin { return } - if (isWorker) { - // preload method use `document` and can't run in the worker - return - } - await init let imports: readonly ImportSpecifier[] = [] @@ -159,6 +154,18 @@ export function buildImportAnalysisPlugin(config: ResolvedConfig): Plugin { source.slice(start, end) === 'import.meta' && source.slice(end, end + 5) === '.glob' ) { + // es worker allow globEager / glob + // iife worker just allow globEager + if ( + isWorker && + config.worker.format === 'iife' && + source.slice(end, end + 10) !== '.globEager' + ) { + this.error( + '`import.meta.glob` is not supported in workers with `iife` format, use `import.meta.globEager` instead.', + end + ) + } const { importsString, exp, endIndex, isEager } = await transformImportGlob( source, diff --git a/packages/vite/src/node/plugins/worker.ts b/packages/vite/src/node/plugins/worker.ts index 4113b7153f9b35..5826980f5b0f72 100644 --- a/packages/vite/src/node/plugins/worker.ts +++ b/packages/vite/src/node/plugins/worker.ts @@ -58,6 +58,14 @@ function emitWorkerAssets( ) } +function emitWorkerSourcemap( + ctx: Rollup.TransformPluginContext, + config: ResolvedConfig, + asset: EmittedFile +) { + return emitWorkerFile(ctx, config, asset, 'assets') +} + function emitWorkerChunks( ctx: Rollup.TransformPluginContext, config: ResolvedConfig, @@ -138,14 +146,11 @@ function emitSourcemapForWorkerEntry( const contentHash = getAssetHash(content) const fileName = `${basename}.${contentHash}.js.map` const filePath = path.posix.join(config.build.assetsDir, fileName) - if (!context.cache.has(contentHash)) { - context.cache.set(contentHash, true) - context.emitFile({ - fileName: filePath, - type: 'asset', - source: data - }) - } + emitWorkerSourcemap(context, config, { + fileName: filePath, + type: 'asset', + source: data + }) // Emit the comment that tells the JS debugger where it can find the // sourcemap file. @@ -154,7 +159,10 @@ function emitSourcemapForWorkerEntry( if (config.build.sourcemap === true) { // inline web workers need to use the full sourcemap path // non-inline web workers can use a relative path - const sourceMapUrl = query?.inline != null ? filePath : fileName + const sourceMapUrl = + query?.inline != null + ? path.posix.join(config.base, filePath) + : fileName code += `//# sourceMappingURL=${sourceMapUrl}` } } @@ -194,7 +202,6 @@ export async function workerFileToUrl( export function webWorkerPlugin(config: ResolvedConfig): Plugin { const isBuild = config.command === 'build' - const isWorker = config.isWorker return { name: 'vite:worker', @@ -279,7 +286,7 @@ export function webWorkerPlugin(config: ResolvedConfig): Plugin { }, renderChunk(code) { - if (isWorker && code.includes('import.meta.url')) { + if (config.isWorker && code.includes('import.meta.url')) { return code.replace('import.meta.url', 'self.location.href') } } From 5c1ee5abf987e25bd39d5af8013ed907a33d4d14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Wed, 27 Apr 2022 17:23:48 +0900 Subject: [PATCH 085/175] docs: `server.origin` config trailing slash (fix #6622) (#7865) --- docs/config/index.md | 2 +- packages/vite/src/node/config.ts | 2 +- packages/vite/src/node/server/index.ts | 18 +++++++++++++++++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/docs/config/index.md b/docs/config/index.md index bab7df7a144987..aaa5dcd47ad361 100644 --- a/docs/config/index.md +++ b/docs/config/index.md @@ -706,7 +706,7 @@ Defines the origin of the generated asset URLs during development. ```js export default defineConfig({ server: { - origin: 'http://127.0.0.1:8080/' + origin: 'http://127.0.0.1:8080' } }) ``` diff --git a/packages/vite/src/node/config.ts b/packages/vite/src/node/config.ts index d242ac632c220e..27a107f3e2098c 100644 --- a/packages/vite/src/node/config.ts +++ b/packages/vite/src/node/config.ts @@ -461,7 +461,7 @@ export async function resolveConfig( ) : '' - const server = resolveServerOptions(resolvedRoot, config.server) + const server = resolveServerOptions(resolvedRoot, config.server, logger) const optimizeDeps = config.optimizeDeps || {} diff --git a/packages/vite/src/node/server/index.ts b/packages/vite/src/node/server/index.ts index 99aefea6de292a..29f57adeb5c752 100644 --- a/packages/vite/src/node/server/index.ts +++ b/packages/vite/src/node/server/index.ts @@ -56,6 +56,7 @@ import type { OptimizedDeps } from '../optimizer' import { resolveHostname } from '../utils' import { searchForWorkspaceRoot } from './searchRoot' import { CLIENT_DIR } from '../constants' +import type { Logger } from '../logger' import { printCommonServerUrls } from '../logger' import { performance } from 'perf_hooks' import { invalidatePackageData } from '../packages' @@ -92,6 +93,8 @@ export interface ServerOptions extends CommonServerOptions { fs?: FileSystemServeOptions /** * Origin for the generated asset URLs. + * + * @example `http://127.0.0.1:8080` */ origin?: string /** @@ -701,7 +704,8 @@ function resolvedAllowDir(root: string, dir: string): string { export function resolveServerOptions( root: string, - raw?: ServerOptions + raw: ServerOptions | undefined, + logger: Logger ): ResolvedServerOptions { const server: ResolvedServerOptions = { preTransformRequests: true, @@ -727,6 +731,18 @@ export function resolveServerOptions( allow: allowDirs, deny } + + if (server.origin?.endsWith('/')) { + server.origin = server.origin.slice(0, -1) + logger.warn( + colors.yellow( + `${colors.bold('(!)')} server.origin should not end with "/". Using "${ + server.origin + }" instead.` + ) + ) + } + return server } From e48827f58bac0af2a564cacd8213195a9015f8a3 Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Wed, 27 Apr 2022 20:16:58 +0800 Subject: [PATCH 086/175] fix(css): clean comments before hoist at rules (#7924) --- .../src/node/__tests__/plugins/css.spec.ts | 48 ++++++++++++++++++- packages/vite/src/node/cleanString.ts | 14 ++++-- packages/vite/src/node/plugins/css.ts | 37 +++++++------- 3 files changed, 78 insertions(+), 21 deletions(-) diff --git a/packages/vite/src/node/__tests__/plugins/css.spec.ts b/packages/vite/src/node/__tests__/plugins/css.spec.ts index 078cec2e0f3d77..e0d1f04a6510b2 100644 --- a/packages/vite/src/node/__tests__/plugins/css.spec.ts +++ b/packages/vite/src/node/__tests__/plugins/css.spec.ts @@ -155,10 +155,54 @@ describe('hoist @ rules', () => { }) test('hoist @import and @charset', async () => { - const css = `.foo{color:red;}@import "bla";@charset "utf-8";.bar{color:grren;}@import "baz";` + const css = `.foo{color:red;}@import "bla";@charset "utf-8";.bar{color:green;}@import "baz";` const result = await hoistAtRules(css) expect(result).toBe( - `@charset "utf-8";@import "bla";@import "baz";.foo{color:red;}.bar{color:grren;}` + `@charset "utf-8";@import "bla";@import "baz";.foo{color:red;}.bar{color:green;}` + ) + }) + + test('dont hoist @import in comments', async () => { + const css = `.foo{color:red;}/* @import "bla"; */@import "bar";` + const result = await hoistAtRules(css) + expect(result).toBe(`@import "bar";.foo{color:red;}/* @import "bla"; */`) + }) + + test('dont hoist @charset in comments', async () => { + const css = `.foo{color:red;}/* @charset "utf-8"; */@charset "utf-8";` + const result = await hoistAtRules(css) + expect(result).toBe( + `@charset "utf-8";.foo{color:red;}/* @charset "utf-8"; */` + ) + }) + + test('dont hoist @import and @charset in comments', async () => { + const css = ` + .foo{color:red;} + /* + @import "bla"; + */ + @charset "utf-8"; + /* + @charset "utf-8"; + @import "bar"; + */ + @import "baz"; + ` + const result = await hoistAtRules(css) + expect(result).toBe( + `@charset "utf-8";@import "baz"; + .foo{color:red;} + /* + @import "bla"; + */ + + /* + @charset "utf-8"; + @import "bar"; + */ + + ` ) }) }) diff --git a/packages/vite/src/node/cleanString.ts b/packages/vite/src/node/cleanString.ts index 3d623dce79c0d3..9b9ef656f4e017 100644 --- a/packages/vite/src/node/cleanString.ts +++ b/packages/vite/src/node/cleanString.ts @@ -1,10 +1,14 @@ import type { RollupError } from 'rollup' +import { multilineCommentsRE, singlelineCommentsRE } from './utils' + // bank on the non-overlapping nature of regex matches and combine all filters into one giant regex // /`([^`\$\{\}]|\$\{(`|\g<1>)*\})*`/g can match nested string template // but js not support match expression(\g<0>). so clean string template(`...`) in other ways. -const stringsRE = /"([^"\r\n]|(?<=\\)")*"|'([^'\r\n]|(?<=\\)')*'/.source -const commentsRE = /\/\*(.|[\r\n])*?\*\/|\/\/.*/.source -const cleanerRE = new RegExp(`${stringsRE}|${commentsRE}`, 'g') +const stringsRE = /"([^"\r\n]|(?<=\\)")*"|'([^'\r\n]|(?<=\\)')*'/g +const cleanerRE = new RegExp( + `${stringsRE.source}|${multilineCommentsRE.source}|${singlelineCommentsRE.source}`, + 'g' +) const blankReplacer = (s: string) => ' '.repeat(s.length) const stringBlankReplacer = (s: string) => @@ -26,6 +30,10 @@ export function emptyString(raw: string): string { return res } +export function emptyCssComments(raw: string) { + return raw.replace(multilineCommentsRE, blankReplacer) +} + const enum LexerState { // template string inTemplateString, diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index 83e18aabecdb33..fef1b6cb7ac515 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -48,6 +48,7 @@ import { transform, formatMessages } from 'esbuild' import { addToHTMLProxyTransformResult } from './html' import { injectSourcesContent, getCodeWithSourcemap } from '../server/sourcemap' import type { RawSourceMap } from '@ampproject/remapping' +import { emptyCssComments } from '../cleanString' // const debug = createDebugger('vite:css') @@ -1117,30 +1118,34 @@ async function minifyCSS(css: string, config: ResolvedConfig) { export async function hoistAtRules(css: string) { const s = new MagicString(css) + const cleanCss = emptyCssComments(css) + let match: RegExpExecArray | null + // #1845 // CSS @import can only appear at top of the file. We need to hoist all @import // to top when multiple files are concatenated. // match until semicolon that's not in quotes - s.replace( - /@import\s*(?:url\([^\)]*\)|"([^"]|(?<=\\)")*"|'([^']|(?<=\\)')*'|[^;]*).*?;/gm, - (match) => { - s.appendLeft(0, match) - return '' - } - ) + const atImportRE = + /@import\s*(?:url\([^\)]*\)|"([^"]|(?<=\\)")*"|'([^']|(?<=\\)')*'|[^;]*).*?;/gm + while ((match = atImportRE.exec(cleanCss))) { + s.remove(match.index, match.index + match[0].length) + // Use `appendLeft` instead of `prepend` to preserve original @import order + s.appendLeft(0, match[0]) + } + // #6333 // CSS @charset must be the top-first in the file, hoist the first to top + const atCharsetRE = + /@charset\s*(?:"([^"]|(?<=\\)")*"|'([^']|(?<=\\)')*'|[^;]*).*?;/gm let foundCharset = false - s.replace( - /@charset\s*(?:"([^"]|(?<=\\)")*"|'([^']|(?<=\\)')*'|[^;]*).*?;/gm, - (match) => { - if (!foundCharset) { - s.prepend(match) - foundCharset = true - } - return '' + while ((match = atCharsetRE.exec(cleanCss))) { + s.remove(match.index, match.index + match[0].length) + if (!foundCharset) { + s.prepend(match[0]) + foundCharset = true } - ) + } + return s.toString() } From 206e1f2cd48b86396f57338ad494da3e1939b647 Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Thu, 28 Apr 2022 01:06:06 +0800 Subject: [PATCH 087/175] docs: clarify loadEnv (#7872) --- docs/config/index.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/config/index.md b/docs/config/index.md index aaa5dcd47ad361..7f051399d1a1e7 100644 --- a/docs/config/index.md +++ b/docs/config/index.md @@ -94,7 +94,7 @@ If the config needs to call async function, it can export a async function inste export default defineConfig(async ({ command, mode }) => { const data = await asyncFunction() return { - // build specific config + // vite config } }) ``` @@ -109,10 +109,14 @@ Note that Vite doesn't load `.env` files by default as the files to load can onl import { defineConfig, loadEnv } from 'vite' export default defineConfig(({ command, mode }) => { - // Load env file based on `mode` in the current working directory - const env = loadEnv(mode, process.cwd()) + // Load env file based on `mode` in the current working directory. + // Set the third parameter to '' to load all env regardless of the `VITE_` prefix. + const env = loadEnv(mode, process.cwd(), '') return { - // build specific config + // vite config + define: { + __APP_ENV__: env.APP_ENV + } } }) ``` From 50672e4f8bc6d23cef735b922e8e0439acb5fe27 Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Thu, 28 Apr 2022 01:20:53 +0800 Subject: [PATCH 088/175] fix: use NODE_ENV in optimizer (#7673) --- packages/playground/optimize-deps/.env | 1 + .../optimize-deps/__tests__/optimize-deps.spec.ts | 4 ++++ packages/playground/optimize-deps/dep-node-env/index.js | 1 + packages/playground/optimize-deps/dep-node-env/package.json | 5 +++++ packages/playground/optimize-deps/index.html | 6 ++++++ packages/playground/optimize-deps/package.json | 1 + packages/vite/src/node/optimizer/index.ts | 4 ++-- pnpm-lock.yaml | 5 +++++ 8 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 packages/playground/optimize-deps/.env create mode 100644 packages/playground/optimize-deps/dep-node-env/index.js create mode 100644 packages/playground/optimize-deps/dep-node-env/package.json diff --git a/packages/playground/optimize-deps/.env b/packages/playground/optimize-deps/.env new file mode 100644 index 00000000000000..995fca4af2ee24 --- /dev/null +++ b/packages/playground/optimize-deps/.env @@ -0,0 +1 @@ +NODE_ENV=production \ No newline at end of file diff --git a/packages/playground/optimize-deps/__tests__/optimize-deps.spec.ts b/packages/playground/optimize-deps/__tests__/optimize-deps.spec.ts index d95a6d984cd9aa..e832408370969a 100644 --- a/packages/playground/optimize-deps/__tests__/optimize-deps.spec.ts +++ b/packages/playground/optimize-deps/__tests__/optimize-deps.spec.ts @@ -62,6 +62,10 @@ test('import * from optimized dep', async () => { expect(await page.textContent('.import-star')).toMatch(`[success]`) }) +test('import from dep with process.env.NODE_ENV', async () => { + expect(await page.textContent('.node-env')).toMatch(`prod`) +}) + test('import from dep with .notjs files', async () => { expect(await page.textContent('.not-js')).toMatch(`[success]`) }) diff --git a/packages/playground/optimize-deps/dep-node-env/index.js b/packages/playground/optimize-deps/dep-node-env/index.js new file mode 100644 index 00000000000000..8548c37894539f --- /dev/null +++ b/packages/playground/optimize-deps/dep-node-env/index.js @@ -0,0 +1 @@ +export const env = process.env.NODE_ENV === 'production' ? 'prod' : 'dev' diff --git a/packages/playground/optimize-deps/dep-node-env/package.json b/packages/playground/optimize-deps/dep-node-env/package.json new file mode 100644 index 00000000000000..59a00fb153c522 --- /dev/null +++ b/packages/playground/optimize-deps/dep-node-env/package.json @@ -0,0 +1,5 @@ +{ + "name": "dep-node-env", + "private": true, + "version": "1.0.0" +} diff --git a/packages/playground/optimize-deps/index.html b/packages/playground/optimize-deps/index.html index 2be896d00acba9..521d54379863d9 100644 --- a/packages/playground/optimize-deps/index.html +++ b/packages/playground/optimize-deps/index.html @@ -38,6 +38,9 @@

Optimizing force included dep even when it's linked

import * as ...

+

Import from dependency with process.env.NODE_ENV

+
+

Import from dependency with .notjs files

@@ -88,6 +91,9 @@

Reused variable names

text('.import-star', `[success] ${keys.join(', ')}`) } + import { env } from 'dep-node-env' + text('.node-env', env) + import { notjsValue } from 'dep-not-js' text('.not-js', notjsValue) diff --git a/packages/playground/optimize-deps/package.json b/packages/playground/optimize-deps/package.json index 2752e691da6fb2..904db5fc65f0ad 100644 --- a/packages/playground/optimize-deps/package.json +++ b/packages/playground/optimize-deps/package.json @@ -17,6 +17,7 @@ "dep-esbuild-plugin-transform": "file:./dep-esbuild-plugin-transform", "dep-linked": "link:./dep-linked", "dep-linked-include": "link:./dep-linked-include", + "dep-node-env": "file:./dep-node-env", "dep-not-js": "file:./dep-not-js", "dep-with-dynamic-import": "file:./dep-with-dynamic-import", "lodash-es": "^4.17.21", diff --git a/packages/vite/src/node/optimizer/index.ts b/packages/vite/src/node/optimizer/index.ts index 3828cb2fbce18b..4e4fb5a8c895ae 100644 --- a/packages/vite/src/node/optimizer/index.ts +++ b/packages/vite/src/node/optimizer/index.ts @@ -445,7 +445,7 @@ export async function runOptimizeDeps( } const define: Record = { - 'process.env.NODE_ENV': JSON.stringify(config.mode) + 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || config.mode) } for (const key in config.define) { const value = config.define[key] @@ -790,7 +790,7 @@ export function getDepHash(config: ResolvedConfig): string { // only a subset of config options that can affect dep optimization content += JSON.stringify( { - mode: config.mode, + mode: process.env.NODE_ENV || config.mode, root: config.root, define: config.define, resolve: config.resolve, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ad65e136bd1b56..a0ee11e84690b1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -317,6 +317,7 @@ importers: dep-esbuild-plugin-transform: file:./dep-esbuild-plugin-transform dep-linked: link:./dep-linked dep-linked-include: link:./dep-linked-include + dep-node-env: file:./dep-node-env dep-not-js: file:./dep-not-js dep-with-dynamic-import: file:./dep-with-dynamic-import lodash-es: ^4.17.21 @@ -336,6 +337,7 @@ importers: dep-esbuild-plugin-transform: link:dep-esbuild-plugin-transform dep-linked: link:dep-linked dep-linked-include: link:dep-linked-include + dep-node-env: link:dep-node-env dep-not-js: link:dep-not-js dep-with-dynamic-import: link:dep-with-dynamic-import lodash-es: 4.17.21 @@ -371,6 +373,9 @@ importers: dependencies: react: 17.0.2 + packages/playground/optimize-deps/dep-node-env: + specifiers: {} + packages/playground/optimize-deps/dep-not-js: specifiers: {} From 7f535aca8e8683506b2535c3256292abce7b0615 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Thu, 28 Apr 2022 03:43:27 +0900 Subject: [PATCH 089/175] chore(css): catch postcss config error (fix #2793) (#7934) --- packages/vite/src/node/plugins/css.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index fef1b6cb7ac515..f310abc9bc7c56 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -942,14 +942,22 @@ async function resolvePostcssConfig( plugins: inlineOptions.plugins || [] } } else { + const searchPath = + typeof inlineOptions === 'string' ? inlineOptions : config.root try { - const searchPath = - typeof inlineOptions === 'string' ? inlineOptions : config.root // @ts-ignore result = await postcssrc({}, searchPath) } catch (e) { if (!/No PostCSS Config found/.test(e.message)) { - throw e + if (e instanceof Error) { + const { name, message, stack } = e + e.name = 'Failed to load PostCSS config' + e.message = `Failed to load PostCSS config (searchPath: ${searchPath}): [${name}] ${message}\n${stack}` + e.stack = '' // add stack to message to retain stack + throw e + } else { + throw new Error(`Failed to load PostCSS config: ${e}`) + } } result = null } From 274c10eb9e9451620981da808e143bc50b8c2a38 Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Thu, 28 Apr 2022 13:45:55 +0800 Subject: [PATCH 090/175] fix(css): support postcss.config.ts (#7935) --- packages/playground/tailwind/package.json | 3 ++- .../tailwind/{postcss.config.js => postcss.config.ts} | 2 +- packages/vite/rollup.config.js | 5 +++++ pnpm-lock.yaml | 2 ++ 4 files changed, 10 insertions(+), 2 deletions(-) rename packages/playground/tailwind/{postcss.config.js => postcss.config.ts} (85%) diff --git a/packages/playground/tailwind/package.json b/packages/playground/tailwind/package.json index ff79908d386e96..1feeb8dfb89e31 100644 --- a/packages/playground/tailwind/package.json +++ b/packages/playground/tailwind/package.json @@ -15,6 +15,7 @@ "vue-router": "^4.0.0" }, "devDependencies": { - "@vitejs/plugin-vue": "workspace:*" + "@vitejs/plugin-vue": "workspace:*", + "ts-node": "^10.4.0" } } diff --git a/packages/playground/tailwind/postcss.config.js b/packages/playground/tailwind/postcss.config.ts similarity index 85% rename from packages/playground/tailwind/postcss.config.js rename to packages/playground/tailwind/postcss.config.ts index b73493f7f96fae..381d8cbd107f81 100644 --- a/packages/playground/tailwind/postcss.config.js +++ b/packages/playground/tailwind/postcss.config.ts @@ -1,4 +1,4 @@ -// postcss.config.js +// postcss.config.ts module.exports = { plugins: { tailwindcss: { config: __dirname + '/tailwind.config.js' }, diff --git a/packages/vite/rollup.config.js b/packages/vite/rollup.config.js index 31ab56cd07e02e..93f4f33bdec398 100644 --- a/packages/vite/rollup.config.js +++ b/packages/vite/rollup.config.js @@ -171,6 +171,11 @@ const createNodeConfig = (isProduction) => { 'lilconfig/dist/index.js': { pattern: /: require,/g, replacement: `: eval('require'),` + }, + // postcss-load-config calls require after register ts-node + 'postcss-load-config/src/index.js': { + src: `require(configFile)`, + replacement: `eval('require')(configFile)` } }), commonjs({ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a0ee11e84690b1..0f0711811935b6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -661,6 +661,7 @@ importers: '@vitejs/plugin-vue': workspace:* autoprefixer: ^10.4.0 tailwindcss: ^2.2.19 + ts-node: ^10.4.0 vue: ^3.2.25 vue-router: ^4.0.0 dependencies: @@ -670,6 +671,7 @@ importers: vue-router: 4.0.12_vue@3.2.26 devDependencies: '@vitejs/plugin-vue': link:../../plugin-vue + ts-node: 10.4.0_233d9fcfccc8abc8f146a08357d842da packages/playground/tailwind-sourcemap: specifiers: From 71b1443aa56c1e28959eaa40dc8a5fed652480c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Sat, 30 Apr 2022 03:23:51 +0900 Subject: [PATCH 091/175] chore: add core.symlinks description to CONTRIBUTING.md (#7962) --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c7020c97a84c80..bed97a0d7d4300 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -69,7 +69,7 @@ And re-run `pnpm install` to link the package. Each package under `packages/playground/` contains a `__tests__` directory. The tests are run using [Jest](https://jestjs.io/) + [Playwright](https://playwright.dev/) with custom integrations to make writing tests simple. The detailed setup is inside `jest.config.js` and `scripts/jest*` files. -Before running the tests, make sure that [Vite has been built](#repo-setup). On Windows, you may want to [activate Developer Mode](https://docs.microsoft.com/en-us/windows/apps/get-started/enable-your-device-for-development) to solve [issues with symlink creation for non-admins](https://github.com/vitejs/vite/issues/7390). +Before running the tests, make sure that [Vite has been built](#repo-setup). On Windows, you may want to [activate Developer Mode](https://docs.microsoft.com/en-us/windows/apps/get-started/enable-your-device-for-development) to solve [issues with symlink creation for non-admins](https://github.com/vitejs/vite/issues/7390). Also you may want to [set git `core.symlinks` to `true` to solve issues with symlinks in git](https://github.com/vitejs/vite/issues/5242). Each test can be run under either dev server mode or build mode. From f7d2d713befe916c4d84b5e1705e20386948a61f Mon Sep 17 00:00:00 2001 From: patak Date: Sat, 30 Apr 2022 06:13:30 +0200 Subject: [PATCH 092/175] fix: inject esbuild helpers in IIFE and UMD wrappers (#7948) --- packages/playground/lib/__tests__/lib.spec.ts | 12 +++++++++ packages/playground/lib/src/main.js | 3 +++ packages/vite/src/node/plugins/esbuild.ts | 25 +++++++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/packages/playground/lib/__tests__/lib.spec.ts b/packages/playground/lib/__tests__/lib.spec.ts index 382fb16510ce6f..f1e93e90d8357b 100644 --- a/packages/playground/lib/__tests__/lib.spec.ts +++ b/packages/playground/lib/__tests__/lib.spec.ts @@ -9,10 +9,22 @@ if (isBuild) { test('umd', async () => { expect(await page.textContent('.umd')).toBe('It works') + const code = fs.readFileSync( + path.join(testDir, 'dist/my-lib-custom-filename.umd.js'), + 'utf-8' + ) + // esbuild helpers are injected inside of the UMD wrapper + expect(code).toMatch(/^\(function\(/) }) test('iife', async () => { expect(await page.textContent('.iife')).toBe('It works') + const code = fs.readFileSync( + path.join(testDir, 'dist/my-lib-custom-filename.iife.js'), + 'utf-8' + ) + // esbuild helpers are injected inside of the IIFE wrapper + expect(code).toMatch(/^var MyLib=function\(\){"use strict";/) }) test('Library mode does not include `preload`', async () => { diff --git a/packages/playground/lib/src/main.js b/packages/playground/lib/src/main.js index 2422edf5829a0e..cb2fb3b842dc4f 100644 --- a/packages/playground/lib/src/main.js +++ b/packages/playground/lib/src/main.js @@ -1,3 +1,6 @@ export default function myLib(sel) { + // Force esbuild spread helpers (https://github.com/evanw/esbuild/issues/951) + console.log({ ...'foo' }) + document.querySelector(sel).textContent = 'It works' } diff --git a/packages/vite/src/node/plugins/esbuild.ts b/packages/vite/src/node/plugins/esbuild.ts index 9e8bae24424d76..bc4a1f780a54d5 100644 --- a/packages/vite/src/node/plugins/esbuild.ts +++ b/packages/vite/src/node/plugins/esbuild.ts @@ -26,6 +26,11 @@ import { searchForWorkspaceRoot } from '..' const debug = createDebugger('vite:esbuild') +const INJECT_HELPERS_IIFE_RE = + /(.*)(var [^\s]+=function\(.*\){"use strict";)(.*)/ +const INJECT_HELPERS_UMD_RE = + /(.*)(\(function\(.*\){.+amd.+function\(.*\){"use strict";)(.*)/ + let server: ViteDevServer export interface ESBuildOptions extends TransformOptions { @@ -254,6 +259,26 @@ export const buildEsbuildPlugin = (config: ResolvedConfig): Plugin => { } : undefined) }) + + if (config.build.lib) { + // #7188, esbuild adds helpers out of the UMD and IIFE wrappers, and the + // names are minified potentially causing collision with other globals. + // We use a regex to inject the helpers inside the wrappers. + // We don't need to create a MagicString here because both the helpers and + // the headers don't modify the sourcemap + const injectHelpers = + opts.format === 'umd' + ? INJECT_HELPERS_UMD_RE + : opts.format === 'iife' + ? INJECT_HELPERS_IIFE_RE + : undefined + if (injectHelpers) { + res.code = res.code.replace( + injectHelpers, + (_, helpers, header, rest) => header + helpers + rest + ) + } + } return res } } From 2b4aab0bf45e9fb67aa8f5453a3db6beb7519c9f Mon Sep 17 00:00:00 2001 From: Tedy <1197633750@qq.com> Date: Sat, 30 Apr 2022 12:14:16 +0800 Subject: [PATCH 093/175] chore: fix typo (#7967) --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bed97a0d7d4300..621f8de145835f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -42,7 +42,7 @@ Some errors are masked and hidden away because of the layers of abstraction and 1. In the sources panel in the right column, click the play button to resume execution and allow the tests to run which will open a Chromium instance. -1. Focusing the Chomium instance, you can open the browser devtools and inspect the console there to find the underlying problems. +1. Focusing the Chromium instance, you can open the browser devtools and inspect the console there to find the underlying problems. 1. To close everything, just stop the test process back in your terminal. From a9fa60b37e373adbf240b184fa801fa19aacfcf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Sat, 30 Apr 2022 13:15:45 +0900 Subject: [PATCH 094/175] chore: bump vue in ssr-vue (#7965) --- packages/playground/ssr-vue/package.json | 2 +- pnpm-lock.yaml | 37 ++++++++++++++---------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/packages/playground/ssr-vue/package.json b/packages/playground/ssr-vue/package.json index 4a385336a97603..02aa3b89bc0dbb 100644 --- a/packages/playground/ssr-vue/package.json +++ b/packages/playground/ssr-vue/package.json @@ -15,7 +15,7 @@ }, "dependencies": { "example-external-component": "file:example-external-component", - "vue": "^3.2.25", + "vue": "^3.2.33", "vue-router": "^4.0.0", "vuex": "^4.0.2" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0f0711811935b6..73be476b1c911b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -622,14 +622,14 @@ importers: example-external-component: file:example-external-component express: ^4.17.1 serve-static: ^1.14.1 - vue: ^3.2.25 + vue: ^3.2.33 vue-router: ^4.0.0 vuex: ^4.0.2 dependencies: example-external-component: link:example-external-component - vue: 3.2.26 - vue-router: 4.0.12_vue@3.2.26 - vuex: 4.0.2_vue@3.2.26 + vue: 3.2.33 + vue-router: 4.0.12_vue@3.2.33 + vuex: 4.0.2_vue@3.2.33 devDependencies: '@vitejs/plugin-vue': link:../../plugin-vue '@vitejs/plugin-vue-jsx': link:../../plugin-vue-jsx @@ -2893,7 +2893,6 @@ packages: '@vue/shared': 3.2.33 estree-walker: 2.0.2 source-map: 0.6.1 - dev: true /@vue/compiler-dom/3.2.26: resolution: {integrity: sha512-smBfaOW6mQDxcT3p9TKT6mE22vjxjJL50GFVJiI0chXYGU/xzC05QRGrW3HHVuJrmLTLx5zBhsZ2dIATERbarg==} @@ -2912,7 +2911,6 @@ packages: dependencies: '@vue/compiler-core': 3.2.33 '@vue/shared': 3.2.33 - dev: true /@vue/compiler-sfc/3.2.26: resolution: {integrity: sha512-ePpnfktV90UcLdsDQUh2JdiTuhV0Skv2iYXxfNMOK/F3Q+2BO0AulcVcfoksOpTJGmhhfosWfMyEaEf0UaWpIw==} @@ -2955,7 +2953,6 @@ packages: magic-string: 0.25.7 postcss: 8.4.12 source-map: 0.6.1 - dev: true /@vue/compiler-ssr/3.2.26: resolution: {integrity: sha512-2mywLX0ODc4Zn8qBoA2PDCsLEZfpUGZcyoFRLSOjyGGK6wDy2/5kyDOWtf0S0UvtoyVq95OTSGIALjZ4k2q/ag==} @@ -2974,7 +2971,6 @@ packages: dependencies: '@vue/compiler-dom': 3.2.33 '@vue/shared': 3.2.33 - dev: true /@vue/devtools-api/6.0.0-beta.21.1: resolution: {integrity: sha512-FqC4s3pm35qGVeXRGOjTsRzlkJjrBLriDS9YXbflHLsfA9FrcKzIyWnLXoNm+/7930E8rRakXuAc2QkC50swAw==} @@ -3006,7 +3002,6 @@ packages: '@vue/shared': 3.2.33 estree-walker: 2.0.2 magic-string: 0.25.7 - dev: true /@vue/reactivity/3.2.26: resolution: {integrity: sha512-h38bxCZLW6oFJVDlCcAiUKFnXI8xP8d+eO0pcDxx+7dQfSPje2AO6M9S9QO6MrxQB7fGP0DH0dYQ8ksf6hrXKQ==} @@ -3022,7 +3017,6 @@ packages: resolution: {integrity: sha512-62Sq0mp9/0bLmDuxuLD5CIaMG2susFAGARLuZ/5jkU1FCf9EDbwUuF+BO8Ub3Rbodx0ziIecM/NsmyjardBxfQ==} dependencies: '@vue/shared': 3.2.33 - dev: true /@vue/runtime-core/3.2.26: resolution: {integrity: sha512-BcYi7qZ9Nn+CJDJrHQ6Zsmxei2hDW0L6AB4vPvUQGBm2fZyC0GXd/4nVbyA2ubmuhctD5RbYY8L+5GUJszv9mQ==} @@ -3041,7 +3035,6 @@ packages: dependencies: '@vue/reactivity': 3.2.33 '@vue/shared': 3.2.33 - dev: true /@vue/runtime-dom/3.2.26: resolution: {integrity: sha512-dY56UIiZI+gjc4e8JQBwAifljyexfVCkIAu/WX8snh8vSOt/gMSEGwPRcl2UpYpBYeyExV8WCbgvwWRNt9cHhQ==} @@ -3063,7 +3056,6 @@ packages: '@vue/runtime-core': 3.2.33 '@vue/shared': 3.2.33 csstype: 2.6.19 - dev: true /@vue/server-renderer/3.2.26_vue@3.2.26: resolution: {integrity: sha512-Jp5SggDUvvUYSBIvYEhy76t4nr1vapY/FIFloWmQzn7UxqaHrrBpbxrqPcTrSgGrcaglj0VBp22BKJNre4aA1w==} @@ -3091,7 +3083,6 @@ packages: '@vue/compiler-ssr': 3.2.33 '@vue/shared': 3.2.33 vue: 3.2.33 - dev: true /@vue/shared/3.2.26: resolution: {integrity: sha512-vPV6Cq+NIWbH5pZu+V+2QHE9y1qfuTq49uNWw4f7FDEeZaDU2H2cx5jcUZOAKW7qTrUS4k6qZPbMy1x4N96nbA==} @@ -3101,7 +3092,6 @@ packages: /@vue/shared/3.2.33: resolution: {integrity: sha512-UBc1Pg1T3yZ97vsA2ueER0F6GbJebLHYlEi4ou1H5YL4KWvMOOWwpYo9/QpWq93wxKG6Wo13IY74Hcn/f7c7Bg==} - dev: true /@wessberg/stringutil/1.0.19: resolution: {integrity: sha512-9AZHVXWlpN8Cn9k5BC/O0Dzb9E9xfEMXzYrNunwvkUTvuK7xgQPVRZpLo+jWCOZ5r8oBa8NIrHuPEu1hzbb6bg==} @@ -9537,6 +9527,15 @@ packages: vue: 3.2.26 dev: false + /vue-router/4.0.12_vue@3.2.33: + resolution: {integrity: sha512-CPXvfqe+mZLB1kBWssssTiWg4EQERyqJZes7USiqfW9B5N2x+nHlnsM1D3b5CaJ6qgCvMmYJnz+G0iWjNCvXrg==} + peerDependencies: + vue: ^3.0.0 + dependencies: + '@vue/devtools-api': 6.0.0-beta.21.1 + vue: 3.2.33 + dev: false + /vue/3.2.26: resolution: {integrity: sha512-KD4lULmskL5cCsEkfhERVRIOEDrfEL9CwAsLYpzptOGjaGFNWo3BQ9g8MAb7RaIO71rmVOziZ/uEN/rHwcUIhg==} dependencies: @@ -9563,7 +9562,6 @@ packages: '@vue/runtime-dom': 3.2.33 '@vue/server-renderer': 3.2.33_vue@3.2.33 '@vue/shared': 3.2.33 - dev: true /vuex/4.0.2_vue@3.2.26: resolution: {integrity: sha512-M6r8uxELjZIK8kTKDGgZTYX/ahzblnzC4isU1tpmEuOIIKmV+TRdc+H4s8ds2NuZ7wpUTdGRzJRtoj+lI+pc0Q==} @@ -9574,6 +9572,15 @@ packages: vue: 3.2.26 dev: false + /vuex/4.0.2_vue@3.2.33: + resolution: {integrity: sha512-M6r8uxELjZIK8kTKDGgZTYX/ahzblnzC4isU1tpmEuOIIKmV+TRdc+H4s8ds2NuZ7wpUTdGRzJRtoj+lI+pc0Q==} + peerDependencies: + vue: ^3.0.2 + dependencies: + '@vue/devtools-api': 6.0.0-beta.21.1 + vue: 3.2.33 + dev: false + /w3c-hr-time/1.0.2: resolution: {integrity: sha512-z8P5DvDNjKDoFIHK7q8r8lackT6l+jo/Ye3HOle7l9nICP9lf1Ci25fy9vHd0JOWewkIFzXIEig3TdKT7JQ5fQ==} dependencies: From a30a5489ccac56ec668546af840984367c356a38 Mon Sep 17 00:00:00 2001 From: yoho Date: Sat, 30 Apr 2022 12:19:24 +0800 Subject: [PATCH 095/175] fix: inline style hmr, transform style code inplace (#7869) --- .../assets/__tests__/assets.spec.ts | 7 +- packages/playground/assets/index.html | 20 +++++- .../css-sourcemap/__tests__/serve.spec.ts | 62 ------------------ packages/playground/hmr/__tests__/hmr.spec.ts | 12 +++- packages/playground/hmr/icon.png | Bin 0 -> 3395 bytes packages/playground/hmr/index.html | 9 +++ packages/playground/ssr-html/index.html | 5 ++ packages/vite/src/node/plugins/css.ts | 9 ++- .../src/node/server/middlewares/indexHtml.ts | 41 ++++++++++-- 9 files changed, 91 insertions(+), 74 deletions(-) create mode 100644 packages/playground/hmr/icon.png diff --git a/packages/playground/assets/__tests__/assets.spec.ts b/packages/playground/assets/__tests__/assets.spec.ts index 75c0e57952db24..19dd52f71e114a 100644 --- a/packages/playground/assets/__tests__/assets.spec.ts +++ b/packages/playground/assets/__tests__/assets.spec.ts @@ -1,4 +1,3 @@ -import { createHash } from 'crypto' import { findAssetFile, getBg, @@ -296,6 +295,11 @@ describe('css and assets in css in build watch', () => { } }) +test('inline style test', async () => { + expect(await getBg('.inline-style')).toMatch(assetMatch) + expect(await getBg('.style-url-assets')).toMatch(assetMatch) +}) + if (!isBuild) { test('@import in html style tag hmr', async () => { await untilUpdated(() => getColor('.import-css'), 'rgb(0, 136, 255)') @@ -304,6 +308,7 @@ if (!isBuild) { (code) => code.replace('#0088ff', '#00ff88'), true ) + await page.waitForNavigation() await untilUpdated(() => getColor('.import-css'), 'rgb(0, 255, 136)') }) } diff --git a/packages/playground/assets/index.html b/packages/playground/assets/index.html index 6678a2da7c2106..99c2c2fe69ae70 100644 --- a/packages/playground/assets/index.html +++ b/packages/playground/assets/index.html @@ -207,7 +207,10 @@

url

background-size: 10px 10px; } -
+
inline style
use style class
@@ -235,6 +238,21 @@

import module css

+

style in svg

+ + + + + + + + diff --git a/packages/playground/css-sourcemap/__tests__/serve.spec.ts b/packages/playground/css-sourcemap/__tests__/serve.spec.ts index 11e33a78af8424..becd792e82293a 100644 --- a/packages/playground/css-sourcemap/__tests__/serve.spec.ts +++ b/packages/playground/css-sourcemap/__tests__/serve.spec.ts @@ -17,68 +17,6 @@ if (!isBuild) { throw new Error('Not found') } - test('inline css', async () => { - const css = await getStyleTagContentIncluding('.inline ') - const map = extractSourcemap(css) - expect(formatSourcemapForSnapshot(map)).toMatchInlineSnapshot(` - Object { - "mappings": "AAGO;AACP,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACX,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACf,CAAC,CAAC,CAAC;", - "sources": Array [ - "/root/index.html", - ], - "sourcesContent": Array [ - " - - - - -
-

CSS Sourcemap

- -

<inline>

- -

<linked>: no import

-

<linked>: with import

- -

<imported>: no import

-

<imported>: with import

- -

<imported sass>

-

<imported sass> with module

- -

<imported less> with string additionalData

- -

<imported stylus>

-
- - - - - ", - ], - "version": 3, - } - `) - }) - test('linked css', async () => { const res = await page.request.get( new URL('./linked.css', page.url()).href, diff --git a/packages/playground/hmr/__tests__/hmr.spec.ts b/packages/playground/hmr/__tests__/hmr.spec.ts index 40b2bdf31b7956..34612ee1e7d3d5 100644 --- a/packages/playground/hmr/__tests__/hmr.spec.ts +++ b/packages/playground/hmr/__tests__/hmr.spec.ts @@ -1,4 +1,4 @@ -import { isBuild, editFile, untilUpdated } from '../../testUtils' +import { isBuild, editFile, untilUpdated, getBg } from '../../testUtils' test('should render', async () => { expect(await page.textContent('.app')).toBe('1') @@ -195,6 +195,16 @@ if (!isBuild) { expect(await btn.textContent()).toBe('Counter 1') }) + test('css in html hmr', async () => { + await page.goto(viteTestUrl) + expect(await getBg('.import-image')).toMatch('icon') + await page.goto(viteTestUrl + '/foo/') + expect(await getBg('.import-image')).toMatch('icon') + editFile('index.html', (code) => code.replace('url("./icon.png")', '')) + await page.waitForNavigation() + expect(await getBg('.import-image')).toMatch('') + }) + test('HTML', async () => { await page.goto(viteTestUrl + '/counter/index.html') let btn = await page.$('button') diff --git a/packages/playground/hmr/icon.png b/packages/playground/hmr/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..4388bfdca3d4d778d2f25a5861599f8f19a1177c GIT binary patch literal 3395 zcmaJ^dpy(o8y`aCQb$M{Gf69KbDPa&mJzw-a@=pT&3zZ!m|LaXQi-Stqav};(cC3M zM}?d^vCOT0I;N7*N=fvaPM!1nKF&@kJcVR{+lVnpAW=nV5g|H(io-_}8K6*NcqG{pEa>P0gCYr*U~dy=m^0Oe z7!hfoL?e16xp?A}qVY%q7;OczNI;1QNJIt>lt79h(@_bQ;BUMr(S5@W1%tkYFrqEN ze~R*PJ`A#<(1;)t15+!P8!LgB{xFgOZ^M8V*o?+;j% zjYbGVxnu3V=Mq_#;0OkTih@F!Or`4OCV95o&O>x)4w-L)G}xSjtYevz@Q}3MqS^c z=?r(`-!lF&n(moMB|_babV?izFPcY~_7AYAcmJMfBT%FUg{9!*NJKKj0c!~sc?<}V z1e6KP(DZx{!kk~eI~MsL4MCDJ0}i3B?ug#`N698}~# z2*4l^2$-pjof!hNA>QZ!0*1A7WRL!P>~qu#$^9z(m!0H z_1U=owYMVUugxctMe9xz?e+DZ*aiSVrr80D@l4=N_`ae9j3}c&b|M6c^Scw&#v42` zs@=W24^$JB&ZnFHq$6hgI?L<)7qPYdpMFDMm5r*2NZZ#;hNLU%;UMB}lBX&zgLa?a z^q;(Rv!#SE3*p7_>9&tfp}FA;>iv!v_p|!wd;>mn_^936qi>ng*>kFww|a^}qJTRK znA`1@E!Y|;+Yc3d2h!d=ZZPN&V<0ppw;;&qMLk zs8GnX$?aj;YSC%6t7ryd|Y^9Qc9F|ZTi%4o)Pe;3_TsRPSb<*4*B>QW0CG(vI z>y^yW0M4}!mMf3!4z1fO+L~w1pRfz#LUd11)b_hvE5tyLhoKw+{E?+obcpiN*0LU8 z+U$wi{2kPnH5r4PMp&T>SNDmqNn*??;K@i|?J!$E9U15d+24QdeF^V4qsj`m?4KR1 zo+530cOpA+R_oI`YVpGHn|g}#XF^ggiIq#Q$r!(y$dA${=6vmyc6@muL~LaHK9;_U zM6ianv&69LoqCIN7iY5Nk~w}(YQ_@J^_HeBva+0R_9?+f_e~4spT$RYhq*aCNMrO$ zANmbE3u(ID)?XQ7A$ZW2RXgnhnaPNg>o$T&swba`imtoDTfX-ox*^fNY~&|)r*EP9 zDjZoQYgH3!&1P!g6r^)r`PMo_8VTHjZZPV`=6oa69GQI3%5zMi(iWaa;uA~o4%J^) zTvx7E_z4|v`9%k4yvRr!>a=q&CRMXs)EtsGU0BaC=tm1rZCwe$9zABiZcVuVM#f_O zEcY-xE#-a$$qK0SptY*~;s&%&{MxjMyzUJK)Ro2HOShN#i zdmd(sJrh3Lv2smAU0Uf)tzU1B4BTO~oK-hJav|YH;*QbtQMXN4?1g)YYj*9zWn;WS zf1=g6CNYN>p%StDbcLOA=ocrq)8-NU#|p81bRF3}y8w-f<_em-45$3L1@~e-{F^+_ zxkl==Ne8Vus0W)|3%}tC9-OE+5bT+_6f|Q*jZeS-JXh8E3%`TziByq04bJ6a1d7>H z;RYj*F8l4WsVGR4UERkbN(jGxSrPD|EDl*hJV;*`c%6d`F)1W~@pz_2+lh zX8Y6jap-cIJ8qTxvL@N3GJ-7LiuUjog<%wMNATus+JP&V$uD}fv7BWwUYMmGCIMGj z{8~4f?dWx0LX>Y-qi=!s6hE7+ubMW78h!`|R=KV%8FK zd9Sek(lv`S^5+9xYR`{X>yATq2OfeBt(}qyYA3{aLq|2d#^vB$R4#D)8lf9t!Y;+P z_6W7^{$}!gg?;4KjI39niyeEj#~ble%M>uw{nu#b`CHdh{gg9q+d8BrP^@~lDBI@d z7PMHwiV3pH(=wk3x<4;S!E(K=DJ>2!RAm*jrN_O@8jfGh%FKDK2Jufl-PsHs+4lH9 zDVKmh4;9;;mTf^PV;hRc zGZ1`0sMNGF2Q#}5#R#bM)tW_A=dSME$5(a2i}Ihk4u>_zBv%vI*myG)hHABMyPQj@ zM)WDfPOZ2LDPxwQFP3s9qT2x$(n(71$z;Qxd;tB$vX<;ZX<>Nsq(dQ>mhaX*MIFCf zb0p{bXj}2S`bD#rpHdTdNv!#{OR);Jsq8JJ*l1;(96~iudG#aZgj0Qo3WuL}YVZek z(SM)#(x7!4_(saUC6(W&b$isUNe3O4T~w_02Y#{Bs)T0h-r|>RiXN`FZb$o39EXiL z*RJ#X)VH`&nA(%q0JE_w3>ZQUex|DOv-oSu#vm zNS0_maoG$tauoZ;v)jT-lc=;EaufphG>)@S1@N~a5rr)*{bw*r-?o*rX6>8&zHcc*`CR~1#1jSw~d|R zwXi;)w4*Di+agG^bKz87RbPQwK!stmYMB_=wK@dlhtu9wFD@&T*Rq=*u7gj@78PR;rI9VW}r3UUH0!vA30jS z9UC??hXtMukpyu2>X*~v8;@W;`1_RbZHs(`$_8)1P;u9mwi4Rc0`sT=V!Y1o!I{Qq zTuHw3d^RR%uB5r{Ro1<>F8RPbj_b`$75gQNggjNu*H}~8;-HRVpN?w*H+KzOf}(^U z)d8)S!qI%E&Bf@3i1yh^Px1-jguC#MCUGbC&Rv0bg=h2Ms1B6?sLoFXEM>DdK;(^h zBZ=9iZF8CfgvLGLDUDAC>!hByzwDss&zxy_dFFE+ps2snc=RE+p+zrQ*E_9YM0{{Y z!fhZyCOLFWcsB~(RGiu+Zuz#hisxiIQ_CT@V-K)JH skXH~y@{pZ%H2RLzTI|$xG-@5%4N!D?9MV?={PtVpVC#adKM-=_zfn5szW@LL literal 0 HcmV?d00001 diff --git a/packages/playground/hmr/index.html b/packages/playground/hmr/index.html index 0add7c26011a01..65a2ed381b027a 100644 --- a/packages/playground/hmr/index.html +++ b/packages/playground/hmr/index.html @@ -1,5 +1,13 @@ +
@@ -8,3 +16,4 @@
+
diff --git a/packages/playground/ssr-html/index.html b/packages/playground/ssr-html/index.html index c37dcc7e366ae8..995c828caae1a8 100644 --- a/packages/playground/ssr-html/index.html +++ b/packages/playground/ssr-html/index.html @@ -4,6 +4,11 @@ SSR HTML +

SSR Dynamic HTML

diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index f310abc9bc7c56..8b01d48c696465 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -301,6 +301,7 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin { const inlined = inlineRE.test(id) const modules = cssModulesCache.get(config)!.get(id) + const isHTMLProxy = htmlProxyRE.test(id) const modulesCode = modules && dataToEsm(modules, { namedExports: true, preferConst: true }) @@ -323,6 +324,10 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin { cssContent = getCodeWithSourcemap('css', css, sourcemap) } + if (isHTMLProxy) { + return cssContent + } + return [ `import { updateStyle as __vite__updateStyle, removeStyle as __vite__removeStyle } from ${JSON.stringify( path.posix.join(config.base, CLIENT_PUBLIC_PATH) @@ -347,7 +352,6 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin { // and then use the cache replace inline-style-flag when `generateBundle` in vite:build-html plugin const inlineCSS = inlineCSSRE.test(id) const query = parseRequest(id) - const isHTMLProxy = htmlProxyRE.test(id) if (inlineCSS && isHTMLProxy) { addToHTMLProxyTransformResult( `${cleanUrl(id)}_${Number.parseInt(query!.index)}`, @@ -718,12 +722,11 @@ async function compileCSS( postcssConfig && postcssConfig.plugins ? postcssConfig.plugins.slice() : [] if (needInlineImport) { - const isHTMLProxy = htmlProxyRE.test(id) postcssPlugins.unshift( (await import('postcss-import')).default({ async resolve(id, basedir) { const publicFile = checkPublicFile(id, config) - if (isHTMLProxy && publicFile) { + if (publicFile) { return publicFile } diff --git a/packages/vite/src/node/server/middlewares/indexHtml.ts b/packages/vite/src/node/server/middlewares/indexHtml.ts index ca2538bd9507ed..8638492b1c2001 100644 --- a/packages/vite/src/node/server/middlewares/indexHtml.ts +++ b/packages/vite/src/node/server/middlewares/indexHtml.ts @@ -16,14 +16,25 @@ import { import type { ResolvedConfig, ViteDevServer } from '../..' import { send } from '../send' import { CLIENT_PUBLIC_PATH, FS_PREFIX } from '../../constants' -import { cleanUrl, fsPathFromId, normalizePath, injectQuery } from '../../utils' +import { + cleanUrl, + fsPathFromId, + normalizePath, + injectQuery, + ensureWatchedFile +} from '../../utils' import type { ModuleGraph } from '../moduleGraph' +interface AssetNode { + start: number + end: number + code: string +} + export function createDevHtmlTransformFn( server: ViteDevServer ): (url: string, html: string, originalUrl: string) => Promise { const [preHooks, postHooks] = resolveHtmlTransforms(server.config.plugins) - return (url: string, html: string, originalUrl: string): Promise => { return applyHtmlTransforms(html, [...preHooks, devHtmlHook, ...postHooks], { path: url, @@ -94,14 +105,15 @@ const devHtmlHook: IndexHtmlTransformHook = async ( html, { path: htmlPath, filename, server, originalUrl } ) => { - const { config, moduleGraph } = server! + const { config, moduleGraph, watcher } = server! const base = config.base || '/' const s = new MagicString(html) let inlineModuleIndex = -1 const filePath = cleanUrl(htmlPath) + const styleUrl: AssetNode[] = [] - const addInlineModule = (node: ElementNode, ext: 'js' | 'css') => { + const addInlineModule = (node: ElementNode, ext: 'js') => { inlineModuleIndex++ const url = filePath.replace(normalizePath(config.root), '') @@ -128,7 +140,6 @@ const devHtmlHook: IndexHtmlTransformHook = async ( if (module) { server?.moduleGraph.invalidateModule(module) } - s.overwrite( node.loc.start.offset, node.loc.end.offset, @@ -154,7 +165,12 @@ const devHtmlHook: IndexHtmlTransformHook = async ( } if (node.tag === 'style' && node.children.length) { - addInlineModule(node, 'css') + const children = node.children[0] as TextNode + styleUrl.push({ + start: children.loc.start.offset, + end: children.loc.end.offset, + code: children.content + }) } // elements with [href/src] attrs @@ -172,6 +188,19 @@ const devHtmlHook: IndexHtmlTransformHook = async ( } }) + await Promise.all( + styleUrl.map(async ({ start, end, code }, index) => { + const url = filename + `?html-proxy&${index}.css` + + // ensure module in graph after successful load + const mod = await moduleGraph.ensureEntryFromUrl(url, false) + ensureWatchedFile(watcher, mod.file, config.root) + + const result = await server!.pluginContainer.transform(code, url) + s.overwrite(start, end, result?.code || '') + }) + ) + html = s.toString() return { From aebaf66cdb5bd9c39225462621e6f55275790463 Mon Sep 17 00:00:00 2001 From: Anthony Campolo <12433465+ajcwebdev@users.noreply.github.com> Date: Sat, 30 Apr 2022 13:20:23 -0500 Subject: [PATCH 096/175] docs: grammar fix in getting started guide (#7972) --- docs/guide/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guide/index.md b/docs/guide/index.md index ff0d3f21b90e65..5af7c29c17ac3c 100644 --- a/docs/guide/index.md +++ b/docs/guide/index.md @@ -113,7 +113,7 @@ Running `vite` starts the dev server using the current working directory as root ## Command Line Interface -In a project where Vite is installed, you can use the `vite` binary in your npm scripts, or run it directly with `npx vite`. Here is the default npm scripts in a scaffolded Vite project: +In a project where Vite is installed, you can use the `vite` binary in your npm scripts, or run it directly with `npx vite`. Here are the default npm scripts in a scaffolded Vite project: ```json5 From 891e7fc4fa3e047be43df5c1a4703cda4a4a1f54 Mon Sep 17 00:00:00 2001 From: TrickyPi <33021497+TrickyPi@users.noreply.github.com> Date: Sun, 1 May 2022 03:11:37 +0800 Subject: [PATCH 097/175] fix(ssr): failed ssrLoadModule call throws same error (#7177) Co-authored-by: Rich Harris --- packages/vite/src/node/server/moduleGraph.ts | 1 + .../__tests__/fixtures/ssrModuleLoader-bad.js | 2 ++ .../ssr/__tests__/ssrModuleLoader.spec.ts | 29 +++++++++++++++++++ packages/vite/src/node/ssr/ssrModuleLoader.ts | 5 ++++ 4 files changed, 37 insertions(+) create mode 100644 packages/vite/src/node/ssr/__tests__/fixtures/ssrModuleLoader-bad.js create mode 100644 packages/vite/src/node/ssr/__tests__/ssrModuleLoader.spec.ts diff --git a/packages/vite/src/node/server/moduleGraph.ts b/packages/vite/src/node/server/moduleGraph.ts index 9c9f0d84bb738f..1d7ae407f110c5 100644 --- a/packages/vite/src/node/server/moduleGraph.ts +++ b/packages/vite/src/node/server/moduleGraph.ts @@ -33,6 +33,7 @@ export class ModuleNode { transformResult: TransformResult | null = null ssrTransformResult: TransformResult | null = null ssrModule: Record | null = null + ssrError: Error | null = null lastHMRTimestamp = 0 lastInvalidationTimestamp = 0 diff --git a/packages/vite/src/node/ssr/__tests__/fixtures/ssrModuleLoader-bad.js b/packages/vite/src/node/ssr/__tests__/fixtures/ssrModuleLoader-bad.js new file mode 100644 index 00000000000000..a51a0519d34003 --- /dev/null +++ b/packages/vite/src/node/ssr/__tests__/fixtures/ssrModuleLoader-bad.js @@ -0,0 +1,2 @@ +export const bad = 1 +throw new Error('it is an expected error') diff --git a/packages/vite/src/node/ssr/__tests__/ssrModuleLoader.spec.ts b/packages/vite/src/node/ssr/__tests__/ssrModuleLoader.spec.ts new file mode 100644 index 00000000000000..6a45a2b70509d0 --- /dev/null +++ b/packages/vite/src/node/ssr/__tests__/ssrModuleLoader.spec.ts @@ -0,0 +1,29 @@ +import { resolve } from 'path' +import { createServer } from '../../index' + +const badjs = resolve(__dirname, './fixtures/ssrModuleLoader-bad.js') +const THROW_MESSAGE = 'it is an expected error' + +test('always throw error when evaluating an wrong SSR module', async () => { + const viteServer = await createServer() + const spy = jest.spyOn(console, 'error').mockImplementation(() => {}) + const expectedErrors = [] + for (const i of [0, 1]) { + try { + await viteServer.ssrLoadModule(badjs) + } catch (e) { + expectedErrors.push(e) + } + } + await viteServer.close() + expect(expectedErrors).toHaveLength(2) + expect(expectedErrors[0]).toBe(expectedErrors[1]) + expectedErrors.forEach((error) => { + expect(error?.message).toContain(THROW_MESSAGE) + }) + expect(spy).toBeCalledTimes(1) + const [firstParameter] = spy.mock.calls[0] + expect(firstParameter).toContain('Error when evaluating SSR module') + expect(firstParameter).toContain(THROW_MESSAGE) + spy.mockClear() +}) diff --git a/packages/vite/src/node/ssr/ssrModuleLoader.ts b/packages/vite/src/node/ssr/ssrModuleLoader.ts index de31c6a20266c5..8b3a423f58aeab 100644 --- a/packages/vite/src/node/ssr/ssrModuleLoader.ts +++ b/packages/vite/src/node/ssr/ssrModuleLoader.ts @@ -77,6 +77,10 @@ async function instantiateModule( const { moduleGraph } = server const mod = await moduleGraph.ensureEntryFromUrl(url, true) + if (mod.ssrError) { + throw mod.ssrError + } + if (mod.ssrModule) { return mod.ssrModule } @@ -202,6 +206,7 @@ async function instantiateModule( ssrExportAll ) } catch (e) { + mod.ssrError = e if (e.stack && fixStacktrace !== false) { const stacktrace = ssrRewriteStacktrace(e.stack, moduleGraph) rebindErrorStacktrace(e, stacktrace) From a5bdb9fa706850c45134c25b77aea2dee1ea03d4 Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Sun, 1 May 2022 03:28:39 +0800 Subject: [PATCH 098/175] feat(create-vite): scaffold directory with only .git (#7971) --- packages/create-vite/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/create-vite/index.js b/packages/create-vite/index.js index cc0a78639755bb..fceef9d9885a05 100755 --- a/packages/create-vite/index.js +++ b/packages/create-vite/index.js @@ -313,7 +313,8 @@ function copyDir(srcDir, destDir) { } function isEmpty(path) { - return fs.readdirSync(path).length === 0 + const files = fs.readdirSync(path) + return files.length === 0 || (files.length === 1 && files[0] === '.git') } function emptyDir(dir) { From f6ae60db74e0fcdb8ecf47df5c8b6df86d2c3ad6 Mon Sep 17 00:00:00 2001 From: yoho Date: Sun, 1 May 2022 14:47:34 +0800 Subject: [PATCH 099/175] fix: inline css hash (#7974) --- packages/playground/html/inline/shared_a.html | 1 + packages/playground/html/vite.config.js | 1 + packages/vite/src/node/plugins/asset.ts | 2 +- packages/vite/src/node/plugins/css.ts | 5 +++-- packages/vite/src/node/plugins/html.ts | 17 +++++++++-------- 5 files changed, 15 insertions(+), 11 deletions(-) create mode 100644 packages/playground/html/inline/shared_a.html diff --git a/packages/playground/html/inline/shared_a.html b/packages/playground/html/inline/shared_a.html new file mode 100644 index 00000000000000..31fbd8fcc34bdf --- /dev/null +++ b/packages/playground/html/inline/shared_a.html @@ -0,0 +1 @@ +

inline a

diff --git a/packages/playground/html/vite.config.js b/packages/playground/html/vite.config.js index 1703e02cc05366..bfe48675cbc18f 100644 --- a/packages/playground/html/vite.config.js +++ b/packages/playground/html/vite.config.js @@ -17,6 +17,7 @@ module.exports = { zeroJS: resolve(__dirname, 'zeroJS.html'), noHead: resolve(__dirname, 'noHead.html'), noBody: resolve(__dirname, 'noBody.html'), + inlinea: resolve(__dirname, 'inline/shared_a.html'), inline1: resolve(__dirname, 'inline/shared-1.html'), inline2: resolve(__dirname, 'inline/shared-2.html'), inline3: resolve(__dirname, 'inline/unique.html'), diff --git a/packages/vite/src/node/plugins/asset.ts b/packages/vite/src/node/plugins/asset.ts index 633438cf3cb0d4..f2eed2bc28bc5a 100644 --- a/packages/vite/src/node/plugins/asset.ts +++ b/packages/vite/src/node/plugins/asset.ts @@ -337,7 +337,7 @@ async function fileToBuiltUrl( return url } -export function getAssetHash(content: Buffer): string { +export function getAssetHash(content: Buffer | string): string { return createHash('sha256').update(content).digest('hex').slice(0, 8) } diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index 8b01d48c696465..cff7eaaf3e4c52 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -33,7 +33,8 @@ import { getAssetFilename, assetUrlRE, fileToUrl, - checkPublicFile + checkPublicFile, + getAssetHash } from './asset' import MagicString from 'magic-string' import type * as PostCSS from 'postcss' @@ -354,7 +355,7 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin { const query = parseRequest(id) if (inlineCSS && isHTMLProxy) { addToHTMLProxyTransformResult( - `${cleanUrl(id)}_${Number.parseInt(query!.index)}`, + `${getAssetHash(cleanUrl(id))}_${Number.parseInt(query!.index)}`, css ) return `export default ''` diff --git a/packages/vite/src/node/plugins/html.ts b/packages/vite/src/node/plugins/html.ts index ed4250f1965869..c33811008ccb17 100644 --- a/packages/vite/src/node/plugins/html.ts +++ b/packages/vite/src/node/plugins/html.ts @@ -23,7 +23,8 @@ import { checkPublicFile, assetUrlRE, urlToBuiltUrl, - getAssetFilename + getAssetFilename, + getAssetHash } from './asset' import { isCSSRequest } from './css' import { modulePreloadPolyfillId } from './modulePreloadPolyfill' @@ -44,7 +45,7 @@ interface ScriptAssetsUrl { } const htmlProxyRE = /\?html-proxy=?[&inline\-css]*&index=(\d+)\.(js|css)$/ -const inlineCSSRE = /__VITE_INLINE_CSS__([^_]+_\d+)__/g +const inlineCSSRE = /__VITE_INLINE_CSS__([a-z\d]{8}_\d+)__/g // Do not allow preceding '.', but do allow preceding '...' for spread operations const inlineImportRE = /(?() // HTML Proxy Transform result are stored by config -// `${importer}_${query.index}` -> transformed css code -// PS: key like `/vite/packages/playground/assets/index.html_1` +// `${hash(importer)}_${query.index}` -> transformed css code +// PS: key like `hash(/vite/packages/playground/assets/index.html)_1`) export const htmlProxyResult = new Map() export function htmlInlineProxyPlugin(config: ResolvedConfig): Plugin { @@ -373,12 +374,12 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin { addToHTMLProxyCache(config, filePath, inlineModuleIndex, { code }) // will transform with css plugin and cache result with css-post plugin js += `\nimport "${id}?html-proxy&inline-css&index=${inlineModuleIndex}.css"` - + const hash = getAssetHash(cleanUrl(id)) // will transform in `applyHtmlTransforms` s.overwrite( styleNode.loc.start.offset, styleNode.loc.end.offset, - `"__VITE_INLINE_CSS__${cleanUrl(id)}_${inlineModuleIndex}__"`, + `"__VITE_INLINE_CSS__${hash}_${inlineModuleIndex}__"`, { contentOnly: true } ) } @@ -392,12 +393,12 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin { code: styleNode.content }) js += `\nimport "${id}?html-proxy&inline-css&index=${inlineModuleIndex}.css"` - + const hash = getAssetHash(cleanUrl(id)) // will transform in `applyHtmlTransforms` s.overwrite( styleNode.loc.start.offset, styleNode.loc.end.offset, - `__VITE_INLINE_CSS__${cleanUrl(id)}_${inlineModuleIndex}__`, + `__VITE_INLINE_CSS__${hash}_${inlineModuleIndex}__`, { contentOnly: true } ) } From 7f9f8f1f84b6fcf3cee45208f929050a842bd535 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Mon, 2 May 2022 03:51:18 +0900 Subject: [PATCH 100/175] fix(css): sourcemap crash with postcss (#7982) --- packages/playground/vue-sourcemap/Css.vue | 11 ++++++ .../vue-sourcemap/__tests__/serve.spec.ts | 39 +++++++++++++++++-- .../playground/vue-sourcemap/package.json | 3 +- .../vue-sourcemap/postcss.config.js | 3 ++ packages/vite/src/node/plugins/css.ts | 19 +++------ pnpm-lock.yaml | 2 + 6 files changed, 59 insertions(+), 18 deletions(-) create mode 100644 packages/playground/vue-sourcemap/postcss.config.js diff --git a/packages/playground/vue-sourcemap/Css.vue b/packages/playground/vue-sourcemap/Css.vue index 19668de8d33965..4f677c7b84dfbd 100644 --- a/packages/playground/vue-sourcemap/Css.vue +++ b/packages/playground/vue-sourcemap/Css.vue @@ -2,6 +2,7 @@

<css>

<css> module

<css> scoped

+

<css> scoped with nested

+ + diff --git a/packages/playground/vue-sourcemap/__tests__/serve.spec.ts b/packages/playground/vue-sourcemap/__tests__/serve.spec.ts index 08b4c04face111..7dfa271deea322 100644 --- a/packages/playground/vue-sourcemap/__tests__/serve.spec.ts +++ b/packages/playground/vue-sourcemap/__tests__/serve.spec.ts @@ -80,7 +80,7 @@ if (!isBuild) { const map = extractSourcemap(css) expect(formatSourcemapForSnapshot(map)).toMatchInlineSnapshot(` Object { - "mappings": ";AAOA;EACE,UAAU;AACZ", + "mappings": ";AAQA;EACE,UAAU;AACZ", "sources": Array [ "/root/Css.vue", ], @@ -89,6 +89,7 @@ if (!isBuild) {

<css>

<css> module

<css> scoped

+

<css> scoped with nested

+ + ", ], "version": 3, @@ -120,7 +131,7 @@ if (!isBuild) { const map = extractSourcemap(css) expect(formatSourcemapForSnapshot(map)).toMatchInlineSnapshot(` Object { - "mappings": ";AAaA;EACE,UAAU;AACZ", + "mappings": ";AAcA;EACE,UAAU;AACZ", "sources": Array [ "/root/Css.vue", ], @@ -129,6 +140,7 @@ if (!isBuild) {

<css>

<css> module

<css> scoped

+

<css> scoped with nested

+ + ", ], "version": 3, @@ -160,7 +182,7 @@ if (!isBuild) { const map = extractSourcemap(css) expect(formatSourcemapForSnapshot(map)).toMatchInlineSnapshot(` Object { - "mappings": ";AAmBA;EACE,UAAU;AACZ", + "mappings": ";AAoBA;EACE,UAAU;AACZ", "sources": Array [ "/root/Css.vue", ], @@ -169,6 +191,7 @@ if (!isBuild) {

<css>

<css> module

<css> scoped

+

<css> scoped with nested

+ + ", ], "version": 3, diff --git a/packages/playground/vue-sourcemap/package.json b/packages/playground/vue-sourcemap/package.json index 286940b01efa58..25bd2b725b7e65 100644 --- a/packages/playground/vue-sourcemap/package.json +++ b/packages/playground/vue-sourcemap/package.json @@ -11,7 +11,8 @@ "devDependencies": { "@vitejs/plugin-vue": "workspace:*", "less": "^4.1.2", - "sass": "^1.43.4" + "sass": "^1.43.4", + "postcss-nested": "^5.0.6" }, "dependencies": { "vue": "^3.2.31" diff --git a/packages/playground/vue-sourcemap/postcss.config.js b/packages/playground/vue-sourcemap/postcss.config.js new file mode 100644 index 00000000000000..9ea26b495d91b5 --- /dev/null +++ b/packages/playground/vue-sourcemap/postcss.config.js @@ -0,0 +1,3 @@ +module.exports = { + plugins: [require('postcss-nested')] +} diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index cff7eaaf3e4c52..b3ea3338cecc04 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -877,32 +877,23 @@ export function formatPostcssSourceMap( ): ExistingRawSourceMap { const inputFileDir = path.dirname(file) - const sources: string[] = [] - const sourcesContent: string[] = [] - for (const [i, source] of rawMap.sources.entries()) { - // remove from sources, to prevent source map to be combined incorrectly - if (source === '') continue - + const sources = rawMap.sources.map((source) => { const cleanSource = cleanUrl(decodeURIComponent(source)) // postcss returns virtual files if (/^<.+>$/.test(cleanSource)) { - sources.push(`\0${cleanSource}`) - } else { - sources.push(normalizePath(path.resolve(inputFileDir, cleanSource))) + return `\0${cleanSource}` } - if (rawMap.sourcesContent) { - sourcesContent.push(rawMap.sourcesContent[i]) - } - } + return normalizePath(path.resolve(inputFileDir, cleanSource)) + }) return { file, mappings: rawMap.mappings, names: rawMap.names, sources, - sourcesContent, + sourcesContent: rawMap.sourcesContent, version: rawMap.version } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 73be476b1c911b..7c177126794187 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -730,6 +730,7 @@ importers: specifiers: '@vitejs/plugin-vue': workspace:* less: ^4.1.2 + postcss-nested: ^5.0.6 sass: ^1.43.4 vue: ^3.2.31 dependencies: @@ -737,6 +738,7 @@ importers: devDependencies: '@vitejs/plugin-vue': link:../../plugin-vue less: 4.1.2 + postcss-nested: 5.0.6 sass: 1.45.1 packages/playground/wasm: From 025eebf7e634e2fdc40fde02b5f82278d5ef05c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Mon, 2 May 2022 04:50:25 +0900 Subject: [PATCH 101/175] fix(css): dynamic import css in package fetches removed js (fixes #7955, #6823) (#7969) --- .../dynamic-import/__tests__/dynamic-import.spec.ts | 7 ++++++- packages/playground/dynamic-import/index.html | 1 + packages/playground/dynamic-import/nested/deps.js | 3 +++ packages/playground/dynamic-import/nested/index.js | 5 +++++ packages/playground/dynamic-import/package.json | 6 +++++- packages/playground/dynamic-import/pkg/index.js | 1 + packages/playground/dynamic-import/pkg/package.json | 7 +++++++ packages/playground/dynamic-import/pkg/pkg.css | 3 +++ packages/vite/src/node/plugins/importAnalysisBuild.ts | 5 ++++- pnpm-lock.yaml | 6 ++++++ 10 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 packages/playground/dynamic-import/nested/deps.js create mode 100644 packages/playground/dynamic-import/pkg/index.js create mode 100644 packages/playground/dynamic-import/pkg/package.json create mode 100644 packages/playground/dynamic-import/pkg/pkg.css diff --git a/packages/playground/dynamic-import/__tests__/dynamic-import.spec.ts b/packages/playground/dynamic-import/__tests__/dynamic-import.spec.ts index c7157ef4652ec6..4730b5e990a1c3 100644 --- a/packages/playground/dynamic-import/__tests__/dynamic-import.spec.ts +++ b/packages/playground/dynamic-import/__tests__/dynamic-import.spec.ts @@ -1,4 +1,4 @@ -import { isBuild, untilUpdated } from '../../testUtils' +import { getColor, isBuild, untilUpdated } from '../../testUtils' test('should load literal dynamic import', async () => { await page.click('.baz') @@ -59,3 +59,8 @@ test('should load dynamic import with css', async () => { true ) }) + +test('should load dynamic import with css in package', async () => { + await page.click('.pkg-css') + await untilUpdated(() => getColor('.pkg-css'), 'blue', true) +}) diff --git a/packages/playground/dynamic-import/index.html b/packages/playground/dynamic-import/index.html index c87ef2a17f48d5..8e18204a7e4296 100644 --- a/packages/playground/dynamic-import/index.html +++ b/packages/playground/dynamic-import/index.html @@ -8,6 +8,7 @@ +
diff --git a/packages/playground/dynamic-import/nested/deps.js b/packages/playground/dynamic-import/nested/deps.js new file mode 100644 index 00000000000000..88fd4787941fd0 --- /dev/null +++ b/packages/playground/dynamic-import/nested/deps.js @@ -0,0 +1,3 @@ +/* don't include dynamic import inside this file */ + +import 'pkg' diff --git a/packages/playground/dynamic-import/nested/index.js b/packages/playground/dynamic-import/nested/index.js index 5518c56a35a2cc..f84ec00380d604 100644 --- a/packages/playground/dynamic-import/nested/index.js +++ b/packages/playground/dynamic-import/nested/index.js @@ -70,6 +70,11 @@ document.querySelector('.css').addEventListener('click', async () => { text('.view', 'dynamic import css') }) +document.querySelector('.pkg-css').addEventListener('click', async () => { + await import('./deps') + text('.view', 'dynamic import css in package') +}) + function text(el, text) { document.querySelector(el).textContent = text } diff --git a/packages/playground/dynamic-import/package.json b/packages/playground/dynamic-import/package.json index a6b6d5f863f1b8..3aac1090af5be4 100644 --- a/packages/playground/dynamic-import/package.json +++ b/packages/playground/dynamic-import/package.json @@ -6,6 +6,10 @@ "dev": "vite", "build": "vite build", "debug": "node --inspect-brk ../../vite/bin/vite", - "preview": "vite preview" + "preview": "vite preview", + "postinstall": "ts-node ../../../scripts/patchFileDeps.ts" + }, + "dependencies": { + "pkg": "file:./pkg" } } diff --git a/packages/playground/dynamic-import/pkg/index.js b/packages/playground/dynamic-import/pkg/index.js new file mode 100644 index 00000000000000..20f705c0b4a8c9 --- /dev/null +++ b/packages/playground/dynamic-import/pkg/index.js @@ -0,0 +1 @@ +import('./pkg.css') diff --git a/packages/playground/dynamic-import/pkg/package.json b/packages/playground/dynamic-import/pkg/package.json new file mode 100644 index 00000000000000..1eab564572e245 --- /dev/null +++ b/packages/playground/dynamic-import/pkg/package.json @@ -0,0 +1,7 @@ +{ + "name": "pkg", + "type": "module", + "private": true, + "version": "1.0.0", + "main": "index.js" +} diff --git a/packages/playground/dynamic-import/pkg/pkg.css b/packages/playground/dynamic-import/pkg/pkg.css new file mode 100644 index 00000000000000..349d669b6829bf --- /dev/null +++ b/packages/playground/dynamic-import/pkg/pkg.css @@ -0,0 +1,3 @@ +.pkg-css { + color: blue; +} diff --git a/packages/vite/src/node/plugins/importAnalysisBuild.ts b/packages/vite/src/node/plugins/importAnalysisBuild.ts index ff315d008f57a5..7e684db2b4cc6b 100644 --- a/packages/vite/src/node/plugins/importAnalysisBuild.ts +++ b/packages/vite/src/node/plugins/importAnalysisBuild.ts @@ -24,6 +24,8 @@ export const preloadBaseMarker = `__VITE_PRELOAD_BASE__` const preloadHelperId = 'vite/preload-helper' const preloadMarkerWithQuote = `"${preloadMarker}"` as const +const dynamicImportPrefixRE = /import\s*\(/ + /** * Helper for preloading CSS and direct imports of async chunks in parallel to * the async chunk itself. @@ -118,7 +120,8 @@ export function buildImportAnalysisPlugin(config: ResolvedConfig): Plugin { async transform(source, importer) { if ( importer.includes('node_modules') && - !source.includes('import.meta.glob') + !source.includes('import.meta.glob') && + !dynamicImportPrefixRE.test(source) ) { return } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7c177126794187..43c9d6d049d250 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -185,6 +185,12 @@ importers: specifiers: {} packages/playground/dynamic-import: + specifiers: + pkg: file:./pkg + dependencies: + pkg: link:pkg + + packages/playground/dynamic-import/pkg: specifiers: {} packages/playground/env: From b877d30a05691bb6ea2da4e67b931a5a3d32809f Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 2 May 2022 09:35:14 +0200 Subject: [PATCH 102/175] chore(deps): update all non-major dependencies (#7949) --- package.json | 12 +- packages/plugin-legacy/package.json | 4 +- packages/plugin-react/package.json | 4 +- packages/plugin-vue-jsx/package.json | 2 +- packages/vite/package.json | 18 +- pnpm-lock.yaml | 606 ++++++++++++++++----------- 6 files changed, 381 insertions(+), 265 deletions(-) diff --git a/package.json b/package.json index 1bfa2c4e77619c..cf18c4ee36e894 100644 --- a/package.json +++ b/package.json @@ -34,24 +34,24 @@ "ci-docs": "run-s build-vite build-plugin-vue build-docs" }, "devDependencies": { - "@microsoft/api-extractor": "^7.22.2", + "@microsoft/api-extractor": "^7.23.0", "@types/fs-extra": "^9.0.13", "@types/jest": "^27.4.1", "@types/node": "^17.0.25", "@types/prompts": "^2.0.14", "@types/semver": "^7.3.9", - "@typescript-eslint/eslint-plugin": "^5.20.0", - "@typescript-eslint/parser": "^5.20.0", + "@typescript-eslint/eslint-plugin": "^5.21.0", + "@typescript-eslint/parser": "^5.21.0", "conventional-changelog-cli": "^2.2.2", "cross-env": "^7.0.3", "esbuild": "^0.14.27", - "eslint": "^8.13.0", + "eslint": "^8.14.0", "eslint-define-config": "^1.4.0", "eslint-plugin-node": "^11.1.0", "execa": "^5.1.1", "fs-extra": "^10.1.0", "jest": "^27.5.1", - "lint-staged": "^12.4.0", + "lint-staged": "^12.4.1", "minimist": "^1.2.6", "node-fetch": "^2.6.6", "npm-run-all": "^4.1.5", @@ -85,7 +85,7 @@ "eslint --ext .ts" ] }, - "packageManager": "pnpm@6.32.9", + "packageManager": "pnpm@6.32.11", "pnpm": { "overrides": { "vite": "workspace:*", diff --git a/packages/plugin-legacy/package.json b/packages/plugin-legacy/package.json index adc97e974f2d37..1ba92ee5fd8565 100644 --- a/packages/plugin-legacy/package.json +++ b/packages/plugin-legacy/package.json @@ -22,8 +22,8 @@ }, "homepage": "https://github.com/vitejs/vite/tree/main/packages/plugin-legacy#readme", "dependencies": { - "@babel/standalone": "^7.17.9", - "core-js": "^3.22.2", + "@babel/standalone": "^7.17.11", + "core-js": "^3.22.3", "magic-string": "^0.26.1", "regenerator-runtime": "^0.13.9", "systemjs": "^6.12.1" diff --git a/packages/plugin-react/package.json b/packages/plugin-react/package.json index 8c93db98aac027..5698472c9dc113 100644 --- a/packages/plugin-react/package.json +++ b/packages/plugin-react/package.json @@ -33,13 +33,13 @@ }, "homepage": "https://github.com/vitejs/vite/tree/main/packages/plugin-react#readme", "dependencies": { - "@babel/core": "^7.17.9", + "@babel/core": "^7.17.10", "@babel/plugin-transform-react-jsx": "^7.17.3", "@babel/plugin-transform-react-jsx-development": "^7.16.7", "@babel/plugin-transform-react-jsx-self": "^7.16.7", "@babel/plugin-transform-react-jsx-source": "^7.16.7", "@rollup/pluginutils": "^4.2.1", - "react-refresh": "^0.12.0", + "react-refresh": "^0.13.0", "resolve": "^1.22.0" } } diff --git a/packages/plugin-vue-jsx/package.json b/packages/plugin-vue-jsx/package.json index 487d207a0df24d..32f346f6ea0024 100644 --- a/packages/plugin-vue-jsx/package.json +++ b/packages/plugin-vue-jsx/package.json @@ -22,7 +22,7 @@ }, "homepage": "https://github.com/vitejs/vite/tree/main/packages/plugin-vue-jsx#readme", "dependencies": { - "@babel/core": "^7.17.9", + "@babel/core": "^7.17.10", "@babel/plugin-syntax-import-meta": "^7.10.4", "@babel/plugin-transform-typescript": "^7.16.8", "@rollup/pluginutils": "^4.2.1", diff --git a/packages/vite/package.json b/packages/vite/package.json index b2caecf4e228ca..39b95bbab97769 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -44,7 +44,7 @@ "//": "READ CONTRIBUTING.md to understand what to put under deps vs. devDeps!", "dependencies": { "esbuild": "^0.14.27", - "postcss": "^8.4.12", + "postcss": "^8.4.13", "resolve": "^1.22.0", "rollup": "^2.59.0" }, @@ -52,9 +52,9 @@ "fsevents": "~2.3.2" }, "devDependencies": { - "@ampproject/remapping": "^2.1.2", - "@babel/parser": "^7.17.9", - "@babel/types": "^7.17.0", + "@ampproject/remapping": "^2.2.0", + "@babel/parser": "^7.17.10", + "@babel/types": "^7.17.10", "@jridgewell/trace-mapping": "^0.3.9", "@rollup/plugin-alias": "^3.1.9", "@rollup/plugin-commonjs": "^21.1.0", @@ -72,12 +72,12 @@ "@types/micromatch": "^4.0.2", "@types/mime": "^2.0.3", "@types/node": "^17.0.25", - "@types/resolve": "^1.20.1", + "@types/resolve": "^1.20.2", "@types/sass": "~1.43.1", "@types/stylus": "^0.48.37", "@types/ws": "^8.5.3", "@vue/compiler-dom": "^3.2.33", - "acorn": "^8.7.0", + "acorn": "^8.7.1", "cac": "6.7.9", "chokidar": "^3.5.3", "connect": "^3.7.0", @@ -112,11 +112,11 @@ "source-map-js": "^1.0.2", "source-map-support": "^0.5.21", "strip-ansi": "^6.0.1", - "terser": "^5.12.1", + "terser": "^5.13.1", "tsconfck": "^1.2.2", - "tslib": "^2.3.1", + "tslib": "^2.4.0", "types": "link:./types", - "ws": "^8.5.0" + "ws": "^8.6.0" }, "peerDependencies": { "less": "*", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 43c9d6d049d250..57fa85d5aaacf7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -10,24 +10,24 @@ importers: .: specifiers: - '@microsoft/api-extractor': ^7.22.2 + '@microsoft/api-extractor': ^7.23.0 '@types/fs-extra': ^9.0.13 '@types/jest': ^27.4.1 '@types/node': ^17.0.25 '@types/prompts': ^2.0.14 '@types/semver': ^7.3.9 - '@typescript-eslint/eslint-plugin': ^5.20.0 - '@typescript-eslint/parser': ^5.20.0 + '@typescript-eslint/eslint-plugin': ^5.21.0 + '@typescript-eslint/parser': ^5.21.0 conventional-changelog-cli: ^2.2.2 cross-env: ^7.0.3 esbuild: ^0.14.27 - eslint: ^8.13.0 + eslint: ^8.14.0 eslint-define-config: ^1.4.0 eslint-plugin-node: ^11.1.0 execa: ^5.1.1 fs-extra: ^10.1.0 jest: ^27.5.1 - lint-staged: ^12.4.0 + lint-staged: ^12.4.1 minimist: ^1.2.6 node-fetch: ^2.6.6 npm-run-all: ^4.1.5 @@ -46,24 +46,24 @@ importers: vite: workspace:* vitepress: ^0.22.3 devDependencies: - '@microsoft/api-extractor': 7.22.2 + '@microsoft/api-extractor': 7.23.0 '@types/fs-extra': 9.0.13 '@types/jest': 27.4.1 '@types/node': 17.0.25 '@types/prompts': 2.0.14 '@types/semver': 7.3.9 - '@typescript-eslint/eslint-plugin': 5.20.0_0df7beb8e4d849cfe6bb8e844ccdebfd - '@typescript-eslint/parser': 5.20.0_eslint@8.13.0+typescript@4.5.4 + '@typescript-eslint/eslint-plugin': 5.21.0_85142f655c5c9420758b0f4908692036 + '@typescript-eslint/parser': 5.21.0_eslint@8.14.0+typescript@4.5.4 conventional-changelog-cli: 2.2.2 cross-env: 7.0.3 esbuild: 0.14.27 - eslint: 8.13.0 + eslint: 8.14.0 eslint-define-config: 1.4.0 - eslint-plugin-node: 11.1.0_eslint@8.13.0 + eslint-plugin-node: 11.1.0_eslint@8.14.0 execa: 5.1.1 fs-extra: 10.1.0 jest: 27.5.1_ts-node@10.4.0 - lint-staged: 12.4.0 + lint-staged: 12.4.1 minimist: 1.2.6 node-fetch: 2.6.6 npm-run-all: 4.1.5 @@ -758,36 +758,36 @@ importers: packages/plugin-legacy: specifiers: - '@babel/standalone': ^7.17.9 - core-js: ^3.22.2 + '@babel/standalone': ^7.17.11 + core-js: ^3.22.3 magic-string: ^0.26.1 regenerator-runtime: ^0.13.9 systemjs: ^6.12.1 dependencies: - '@babel/standalone': 7.17.9 - core-js: 3.22.2 + '@babel/standalone': 7.17.11 + core-js: 3.22.3 magic-string: 0.26.1 regenerator-runtime: 0.13.9 systemjs: 6.12.1 packages/plugin-react: specifiers: - '@babel/core': ^7.17.9 + '@babel/core': ^7.17.10 '@babel/plugin-transform-react-jsx': ^7.17.3 '@babel/plugin-transform-react-jsx-development': ^7.16.7 '@babel/plugin-transform-react-jsx-self': ^7.16.7 '@babel/plugin-transform-react-jsx-source': ^7.16.7 '@rollup/pluginutils': ^4.2.1 - react-refresh: ^0.12.0 + react-refresh: ^0.13.0 resolve: ^1.22.0 dependencies: - '@babel/core': 7.17.9 - '@babel/plugin-transform-react-jsx': 7.17.3_@babel+core@7.17.9 - '@babel/plugin-transform-react-jsx-development': 7.16.7_@babel+core@7.17.9 - '@babel/plugin-transform-react-jsx-self': 7.16.7_@babel+core@7.17.9 - '@babel/plugin-transform-react-jsx-source': 7.16.7_@babel+core@7.17.9 + '@babel/core': 7.17.10 + '@babel/plugin-transform-react-jsx': 7.17.3_@babel+core@7.17.10 + '@babel/plugin-transform-react-jsx-development': 7.16.7_@babel+core@7.17.10 + '@babel/plugin-transform-react-jsx-self': 7.16.7_@babel+core@7.17.10 + '@babel/plugin-transform-react-jsx-source': 7.16.7_@babel+core@7.17.10 '@rollup/pluginutils': 4.2.1 - react-refresh: 0.12.0 + react-refresh: 0.13.0 resolve: 1.22.0 packages/plugin-vue: @@ -812,25 +812,25 @@ importers: packages/plugin-vue-jsx: specifiers: - '@babel/core': ^7.17.9 + '@babel/core': ^7.17.10 '@babel/plugin-syntax-import-meta': ^7.10.4 '@babel/plugin-transform-typescript': ^7.16.8 '@rollup/pluginutils': ^4.2.1 '@vue/babel-plugin-jsx': ^1.1.1 hash-sum: ^2.0.0 dependencies: - '@babel/core': 7.17.9 - '@babel/plugin-syntax-import-meta': 7.10.4_@babel+core@7.17.9 - '@babel/plugin-transform-typescript': 7.16.8_@babel+core@7.17.9 + '@babel/core': 7.17.10 + '@babel/plugin-syntax-import-meta': 7.10.4_@babel+core@7.17.10 + '@babel/plugin-transform-typescript': 7.16.8_@babel+core@7.17.10 '@rollup/pluginutils': 4.2.1 - '@vue/babel-plugin-jsx': 1.1.1_@babel+core@7.17.9 + '@vue/babel-plugin-jsx': 1.1.1_@babel+core@7.17.10 hash-sum: 2.0.0 packages/vite: specifiers: - '@ampproject/remapping': ^2.1.2 - '@babel/parser': ^7.17.9 - '@babel/types': ^7.17.0 + '@ampproject/remapping': ^2.2.0 + '@babel/parser': ^7.17.10 + '@babel/types': ^7.17.10 '@jridgewell/trace-mapping': ^0.3.9 '@rollup/plugin-alias': ^3.1.9 '@rollup/plugin-commonjs': ^21.1.0 @@ -848,12 +848,12 @@ importers: '@types/micromatch': ^4.0.2 '@types/mime': ^2.0.3 '@types/node': ^17.0.25 - '@types/resolve': ^1.20.1 + '@types/resolve': ^1.20.2 '@types/sass': ~1.43.1 '@types/stylus': ^0.48.37 '@types/ws': ^8.5.3 '@vue/compiler-dom': ^3.2.33 - acorn: ^8.7.0 + acorn: ^8.7.1 cac: 6.7.9 chokidar: ^3.5.3 connect: ^3.7.0 @@ -881,7 +881,7 @@ importers: open: ^8.4.0 periscopic: ^2.0.3 picocolors: ^1.0.0 - postcss: ^8.4.12 + postcss: ^8.4.13 postcss-import: ^14.1.0 postcss-load-config: ^3.1.4 postcss-modules: ^4.3.1 @@ -893,29 +893,29 @@ importers: source-map-js: ^1.0.2 source-map-support: ^0.5.21 strip-ansi: ^6.0.1 - terser: ^5.12.1 + terser: ^5.13.1 tsconfck: ^1.2.2 - tslib: ^2.3.1 + tslib: ^2.4.0 types: link:./types - ws: ^8.5.0 + ws: ^8.6.0 dependencies: esbuild: 0.14.27 - postcss: 8.4.12 + postcss: 8.4.13 resolve: 1.22.0 rollup: 2.62.0 optionalDependencies: fsevents: 2.3.2 devDependencies: - '@ampproject/remapping': 2.1.2 - '@babel/parser': 7.17.9 - '@babel/types': 7.17.0 + '@ampproject/remapping': 2.2.0 + '@babel/parser': 7.17.10 + '@babel/types': 7.17.10 '@jridgewell/trace-mapping': 0.3.9 '@rollup/plugin-alias': 3.1.9_rollup@2.62.0 '@rollup/plugin-commonjs': 21.1.0_rollup@2.62.0 '@rollup/plugin-dynamic-import-vars': 1.4.3_rollup@2.62.0 '@rollup/plugin-json': 4.1.0_rollup@2.62.0 '@rollup/plugin-node-resolve': 13.2.1_rollup@2.62.0 - '@rollup/plugin-typescript': 8.3.2_7c5ff569c0887b4f0035eb7cb6988163 + '@rollup/plugin-typescript': 8.3.2_83df2083f1d8ae39f870809a13a7071e '@rollup/pluginutils': 4.2.1 '@types/convert-source-map': 1.5.2 '@types/cross-spawn': 6.0.2 @@ -926,12 +926,12 @@ importers: '@types/micromatch': 4.0.2 '@types/mime': 2.0.3 '@types/node': 17.0.25 - '@types/resolve': 1.20.1 + '@types/resolve': 1.20.2 '@types/sass': 1.43.1 '@types/stylus': 0.48.37 '@types/ws': 8.5.3 '@vue/compiler-dom': 3.2.33 - acorn: 8.7.0 + acorn: 8.7.1 cac: 6.7.9 chokidar: 3.5.3 connect: 3.7.0 @@ -957,20 +957,20 @@ importers: open: 8.4.0 periscopic: 2.0.3 picocolors: 1.0.0 - postcss-import: 14.1.0_postcss@8.4.12 - postcss-load-config: 3.1.4_postcss@8.4.12+ts-node@10.4.0 - postcss-modules: 4.3.1_postcss@8.4.12 + postcss-import: 14.1.0_postcss@8.4.13 + postcss-load-config: 3.1.4_postcss@8.4.13+ts-node@10.4.0 + postcss-modules: 4.3.1_postcss@8.4.13 resolve.exports: 1.1.0 rollup-plugin-license: 2.7.0_rollup@2.62.0 sirv: 2.0.2 source-map-js: 1.0.2 source-map-support: 0.5.21 strip-ansi: 6.0.1 - terser: 5.12.1 + terser: 5.13.1 tsconfck: 1.2.2_typescript@4.5.4 - tslib: 2.3.1 + tslib: 2.4.0 types: link:types - ws: 8.5.0 + ws: 8.6.0 packages: @@ -1096,6 +1096,15 @@ packages: engines: {node: '>=6.0.0'} dependencies: '@jridgewell/trace-mapping': 0.3.9 + dev: false + + /@ampproject/remapping/2.2.0: + resolution: {integrity: sha512-qRmjj8nj9qmLTQXXmaR1cck3UXSRMPrbsLJAasZpF+t3riI71BXed5ebIOYwQntykeZuhjsdweEc9BxH5Jc26w==} + engines: {node: '>=6.0.0'} + dependencies: + '@jridgewell/gen-mapping': 0.1.1 + '@jridgewell/trace-mapping': 0.3.9 + dev: true /@babel/code-frame/7.16.0: resolution: {integrity: sha512-IF4EOMEV+bfYwOmNxGzSnjR2EmQod7f1UXOpZM3l4i4o4QNwzjtJAu/HxdjHq0aYBvdqMuQEY1eg0nqW9ZPORA==} @@ -1114,25 +1123,25 @@ packages: engines: {node: '>=6.9.0'} dev: true - /@babel/compat-data/7.17.7: - resolution: {integrity: sha512-p8pdE6j0a29TNGebNm7NzYZWB3xVZJBZ7XGs42uAKzQo8VQ3F0By/cQCtUEABwIqw5zo6WA4NbmxsfzADzMKnQ==} + /@babel/compat-data/7.17.10: + resolution: {integrity: sha512-GZt/TCsG70Ms19gfZO1tM4CVnXsPgEPBCpJu+Qz3L0LUDsY5nZqFZglIoPC1kIYOtNBZlrnFT+klg12vFGZXrw==} engines: {node: '>=6.9.0'} dev: false - /@babel/core/7.17.2: - resolution: {integrity: sha512-R3VH5G42VSDolRHyUO4V2cfag8WHcZyxdq5Z/m8Xyb92lW/Erm/6kM+XtRFGf3Mulre3mveni2NHfEUws8wSvw==} + /@babel/core/7.17.10: + resolution: {integrity: sha512-liKoppandF3ZcBnIYFjfSDHZLKdLHGJRkoWtG8zQyGJBQfIYobpnVGI5+pLBNtS6psFLDzyq8+h5HiVljW9PNA==} engines: {node: '>=6.9.0'} dependencies: - '@ampproject/remapping': 2.1.0 + '@ampproject/remapping': 2.1.2 '@babel/code-frame': 7.16.7 - '@babel/generator': 7.17.0 - '@babel/helper-compilation-targets': 7.16.7_@babel+core@7.17.2 - '@babel/helper-module-transforms': 7.16.7 - '@babel/helpers': 7.17.2 - '@babel/parser': 7.17.0 + '@babel/generator': 7.17.10 + '@babel/helper-compilation-targets': 7.17.10_@babel+core@7.17.10 + '@babel/helper-module-transforms': 7.17.7 + '@babel/helpers': 7.17.9 + '@babel/parser': 7.17.10 '@babel/template': 7.16.7 - '@babel/traverse': 7.17.0 - '@babel/types': 7.17.0 + '@babel/traverse': 7.17.10 + '@babel/types': 7.17.10 convert-source-map: 1.8.0 debug: 4.3.4 gensync: 1.0.0-beta.2 @@ -1140,21 +1149,21 @@ packages: semver: 6.3.0 transitivePeerDependencies: - supports-color - dev: true + dev: false - /@babel/core/7.17.9: - resolution: {integrity: sha512-5ug+SfZCpDAkVp9SFIZAzlW18rlzsOcJGaetCjkySnrXXDUw9AR8cDUm1iByTmdWM6yxX6/zycaV76w3YTF2gw==} + /@babel/core/7.17.2: + resolution: {integrity: sha512-R3VH5G42VSDolRHyUO4V2cfag8WHcZyxdq5Z/m8Xyb92lW/Erm/6kM+XtRFGf3Mulre3mveni2NHfEUws8wSvw==} engines: {node: '>=6.9.0'} dependencies: - '@ampproject/remapping': 2.1.2 + '@ampproject/remapping': 2.1.0 '@babel/code-frame': 7.16.7 - '@babel/generator': 7.17.9 - '@babel/helper-compilation-targets': 7.17.7_@babel+core@7.17.9 - '@babel/helper-module-transforms': 7.17.7 - '@babel/helpers': 7.17.9 - '@babel/parser': 7.17.9 + '@babel/generator': 7.17.0 + '@babel/helper-compilation-targets': 7.16.7_@babel+core@7.17.2 + '@babel/helper-module-transforms': 7.16.7 + '@babel/helpers': 7.17.2 + '@babel/parser': 7.17.0 '@babel/template': 7.16.7 - '@babel/traverse': 7.17.9 + '@babel/traverse': 7.17.0 '@babel/types': 7.17.0 convert-source-map: 1.8.0 debug: 4.3.4 @@ -1163,7 +1172,7 @@ packages: semver: 6.3.0 transitivePeerDependencies: - supports-color - dev: false + dev: true /@babel/generator/7.16.5: resolution: {integrity: sha512-kIvCdjZqcdKqoDbVVdt5R99icaRtrtYhYK/xux5qiWCBmfdvEYMFZ68QCrpE5cbFM1JsuArUNs1ZkuKtTtUcZA==} @@ -1192,13 +1201,13 @@ packages: source-map: 0.5.7 dev: true - /@babel/generator/7.17.9: - resolution: {integrity: sha512-rAdDousTwxbIxbz5I7GEQ3lUip+xVCXooZNbsydCWs3xA7ZsYOv+CFRdzGxRX78BmQHu9B1Eso59AOZQOJDEdQ==} + /@babel/generator/7.17.10: + resolution: {integrity: sha512-46MJZZo9y3o4kmhBVc7zW7i8dtR1oIK/sdO5NcfcZRhTGYi+KKJRtHNgsU6c4VUcJmUNV/LQdebD/9Dlv4K+Tg==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.17.0 + '@babel/types': 7.17.10 + '@jridgewell/gen-mapping': 0.1.1 jsesc: 2.5.2 - source-map: 0.5.7 dev: false /@babel/helper-annotate-as-pure/7.16.7: @@ -1221,26 +1230,26 @@ packages: semver: 6.3.0 dev: true - /@babel/helper-compilation-targets/7.17.7_@babel+core@7.17.9: - resolution: {integrity: sha512-UFzlz2jjd8kroj0hmCFV5zr+tQPi1dpC2cRsDV/3IEW8bJfCPrPpmcSN6ZS8RqIq4LXcmpipCQFPddyFA5Yc7w==} + /@babel/helper-compilation-targets/7.17.10_@babel+core@7.17.10: + resolution: {integrity: sha512-gh3RxjWbauw/dFiU/7whjd0qN9K6nPJMqe6+Er7rOavFh0CQUSwhAE3IcTho2rywPJFxej6TUUHDkWcYI6gGqQ==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0 dependencies: - '@babel/compat-data': 7.17.7 - '@babel/core': 7.17.9 + '@babel/compat-data': 7.17.10 + '@babel/core': 7.17.10 '@babel/helper-validator-option': 7.16.7 - browserslist: 4.19.1 + browserslist: 4.20.3 semver: 6.3.0 dev: false - /@babel/helper-create-class-features-plugin/7.16.10_@babel+core@7.17.9: + /@babel/helper-create-class-features-plugin/7.16.10_@babel+core@7.17.10: resolution: {integrity: sha512-wDeej0pu3WN/ffTxMNCPW5UCiOav8IcLRxSIyp/9+IF2xJUM9h/OYjg0IJLHaL6F8oU8kqMz9nc1vryXhMsgXg==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0 dependencies: - '@babel/core': 7.17.9 + '@babel/core': 7.17.10 '@babel/helper-annotate-as-pure': 7.16.7 '@babel/helper-environment-visitor': 7.16.7 '@babel/helper-function-name': 7.16.7 @@ -1256,7 +1265,7 @@ packages: resolution: {integrity: sha512-SLLb0AAn6PkUeAfKJCCOl9e1R53pQlGAfc4y4XuMRZfqeMYLE0dM1LMhqbGAlGQY0lfw5/ohoYWAe9V1yibRag==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.17.0 + '@babel/types': 7.17.10 /@babel/helper-function-name/7.16.7: resolution: {integrity: sha512-QfDfEnIUyyBSR3HtrtGECuZ6DAyCkYFp7GHl75vFtTnn6pjKeK0T1DB5lLkFvBea8MdaiUABx3osbgLyInoejA==} @@ -1271,7 +1280,7 @@ packages: engines: {node: '>=6.9.0'} dependencies: '@babel/template': 7.16.7 - '@babel/types': 7.17.0 + '@babel/types': 7.17.10 dev: false /@babel/helper-get-function-arity/7.16.7: @@ -1291,7 +1300,7 @@ packages: resolution: {integrity: sha512-m04d/0Op34H5v7pbZw6pSKP7weA6lsMvfiIAMeIvkY/R4xQtBSMFEigu9QTZ2qB/9l22vsxtM8a+Q8CzD255fg==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.17.0 + '@babel/types': 7.17.10 /@babel/helper-member-expression-to-functions/7.16.7: resolution: {integrity: sha512-VtJ/65tYiU/6AbMTDwyoXGPKHgTsfRarivm+YbB5uAzKUyuPjgZSgAFeG87FCigc7KNHu2Pegh1XIT3lXjvz3Q==} @@ -1338,8 +1347,8 @@ packages: '@babel/helper-split-export-declaration': 7.16.7 '@babel/helper-validator-identifier': 7.16.7 '@babel/template': 7.16.7 - '@babel/traverse': 7.17.9 - '@babel/types': 7.17.0 + '@babel/traverse': 7.17.10 + '@babel/types': 7.17.10 transitivePeerDependencies: - supports-color dev: false @@ -1383,14 +1392,14 @@ packages: resolution: {integrity: sha512-txyMCGroZ96i+Pxr3Je3lzEJjqwaRC9buMUgtomcrLe5Nd0+fk1h0LLA+ixUF5OW7AhHuQ7Es1WcQJZmZsz2XA==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.17.0 + '@babel/types': 7.17.10 dev: false /@babel/helper-split-export-declaration/7.16.7: resolution: {integrity: sha512-xbWoy/PFoxSWazIToT9Sif+jJTlrMcndIsaOKvTA6u7QEo7ilkRZpjew18/W3c7nm8fXdUDXh02VXTbZ0pGDNw==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.17.0 + '@babel/types': 7.17.10 /@babel/helper-validator-identifier/7.15.7: resolution: {integrity: sha512-K4JvCtQqad9OY2+yTU8w+E82ywk/fe+ELNlt1G8z3bVGlZfn/hOcQQsUhGhW/N+tb3fxK800wLtKOE/aM0m72w==} @@ -1420,8 +1429,8 @@ packages: engines: {node: '>=6.9.0'} dependencies: '@babel/template': 7.16.7 - '@babel/traverse': 7.17.9 - '@babel/types': 7.17.0 + '@babel/traverse': 7.17.10 + '@babel/types': 7.17.10 transitivePeerDependencies: - supports-color dev: false @@ -1459,6 +1468,11 @@ packages: hasBin: true dev: true + /@babel/parser/7.17.10: + resolution: {integrity: sha512-n2Q6i+fnJqzOaq2VkdXxy2TCPCWQZHiCo0XqmrCvDWcZQKRyZzYi4Z0yxlBuN0w+r2ZHmre+Q087DSrw3pbJDQ==} + engines: {node: '>=6.0.0'} + hasBin: true + /@babel/parser/7.17.8: resolution: {integrity: sha512-BoHhDJrJXqcg+ZL16Xv39H9n+AqJ4pcDrQBGZN+wHxIysrLZ3/ECwCBUch/1zUNhnsXULcONU3Ei5Hmkfk6kiQ==} engines: {node: '>=6.0.0'} @@ -1506,23 +1520,23 @@ packages: '@babel/helper-plugin-utils': 7.16.7 dev: true - /@babel/plugin-syntax-import-meta/7.10.4_@babel+core@7.17.2: + /@babel/plugin-syntax-import-meta/7.10.4_@babel+core@7.17.10: resolution: {integrity: sha512-Yqfm+XDx0+Prh3VSeEQCPU81yC+JWZ2pDPFSS4ZdpfZhp4MkFMaDC1UqseovEKwSUpnIL7+vK+Clp7bfh0iD7g==} peerDependencies: '@babel/core': ^7.0.0-0 dependencies: - '@babel/core': 7.17.2 + '@babel/core': 7.17.10 '@babel/helper-plugin-utils': 7.16.5 - dev: true + dev: false - /@babel/plugin-syntax-import-meta/7.10.4_@babel+core@7.17.9: + /@babel/plugin-syntax-import-meta/7.10.4_@babel+core@7.17.2: resolution: {integrity: sha512-Yqfm+XDx0+Prh3VSeEQCPU81yC+JWZ2pDPFSS4ZdpfZhp4MkFMaDC1UqseovEKwSUpnIL7+vK+Clp7bfh0iD7g==} peerDependencies: '@babel/core': ^7.0.0-0 dependencies: - '@babel/core': 7.17.9 + '@babel/core': 7.17.2 '@babel/helper-plugin-utils': 7.16.5 - dev: false + dev: true /@babel/plugin-syntax-json-strings/7.8.3_@babel+core@7.17.2: resolution: {integrity: sha512-lY6kdGpWHvjoe2vk4WrAapEuBR69EMxZl+RoGRhrFGNYVK8mOPAW8VfbT/ZgrFbXlDNiiaxQnAtgVCZ6jv30EA==} @@ -1542,23 +1556,23 @@ packages: '@babel/helper-plugin-utils': 7.16.7 dev: true - /@babel/plugin-syntax-jsx/7.16.5_@babel+core@7.17.9: + /@babel/plugin-syntax-jsx/7.16.5_@babel+core@7.17.10: resolution: {integrity: sha512-42OGssv9NPk4QHKVgIHlzeLgPOW5rGgfV5jzG90AhcXXIv6hu/eqj63w4VgvRxdvZY3AlYeDgPiSJ3BqAd1Y6Q==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0-0 dependencies: - '@babel/core': 7.17.9 + '@babel/core': 7.17.10 '@babel/helper-plugin-utils': 7.16.7 dev: false - /@babel/plugin-syntax-jsx/7.16.7_@babel+core@7.17.9: + /@babel/plugin-syntax-jsx/7.16.7_@babel+core@7.17.10: resolution: {integrity: sha512-Esxmk7YjA8QysKeT3VhTXvF6y77f/a91SIs4pWb4H2eWGQkCKFgQaG6hdoEVZtGsrAcb2K5BW66XsOErD4WU3Q==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0-0 dependencies: - '@babel/core': 7.17.9 + '@babel/core': 7.17.10 '@babel/helper-plugin-utils': 7.16.7 dev: false @@ -1635,80 +1649,80 @@ packages: '@babel/helper-plugin-utils': 7.16.7 dev: true - /@babel/plugin-syntax-typescript/7.16.7_@babel+core@7.17.2: + /@babel/plugin-syntax-typescript/7.16.7_@babel+core@7.17.10: resolution: {integrity: sha512-YhUIJHHGkqPgEcMYkPCKTyGUdoGKWtopIycQyjJH8OjvRgOYsXsaKehLVPScKJWAULPxMa4N1vCe6szREFlZ7A==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0-0 dependencies: - '@babel/core': 7.17.2 + '@babel/core': 7.17.10 '@babel/helper-plugin-utils': 7.16.7 - dev: true + dev: false - /@babel/plugin-syntax-typescript/7.16.7_@babel+core@7.17.9: + /@babel/plugin-syntax-typescript/7.16.7_@babel+core@7.17.2: resolution: {integrity: sha512-YhUIJHHGkqPgEcMYkPCKTyGUdoGKWtopIycQyjJH8OjvRgOYsXsaKehLVPScKJWAULPxMa4N1vCe6szREFlZ7A==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0-0 dependencies: - '@babel/core': 7.17.9 + '@babel/core': 7.17.2 '@babel/helper-plugin-utils': 7.16.7 - dev: false + dev: true - /@babel/plugin-transform-react-jsx-development/7.16.7_@babel+core@7.17.9: + /@babel/plugin-transform-react-jsx-development/7.16.7_@babel+core@7.17.10: resolution: {integrity: sha512-RMvQWvpla+xy6MlBpPlrKZCMRs2AGiHOGHY3xRwl0pEeim348dDyxeH4xBsMPbIMhujeq7ihE702eM2Ew0Wo+A==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0-0 dependencies: - '@babel/core': 7.17.9 - '@babel/plugin-transform-react-jsx': 7.17.3_@babel+core@7.17.9 + '@babel/core': 7.17.10 + '@babel/plugin-transform-react-jsx': 7.17.3_@babel+core@7.17.10 dev: false - /@babel/plugin-transform-react-jsx-self/7.16.7_@babel+core@7.17.9: + /@babel/plugin-transform-react-jsx-self/7.16.7_@babel+core@7.17.10: resolution: {integrity: sha512-oe5VuWs7J9ilH3BCCApGoYjHoSO48vkjX2CbA5bFVhIuO2HKxA3vyF7rleA4o6/4rTDbk6r8hBW7Ul8E+UZrpA==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0-0 dependencies: - '@babel/core': 7.17.9 + '@babel/core': 7.17.10 '@babel/helper-plugin-utils': 7.16.7 dev: false - /@babel/plugin-transform-react-jsx-source/7.16.7_@babel+core@7.17.9: + /@babel/plugin-transform-react-jsx-source/7.16.7_@babel+core@7.17.10: resolution: {integrity: sha512-rONFiQz9vgbsnaMtQlZCjIRwhJvlrPET8TabIUK2hzlXw9B9s2Ieaxte1SCOOXMbWRHodbKixNf3BLcWVOQ8Bw==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0-0 dependencies: - '@babel/core': 7.17.9 + '@babel/core': 7.17.10 '@babel/helper-plugin-utils': 7.16.7 dev: false - /@babel/plugin-transform-react-jsx/7.17.3_@babel+core@7.17.9: + /@babel/plugin-transform-react-jsx/7.17.3_@babel+core@7.17.10: resolution: {integrity: sha512-9tjBm4O07f7mzKSIlEmPdiE6ub7kfIe6Cd+w+oQebpATfTQMAgW+YOuWxogbKVTulA+MEO7byMeIUtQ1z+z+ZQ==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0-0 dependencies: - '@babel/core': 7.17.9 + '@babel/core': 7.17.10 '@babel/helper-annotate-as-pure': 7.16.7 '@babel/helper-module-imports': 7.16.7 '@babel/helper-plugin-utils': 7.16.7 - '@babel/plugin-syntax-jsx': 7.16.7_@babel+core@7.17.9 + '@babel/plugin-syntax-jsx': 7.16.7_@babel+core@7.17.10 '@babel/types': 7.17.0 dev: false - /@babel/plugin-transform-typescript/7.16.8_@babel+core@7.17.9: + /@babel/plugin-transform-typescript/7.16.8_@babel+core@7.17.10: resolution: {integrity: sha512-bHdQ9k7YpBDO2d0NVfkj51DpQcvwIzIusJ7mEUaMlbZq3Kt/U47j24inXZHQ5MDiYpCs+oZiwnXyKedE8+q7AQ==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0-0 dependencies: - '@babel/core': 7.17.9 - '@babel/helper-create-class-features-plugin': 7.16.10_@babel+core@7.17.9 + '@babel/core': 7.17.10 + '@babel/helper-create-class-features-plugin': 7.16.10_@babel+core@7.17.10 '@babel/helper-plugin-utils': 7.16.7 - '@babel/plugin-syntax-typescript': 7.16.7_@babel+core@7.17.9 + '@babel/plugin-syntax-typescript': 7.16.7_@babel+core@7.17.10 transitivePeerDependencies: - supports-color dev: false @@ -1719,8 +1733,8 @@ packages: dependencies: regenerator-runtime: 0.13.9 - /@babel/standalone/7.17.9: - resolution: {integrity: sha512-9wL9AtDlga8avxUrBvQJmhUtJWrelsUL0uV+TcP+49Sb6Pj8/bNIzQzU4dDp0NAPOvnZR/7msFIKsKoCl/W1/w==} + /@babel/standalone/7.17.11: + resolution: {integrity: sha512-47wVYBeTktYHwtzlFuK7qqV/H5X6mU4MUNqpQ9iiJOqnP8rWL0eX0GWLKRsv8D8suYzhuS1K/dtwgGr+26U7Gg==} engines: {node: '>=6.9.0'} dev: false @@ -1738,8 +1752,8 @@ packages: engines: {node: '>=6.9.0'} dependencies: '@babel/code-frame': 7.16.7 - '@babel/parser': 7.17.8 - '@babel/types': 7.17.0 + '@babel/parser': 7.17.10 + '@babel/types': 7.17.10 /@babel/traverse/7.16.10: resolution: {integrity: sha512-yzuaYXoRJBGMlBhsMJoUW7G1UmSb/eXr/JHYM/MsOJgavJibLwASijW7oXBdw3NQ6T0bW7Ty5P/VarOs9cHmqw==} @@ -1795,18 +1809,18 @@ packages: - supports-color dev: true - /@babel/traverse/7.17.9: - resolution: {integrity: sha512-PQO8sDIJ8SIwipTPiR71kJQCKQYB5NGImbOviK8K+kg5xkNSYXLBupuX9QhatFowrsvo9Hj8WgArg3W7ijNAQw==} + /@babel/traverse/7.17.10: + resolution: {integrity: sha512-VmbrTHQteIdUUQNTb+zE12SHS/xQVIShmBPhlNP12hD5poF2pbITW1Z4172d03HegaQWhLffdkRJYtAzp0AGcw==} engines: {node: '>=6.9.0'} dependencies: '@babel/code-frame': 7.16.7 - '@babel/generator': 7.17.9 + '@babel/generator': 7.17.10 '@babel/helper-environment-visitor': 7.16.7 '@babel/helper-function-name': 7.17.9 '@babel/helper-hoist-variables': 7.16.7 '@babel/helper-split-export-declaration': 7.16.7 - '@babel/parser': 7.17.9 - '@babel/types': 7.17.0 + '@babel/parser': 7.17.10 + '@babel/types': 7.17.10 debug: 4.3.4 globals: 11.12.0 transitivePeerDependencies: @@ -1834,6 +1848,13 @@ packages: '@babel/helper-validator-identifier': 7.16.7 to-fast-properties: 2.0.0 + /@babel/types/7.17.10: + resolution: {integrity: sha512-9O26jG0mBYfGkUYCYZRnBwbVLd1UZOICEr2Em6InB6jVfsAv1GKgwXHmrSg+WFWDmeKTA6vyTZiN8tCSM5Oo3A==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/helper-validator-identifier': 7.16.7 + to-fast-properties: 2.0.0 + /@bcoe/v8-coverage/0.2.3: resolution: {integrity: sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==} dev: true @@ -1965,8 +1986,8 @@ packages: resolution: {integrity: sha512-6U71C2Wp7r5XtFtQzYrW5iKFT67OixrSxjI4MptCHzdSVlgabczzqLe0ZSgnub/5Kp4hSbpDB1tMytZY9pwxxA==} dev: false - /@eslint/eslintrc/1.2.1: - resolution: {integrity: sha512-bxvbYnBPN1Gibwyp6NrpnFzA3YtRL3BBAyEAFVIpNTm2Rn4Vy87GA5M4aSn3InRrlsbX5N0GW7XIx+U4SAEKdQ==} + /@eslint/eslintrc/1.2.2: + resolution: {integrity: sha512-lTVWHs7O2hjBFZunXTZYnYqtB9GakA1lnxIf+gKq2nY5gxkkNi/lQvveW6t8gFdOHTg6nG50Xs95PrLqVpcaLg==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dependencies: ajv: 6.12.6 @@ -2213,10 +2234,21 @@ packages: chalk: 4.1.2 dev: true + /@jridgewell/gen-mapping/0.1.1: + resolution: {integrity: sha512-sQXCasFk+U8lWYEe66WxRDOE9PjVz4vSM51fTu3Hw+ClTpUSQb718772vH3pyS5pShp6lvQM7SxgIDXXXmOX7w==} + engines: {node: '>=6.0.0'} + dependencies: + '@jridgewell/set-array': 1.1.0 + '@jridgewell/sourcemap-codec': 1.4.10 + /@jridgewell/resolve-uri/3.0.5: resolution: {integrity: sha512-VPeQ7+wH0itvQxnG+lIzWgkysKIr3L9sslimFW55rHMdGu/qCQ5z5h9zq4gI8uBtqkpHhsF4Z/OwExufUCThew==} engines: {node: '>=6.0.0'} + /@jridgewell/set-array/1.1.0: + resolution: {integrity: sha512-SfJxIxNVYLTsKwzB3MoOQ1yxf4w/E6MdkvTgrgAt1bfxjSrLUoHMKrDOykwN14q65waezZIdqDneUIPh4/sKxg==} + engines: {node: '>=6.0.0'} + /@jridgewell/sourcemap-codec/1.4.10: resolution: {integrity: sha512-Ht8wIW5v165atIX1p+JvKR5ONzUyF4Ac8DZIQ5kZs9zrb6M8SJNXpx1zn04rn65VjBMygRoMXcyYwNK0fT7bEg==} @@ -2250,30 +2282,30 @@ packages: - supports-color dev: false - /@microsoft/api-extractor-model/7.17.1: - resolution: {integrity: sha512-DCDtD8TdEpNk2lW4JvXgwwpxKy70P0JLad55iahwO8A+C63KYsrHIpAzo0FUauh5pwJ0v5QVNIJ+OBgKGteemg==} + /@microsoft/api-extractor-model/7.17.2: + resolution: {integrity: sha512-fYfCeBeLm7jnZligC64qHiH4/vzswFLDfyPpX+uKO36OI2kIeMHrYG0zaezmuinKvE4vg1dAz38zZeDbPvBKGg==} dependencies: '@microsoft/tsdoc': 0.14.1 '@microsoft/tsdoc-config': 0.16.1 - '@rushstack/node-core-library': 3.45.3 + '@rushstack/node-core-library': 3.45.4 dev: true - /@microsoft/api-extractor/7.22.2: - resolution: {integrity: sha512-G7vXz6UHz+qoaUGPf2k5Md4bSpHii9nFys3sIe3bmFUbmhAe+HfSB/dCn1PsLhW7tZfEXwMHTj7fbL5vcZkrEw==} + /@microsoft/api-extractor/7.23.0: + resolution: {integrity: sha512-fbdX05RVE1EMA7nvyRHuS9nx1pryhjgURDx6pQlE/9yOXQ5PO7MpYdfWGaRsQwyYuU3+tPxgro819c0R3AK6KA==} hasBin: true dependencies: - '@microsoft/api-extractor-model': 7.17.1 + '@microsoft/api-extractor-model': 7.17.2 '@microsoft/tsdoc': 0.14.1 '@microsoft/tsdoc-config': 0.16.1 - '@rushstack/node-core-library': 3.45.3 - '@rushstack/rig-package': 0.3.10 - '@rushstack/ts-command-line': 4.10.9 + '@rushstack/node-core-library': 3.45.4 + '@rushstack/rig-package': 0.3.11 + '@rushstack/ts-command-line': 4.10.10 colors: 1.2.5 lodash: 4.17.21 resolve: 1.17.0 semver: 7.3.7 source-map: 0.6.1 - typescript: 4.5.4 + typescript: 4.6.4 dev: true /@microsoft/tsdoc-config/0.16.1: @@ -2411,7 +2443,7 @@ packages: rollup: 2.62.0 dev: true - /@rollup/plugin-typescript/8.3.2_7c5ff569c0887b4f0035eb7cb6988163: + /@rollup/plugin-typescript/8.3.2_83df2083f1d8ae39f870809a13a7071e: resolution: {integrity: sha512-MtgyR5LNHZr3GyN0tM7gNO9D0CS+Y+vflS4v/PHmrX17JCkHUYKvQ5jN5o3cz1YKllM3duXUqu3yOHwMPUxhDg==} engines: {node: '>=8.0.0'} peerDependencies: @@ -2422,7 +2454,7 @@ packages: '@rollup/pluginutils': 3.1.0_rollup@2.62.0 resolve: 1.22.0 rollup: 2.62.0 - tslib: 2.3.1 + tslib: 2.4.0 typescript: 4.5.4 dev: true @@ -2445,8 +2477,8 @@ packages: estree-walker: 2.0.2 picomatch: 2.3.1 - /@rushstack/node-core-library/3.45.3: - resolution: {integrity: sha512-Rn0mxqC3MPb+YbvaeFcRWfcYHLwyZ99/ffYA8chpq5OpqoY+Mr1ycTbMvzl5AxWf1pYmi/2+Eo3iTOsQdYR8xw==} + /@rushstack/node-core-library/3.45.4: + resolution: {integrity: sha512-FMoEQWjK7nWAO2uFgV1eVpVhY9ZDGOdIIomi9zTej64cKJ+8/Nvu+ny0xKaUDEjw/ALftN2D2ml7L0RDpW/Z9g==} dependencies: '@types/node': 12.20.24 colors: 1.2.5 @@ -2459,15 +2491,15 @@ packages: z-schema: 5.0.2 dev: true - /@rushstack/rig-package/0.3.10: - resolution: {integrity: sha512-4Z2HhXM4YBWOi4ZYFQNK6Yxz641v+cvc8NKiaNZh+RIdNb3D4Rfpy3XUkggbCozpfDriBfL1+KaXlJtfJfAIXw==} + /@rushstack/rig-package/0.3.11: + resolution: {integrity: sha512-uI1/g5oQPtyrT9nStoyX/xgZSLa2b+srRFaDk3r1eqC7zA5th4/bvTGl2QfV3C9NcP+coSqmk5mFJkUfH6i3Lw==} dependencies: resolve: 1.17.0 strip-json-comments: 3.1.1 dev: true - /@rushstack/ts-command-line/4.10.9: - resolution: {integrity: sha512-TE3eZgHNVHOY3p8lp38FoNEJUr0+swPb24sCcYuwlC+MHgMGXyJNM+p7l3TKSBRiY01XShoL2k601oGwL00KlA==} + /@rushstack/ts-command-line/4.10.10: + resolution: {integrity: sha512-F+MH7InPDXqX40qvvcEsnvPpmg566SBpfFqj2fcCh8RjM6AyOoWlXc8zx7giBD3ZN85NVAEjZAgrcLU0z+R2yg==} dependencies: '@types/argparse': 1.0.38 argparse: 1.0.10 @@ -2679,8 +2711,8 @@ packages: '@types/node': 17.0.25 dev: true - /@types/resolve/1.20.1: - resolution: {integrity: sha512-Ku5+GPFa12S3W26Uwtw+xyrtIpaZsGYHH6zxNbZlstmlvMYSZRzOwzwsXbxlVUbHyUucctSyuFtu6bNxwYomIw==} + /@types/resolve/1.20.2: + resolution: {integrity: sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==} dev: true /@types/sass/1.43.1: @@ -2731,8 +2763,8 @@ packages: dev: true optional: true - /@typescript-eslint/eslint-plugin/5.20.0_0df7beb8e4d849cfe6bb8e844ccdebfd: - resolution: {integrity: sha512-fapGzoxilCn3sBtC6NtXZX6+P/Hef7VDbyfGqTTpzYydwhlkevB+0vE0EnmHPVTVSy68GUncyJ/2PcrFBeCo5Q==} + /@typescript-eslint/eslint-plugin/5.21.0_85142f655c5c9420758b0f4908692036: + resolution: {integrity: sha512-fTU85q8v5ZLpoZEyn/u1S2qrFOhi33Edo2CZ0+q1gDaWWm0JuPh3bgOyU8lM0edIEYgKLDkPFiZX2MOupgjlyg==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: '@typescript-eslint/parser': ^5.0.0 @@ -2742,12 +2774,12 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/parser': 5.20.0_eslint@8.13.0+typescript@4.5.4 - '@typescript-eslint/scope-manager': 5.20.0 - '@typescript-eslint/type-utils': 5.20.0_eslint@8.13.0+typescript@4.5.4 - '@typescript-eslint/utils': 5.20.0_eslint@8.13.0+typescript@4.5.4 + '@typescript-eslint/parser': 5.21.0_eslint@8.14.0+typescript@4.5.4 + '@typescript-eslint/scope-manager': 5.21.0 + '@typescript-eslint/type-utils': 5.21.0_eslint@8.14.0+typescript@4.5.4 + '@typescript-eslint/utils': 5.21.0_eslint@8.14.0+typescript@4.5.4 debug: 4.3.4 - eslint: 8.13.0 + eslint: 8.14.0 functional-red-black-tree: 1.0.1 ignore: 5.2.0 regexpp: 3.2.0 @@ -2758,8 +2790,8 @@ packages: - supports-color dev: true - /@typescript-eslint/parser/5.20.0_eslint@8.13.0+typescript@4.5.4: - resolution: {integrity: sha512-UWKibrCZQCYvobmu3/N8TWbEeo/EPQbS41Ux1F9XqPzGuV7pfg6n50ZrFo6hryynD8qOTTfLHtHjjdQtxJ0h/w==} + /@typescript-eslint/parser/5.21.0_eslint@8.14.0+typescript@4.5.4: + resolution: {integrity: sha512-8RUwTO77hstXUr3pZoWZbRQUxXcSXafZ8/5gpnQCfXvgmP9gpNlRGlWzvfbEQ14TLjmtU8eGnONkff8U2ui2Eg==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 @@ -2768,26 +2800,26 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/scope-manager': 5.20.0 - '@typescript-eslint/types': 5.20.0 - '@typescript-eslint/typescript-estree': 5.20.0_typescript@4.5.4 + '@typescript-eslint/scope-manager': 5.21.0 + '@typescript-eslint/types': 5.21.0 + '@typescript-eslint/typescript-estree': 5.21.0_typescript@4.5.4 debug: 4.3.4 - eslint: 8.13.0 + eslint: 8.14.0 typescript: 4.5.4 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/scope-manager/5.20.0: - resolution: {integrity: sha512-h9KtuPZ4D/JuX7rpp1iKg3zOH0WNEa+ZIXwpW/KWmEFDxlA/HSfCMhiyF1HS/drTICjIbpA6OqkAhrP/zkCStg==} + /@typescript-eslint/scope-manager/5.21.0: + resolution: {integrity: sha512-XTX0g0IhvzcH/e3393SvjRCfYQxgxtYzL3UREteUneo72EFlt7UNoiYnikUtmGVobTbhUDByhJ4xRBNe+34kOQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dependencies: - '@typescript-eslint/types': 5.20.0 - '@typescript-eslint/visitor-keys': 5.20.0 + '@typescript-eslint/types': 5.21.0 + '@typescript-eslint/visitor-keys': 5.21.0 dev: true - /@typescript-eslint/type-utils/5.20.0_eslint@8.13.0+typescript@4.5.4: - resolution: {integrity: sha512-WxNrCwYB3N/m8ceyoGCgbLmuZwupvzN0rE8NBuwnl7APgjv24ZJIjkNzoFBXPRCGzLNkoU/WfanW0exvp/+3Iw==} + /@typescript-eslint/type-utils/5.21.0_eslint@8.14.0+typescript@4.5.4: + resolution: {integrity: sha512-MxmLZj0tkGlkcZCSE17ORaHl8Th3JQwBzyXL/uvC6sNmu128LsgjTX0NIzy+wdH2J7Pd02GN8FaoudJntFvSOw==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: eslint: '*' @@ -2796,22 +2828,22 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/utils': 5.20.0_eslint@8.13.0+typescript@4.5.4 + '@typescript-eslint/utils': 5.21.0_eslint@8.14.0+typescript@4.5.4 debug: 4.3.4 - eslint: 8.13.0 + eslint: 8.14.0 tsutils: 3.21.0_typescript@4.5.4 typescript: 4.5.4 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/types/5.20.0: - resolution: {integrity: sha512-+d8wprF9GyvPwtoB4CxBAR/s0rpP25XKgnOvMf/gMXYDvlUC3rPFHupdTQ/ow9vn7UDe5rX02ovGYQbv/IUCbg==} + /@typescript-eslint/types/5.21.0: + resolution: {integrity: sha512-XnOOo5Wc2cBlq8Lh5WNvAgHzpjnEzxn4CJBwGkcau7b/tZ556qrWXQz4DJyChYg8JZAD06kczrdgFPpEQZfDsA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true - /@typescript-eslint/typescript-estree/5.20.0_typescript@4.5.4: - resolution: {integrity: sha512-36xLjP/+bXusLMrT9fMMYy1KJAGgHhlER2TqpUVDYUQg4w0q/NW/sg4UGAgVwAqb8V4zYg43KMUpM8vV2lve6w==} + /@typescript-eslint/typescript-estree/5.21.0_typescript@4.5.4: + resolution: {integrity: sha512-Y8Y2T2FNvm08qlcoSMoNchh9y2Uj3QmjtwNMdRQkcFG7Muz//wfJBGBxh8R7HAGQFpgYpdHqUpEoPQk+q9Kjfg==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: typescript: '*' @@ -2819,8 +2851,8 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/types': 5.20.0 - '@typescript-eslint/visitor-keys': 5.20.0 + '@typescript-eslint/types': 5.21.0 + '@typescript-eslint/visitor-keys': 5.21.0 debug: 4.3.4 globby: 11.0.4 is-glob: 4.0.3 @@ -2831,29 +2863,29 @@ packages: - supports-color dev: true - /@typescript-eslint/utils/5.20.0_eslint@8.13.0+typescript@4.5.4: - resolution: {integrity: sha512-lHONGJL1LIO12Ujyx8L8xKbwWSkoUKFSO+0wDAqGXiudWB2EO7WEUT+YZLtVbmOmSllAjLb9tpoIPwpRe5Tn6w==} + /@typescript-eslint/utils/5.21.0_eslint@8.14.0+typescript@4.5.4: + resolution: {integrity: sha512-q/emogbND9wry7zxy7VYri+7ydawo2HDZhRZ5k6yggIvXa7PvBbAAZ4PFH/oZLem72ezC4Pr63rJvDK/sTlL8Q==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 dependencies: '@types/json-schema': 7.0.9 - '@typescript-eslint/scope-manager': 5.20.0 - '@typescript-eslint/types': 5.20.0 - '@typescript-eslint/typescript-estree': 5.20.0_typescript@4.5.4 - eslint: 8.13.0 + '@typescript-eslint/scope-manager': 5.21.0 + '@typescript-eslint/types': 5.21.0 + '@typescript-eslint/typescript-estree': 5.21.0_typescript@4.5.4 + eslint: 8.14.0 eslint-scope: 5.1.1 - eslint-utils: 3.0.0_eslint@8.13.0 + eslint-utils: 3.0.0_eslint@8.14.0 transitivePeerDependencies: - supports-color - typescript dev: true - /@typescript-eslint/visitor-keys/5.20.0: - resolution: {integrity: sha512-1flRpNF+0CAQkMNlTJ6L/Z5jiODG/e5+7mk6XwtPOUS3UrTz3UOiAg9jG2VtKsWI6rZQfy4C6a232QNRZTRGlg==} + /@typescript-eslint/visitor-keys/5.21.0: + resolution: {integrity: sha512-SX8jNN+iHqAF0riZQMkm7e8+POXa/fXw5cxL+gjpyP+FI+JVNhii53EmQgDAfDcBpFekYSlO0fGytMQwRiMQCA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dependencies: - '@typescript-eslint/types': 5.20.0 + '@typescript-eslint/types': 5.21.0 eslint-visitor-keys: 3.3.0 dev: true @@ -2861,11 +2893,11 @@ packages: resolution: {integrity: sha512-hz4R8tS5jMn8lDq6iD+yWL6XNB699pGIVLk7WSJnn1dbpjaazsjZQkieJoRX6gW5zpYSCFqQ7jUquPNY65tQYA==} dev: false - /@vue/babel-plugin-jsx/1.1.1_@babel+core@7.17.9: + /@vue/babel-plugin-jsx/1.1.1_@babel+core@7.17.10: resolution: {integrity: sha512-j2uVfZjnB5+zkcbc/zsOc0fSNGCMMjaEXP52wdwdIfn0qjFfEYpYZBFKFg+HHnQeJCVrjOeO0YxgaL7DMrym9w==} dependencies: '@babel/helper-module-imports': 7.16.0 - '@babel/plugin-syntax-jsx': 7.16.5_@babel+core@7.17.9 + '@babel/plugin-syntax-jsx': 7.16.5_@babel+core@7.17.10 '@babel/template': 7.16.0 '@babel/traverse': 7.16.5 '@babel/types': 7.16.0 @@ -2897,7 +2929,7 @@ packages: /@vue/compiler-core/3.2.33: resolution: {integrity: sha512-AAmr52ji3Zhk7IKIuigX2osWWsb2nQE5xsdFYjdnmtQ4gymmqXbjLvkSE174+fF3A3kstYrTgGkqgOEbsdLDpw==} dependencies: - '@babel/parser': 7.17.9 + '@babel/parser': 7.17.10 '@vue/shared': 3.2.33 estree-walker: 2.0.2 source-map: 0.6.1 @@ -3137,12 +3169,12 @@ packages: acorn-walk: 7.2.0 dev: true - /acorn-jsx/5.3.2_acorn@8.7.0: + /acorn-jsx/5.3.2_acorn@8.7.1: resolution: {integrity: sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==} peerDependencies: acorn: ^6.0.0 || ^7.0.0 || ^8.0.0 dependencies: - acorn: 8.7.0 + acorn: 8.7.1 dev: true /acorn-node/1.8.2: @@ -3173,6 +3205,12 @@ packages: hasBin: true dev: true + /acorn/8.7.1: + resolution: {integrity: sha512-Xx54uLJQZ19lKygFXOWsscKUbsBZW0CPykPhVQdhIeIwrbPmJzqeASDInc8nKBnp/JT6igTs82qPXz069H8I/A==} + engines: {node: '>=0.4.0'} + hasBin: true + dev: true + /add-stream/1.0.0: resolution: {integrity: sha1-anmQQ3ynNtXhKI25K9MmbV9csqo=} dev: true @@ -3530,6 +3568,18 @@ packages: node-releases: 2.0.1 picocolors: 1.0.0 + /browserslist/4.20.3: + resolution: {integrity: sha512-NBhymBQl1zM0Y5dQT/O+xiLP9/rzOIQdKM/eMJBAq7yBgaB6krIYLGejrwVYnSHZdqjscB1SPuAjHwxjvN6Wdg==} + engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} + hasBin: true + dependencies: + caniuse-lite: 1.0.30001334 + electron-to-chromium: 1.4.129 + escalade: 3.1.1 + node-releases: 2.0.4 + picocolors: 1.0.0 + dev: false + /bs-logger/0.2.6: resolution: {integrity: sha512-pd8DCoxmbgc7hyPKOvxtqNcjYoOsABPQdcCUjGp3d42VR2CX1ORhk2A87oqqu5R1kk+76nsxZupkmyd+MVtCog==} engines: {node: '>= 6'} @@ -3614,6 +3664,10 @@ packages: /caniuse-lite/1.0.30001294: resolution: {integrity: sha512-LiMlrs1nSKZ8qkNhpUf5KD0Al1KCBE3zaT7OLOwEkagXMEDij98SiOovn9wxVGQpklk9vVC/pUSqgYmkmKOS8g==} + /caniuse-lite/1.0.30001334: + resolution: {integrity: sha512-kbaCEBRRVSoeNs74sCuq92MJyGrMtjWVfhltoHUCW4t4pXFvGjUBrfo47weBRViHkiV3eBYyIsfl956NtHGazw==} + dev: false + /chalk/2.4.2: resolution: {integrity: sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==} engines: {node: '>=4'} @@ -4093,8 +4147,8 @@ packages: is-what: 3.14.1 dev: true - /core-js/3.22.2: - resolution: {integrity: sha512-Z5I2vzDnEIqO2YhELVMFcL1An2CIsFe9Q7byZhs8c/QxummxZlAHw33TUHbIte987LkisOgL0LwQ1P9D6VISnA==} + /core-js/3.22.3: + resolution: {integrity: sha512-1t+2a/d2lppW1gkLXx3pKPVGbBdxXAkqztvWb1EJ8oF8O2gIGiytzflNiFEehYwVK/t2ryUsGBoOFFvNx95mbg==} requiresBuild: true dev: false @@ -4470,6 +4524,10 @@ packages: resolution: {integrity: sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=} dev: true + /electron-to-chromium/1.4.129: + resolution: {integrity: sha512-GgtN6bsDtHdtXJtlMYZWGB/uOyjZWjmRDumXTas7dGBaB9zUyCjzHet1DY2KhyHN8R0GLbzZWqm4efeddqqyRQ==} + dev: false + /electron-to-chromium/1.4.29: resolution: {integrity: sha512-N2Jbwxo5Rum8G2YXeUxycs1sv4Qme/ry71HG73bv8BvZl+I/4JtRgK/En+ST/Wh/yF1fqvVCY4jZBgMxnhjtBA==} @@ -4804,25 +4862,25 @@ packages: engines: {node: '>= 14.6.0', npm: '>= 6.0.0', pnpm: '>= 6.32.9'} dev: true - /eslint-plugin-es/3.0.1_eslint@8.13.0: + /eslint-plugin-es/3.0.1_eslint@8.14.0: resolution: {integrity: sha512-GUmAsJaN4Fc7Gbtl8uOBlayo2DqhwWvEzykMHSCZHU3XdJ+NSzzZcVhXh3VxX5icqQ+oQdIEawXX8xkR3mIFmQ==} engines: {node: '>=8.10.0'} peerDependencies: eslint: '>=4.19.1' dependencies: - eslint: 8.13.0 + eslint: 8.14.0 eslint-utils: 2.1.0 regexpp: 3.2.0 dev: true - /eslint-plugin-node/11.1.0_eslint@8.13.0: + /eslint-plugin-node/11.1.0_eslint@8.14.0: resolution: {integrity: sha512-oUwtPJ1W0SKD0Tr+wqu92c5xuCeQqB3hSCHasn/ZgjFdA9iDGNkNf2Zi9ztY7X+hNuMib23LNGRm6+uN+KLE3g==} engines: {node: '>=8.10.0'} peerDependencies: eslint: '>=5.16.0' dependencies: - eslint: 8.13.0 - eslint-plugin-es: 3.0.1_eslint@8.13.0 + eslint: 8.14.0 + eslint-plugin-es: 3.0.1_eslint@8.14.0 eslint-utils: 2.1.0 ignore: 5.2.0 minimatch: 3.0.4 @@ -4853,13 +4911,13 @@ packages: eslint-visitor-keys: 1.3.0 dev: true - /eslint-utils/3.0.0_eslint@8.13.0: + /eslint-utils/3.0.0_eslint@8.14.0: resolution: {integrity: sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==} engines: {node: ^10.0.0 || ^12.0.0 || >= 14.0.0} peerDependencies: eslint: '>=5' dependencies: - eslint: 8.13.0 + eslint: 8.14.0 eslint-visitor-keys: 2.1.0 dev: true @@ -4878,12 +4936,12 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true - /eslint/8.13.0: - resolution: {integrity: sha512-D+Xei61eInqauAyTJ6C0q6x9mx7kTUC1KZ0m0LSEexR0V+e94K12LmWX076ZIsldwfQ2RONdaJe0re0TRGQbRQ==} + /eslint/8.14.0: + resolution: {integrity: sha512-3/CE4aJX7LNEiE3i6FeodHmI/38GZtWCsAtsymScmzYapx8q1nVVb+eLcLSzATmCPXw5pT4TqVs1E0OmxAd9tw==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} hasBin: true dependencies: - '@eslint/eslintrc': 1.2.1 + '@eslint/eslintrc': 1.2.2 '@humanwhocodes/config-array': 0.9.2 ajv: 6.12.6 chalk: 4.1.2 @@ -4892,7 +4950,7 @@ packages: doctrine: 3.0.0 escape-string-regexp: 4.0.0 eslint-scope: 7.1.1 - eslint-utils: 3.0.0_eslint@8.13.0 + eslint-utils: 3.0.0_eslint@8.14.0 eslint-visitor-keys: 3.3.0 espree: 9.3.1 esquery: 1.4.0 @@ -4926,8 +4984,8 @@ packages: resolution: {integrity: sha512-bvdyLmJMfwkV3NCRl5ZhJf22zBFo1y8bYh3VYb+bfzqNB4Je68P2sSuXyuFquzWLebHpNd2/d5uv7yoP9ISnGQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dependencies: - acorn: 8.7.0 - acorn-jsx: 5.3.2_acorn@8.7.0 + acorn: 8.7.1 + acorn-jsx: 5.3.2_acorn@8.7.1 eslint-visitor-keys: 3.3.0 dev: true @@ -5619,13 +5677,13 @@ packages: resolution: {integrity: sha1-Bupvg2ead0njhs/h/oEq5dsiPe0=} dev: true - /icss-utils/5.1.0_postcss@8.4.12: + /icss-utils/5.1.0_postcss@8.4.13: resolution: {integrity: sha512-soFhflCVWLfRNOPU3iv5Z9VUdT44xFRbzjLsEzSr5AQmgqPMTHdU3PMT1Cf1ssx8fLNJDA1juftYl+PUcv3MqA==} engines: {node: ^10 || ^12 || >= 14} peerDependencies: postcss: ^8.1.0 dependencies: - postcss: 8.4.12 + postcss: 8.4.13 dev: true /ignore/5.2.0: @@ -6505,7 +6563,7 @@ packages: optional: true dependencies: abab: 2.0.5 - acorn: 8.7.0 + acorn: 8.7.1 acorn-globals: 6.0.0 cssom: 0.4.4 cssstyle: 2.3.0 @@ -6673,8 +6731,8 @@ packages: /lines-and-columns/1.2.4: resolution: {integrity: sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==} - /lint-staged/12.4.0: - resolution: {integrity: sha512-3X7MR0h9b7qf4iXf/1n7RlVAx+EzpAZXoCEMhVSpaBlgKDfH2ewf+QUm7BddFyq29v4dgPP+8+uYpWuSWx035A==} + /lint-staged/12.4.1: + resolution: {integrity: sha512-PTXgzpflrQ+pODQTG116QNB+Q6uUTDg5B5HqGvNhoQSGt8Qy+MA/6zSnR8n38+sxP5TapzeQGTvoKni0KRS8Vg==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} hasBin: true dependencies: @@ -6785,6 +6843,10 @@ packages: resolution: {integrity: sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==} dev: true + /lodash.sortby/4.7.0: + resolution: {integrity: sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=} + dev: true + /lodash.topath/4.5.2: resolution: {integrity: sha1-NhY1Hzu6YZlKCTGYlmC9AyVP0Ak=} dev: false @@ -7104,6 +7166,12 @@ packages: engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} hasBin: true + /nanoid/3.3.3: + resolution: {integrity: sha512-p1sjXuopFs0xg+fPASzQ28agW1oHD7xDsd9Xkf3T15H3c/cifrFHVwrh74PdoklAPi+i7MdRsE47vm2r6JoB+w==} + engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} + hasBin: true + dev: false + /natural-compare/1.4.0: resolution: {integrity: sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=} dev: true @@ -7179,6 +7247,10 @@ packages: /node-releases/2.0.1: resolution: {integrity: sha512-CqyzN6z7Q6aMeF/ktcMVTzhAHCEpf8SOarwpzpf8pNBY2k5/oM34UHldUwp8VKI7uxct2HxSRdJjBaZeESzcxA==} + /node-releases/2.0.4: + resolution: {integrity: sha512-gbMzqQtTtDz/00jQzZ21PQzdI9PyLYqUSvD0p3naOhX4odFji0ZxYdnVwPTxmSwkmxhcFImpozceidSG+AgoPQ==} + dev: false + /nopt/5.0.0: resolution: {integrity: sha512-Tbj67rffqceeLpcRXrT7vKAN8CwfPeIBgM7E6iBkmKLV7bEMwpGgYLGv0jACUsECaa/vuxP0IjEont6umdMgtQ==} engines: {node: '>=6'} @@ -7615,13 +7687,13 @@ packages: engines: {node: '>=12.13.0'} dev: true - /postcss-import/14.1.0_postcss@8.4.12: + /postcss-import/14.1.0_postcss@8.4.13: resolution: {integrity: sha512-flwI+Vgm4SElObFVPpTIT7SU7R3qk2L7PyduMcokiaVKuWv9d/U+Gm/QAd8NDLuykTWTkcrjOeD2Pp1rMeBTGw==} engines: {node: '>=10.0.0'} peerDependencies: postcss: ^8.0.0 dependencies: - postcss: 8.4.12 + postcss: 8.4.13 postcss-value-parser: 4.2.0 read-cache: 1.0.0 resolve: 1.22.0 @@ -7677,7 +7749,7 @@ packages: yaml: 1.10.2 dev: false - /postcss-load-config/3.1.4_postcss@8.4.12+ts-node@10.4.0: + /postcss-load-config/3.1.4_postcss@8.4.13+ts-node@10.4.0: resolution: {integrity: sha512-6DiM4E7v4coTE4uzA8U//WhtPwyhiim3eyjEMFCnUpzbrkK9wJHgKDT2mR+HbtSrd/NubVaYTOpSpjUl8NQeRg==} engines: {node: '>= 10'} peerDependencies: @@ -7690,53 +7762,53 @@ packages: optional: true dependencies: lilconfig: 2.0.5 - postcss: 8.4.12 + postcss: 8.4.13 ts-node: 10.4.0_233d9fcfccc8abc8f146a08357d842da yaml: 1.10.2 dev: true - /postcss-modules-extract-imports/3.0.0_postcss@8.4.12: + /postcss-modules-extract-imports/3.0.0_postcss@8.4.13: resolution: {integrity: sha512-bdHleFnP3kZ4NYDhuGlVK+CMrQ/pqUm8bx/oGL93K6gVwiclvX5x0n76fYMKuIGKzlABOy13zsvqjb0f92TEXw==} engines: {node: ^10 || ^12 || >= 14} peerDependencies: postcss: ^8.1.0 dependencies: - postcss: 8.4.12 + postcss: 8.4.13 dev: true - /postcss-modules-local-by-default/4.0.0_postcss@8.4.12: + /postcss-modules-local-by-default/4.0.0_postcss@8.4.13: resolution: {integrity: sha512-sT7ihtmGSF9yhm6ggikHdV0hlziDTX7oFoXtuVWeDd3hHObNkcHRo9V3yg7vCAY7cONyxJC/XXCmmiHHcvX7bQ==} engines: {node: ^10 || ^12 || >= 14} peerDependencies: postcss: ^8.1.0 dependencies: - icss-utils: 5.1.0_postcss@8.4.12 - postcss: 8.4.12 + icss-utils: 5.1.0_postcss@8.4.13 + postcss: 8.4.13 postcss-selector-parser: 6.0.8 postcss-value-parser: 4.2.0 dev: true - /postcss-modules-scope/3.0.0_postcss@8.4.12: + /postcss-modules-scope/3.0.0_postcss@8.4.13: resolution: {integrity: sha512-hncihwFA2yPath8oZ15PZqvWGkWf+XUfQgUGamS4LqoP1anQLOsOJw0vr7J7IwLpoY9fatA2qiGUGmuZL0Iqlg==} engines: {node: ^10 || ^12 || >= 14} peerDependencies: postcss: ^8.1.0 dependencies: - postcss: 8.4.12 + postcss: 8.4.13 postcss-selector-parser: 6.0.8 dev: true - /postcss-modules-values/4.0.0_postcss@8.4.12: + /postcss-modules-values/4.0.0_postcss@8.4.13: resolution: {integrity: sha512-RDxHkAiEGI78gS2ofyvCsu7iycRv7oqw5xMWn9iMoR0N/7mf9D50ecQqUo5BZ9Zh2vH4bCUR/ktCqbB9m8vJjQ==} engines: {node: ^10 || ^12 || >= 14} peerDependencies: postcss: ^8.1.0 dependencies: - icss-utils: 5.1.0_postcss@8.4.12 - postcss: 8.4.12 + icss-utils: 5.1.0_postcss@8.4.13 + postcss: 8.4.13 dev: true - /postcss-modules/4.3.1_postcss@8.4.12: + /postcss-modules/4.3.1_postcss@8.4.13: resolution: {integrity: sha512-ItUhSUxBBdNamkT3KzIZwYNNRFKmkJrofvC2nWab3CPKhYBQ1f27XXh1PAPE27Psx58jeelPsxWB/+og+KEH0Q==} peerDependencies: postcss: ^8.0.0 @@ -7744,11 +7816,11 @@ packages: generic-names: 4.0.0 icss-replace-symbols: 1.1.0 lodash.camelcase: 4.3.0 - postcss: 8.4.12 - postcss-modules-extract-imports: 3.0.0_postcss@8.4.12 - postcss-modules-local-by-default: 4.0.0_postcss@8.4.12 - postcss-modules-scope: 3.0.0_postcss@8.4.12 - postcss-modules-values: 4.0.0_postcss@8.4.12 + postcss: 8.4.13 + postcss-modules-extract-imports: 3.0.0_postcss@8.4.13 + postcss-modules-local-by-default: 4.0.0_postcss@8.4.13 + postcss-modules-scope: 3.0.0_postcss@8.4.13 + postcss-modules-values: 4.0.0_postcss@8.4.13 string-hash: 1.1.3 dev: true @@ -7800,6 +7872,15 @@ packages: picocolors: 1.0.0 source-map-js: 1.0.2 + /postcss/8.4.13: + resolution: {integrity: sha512-jtL6eTBrza5MPzy8oJLFuUscHDXTV5KcLlqAWHl5q5WYRfnNRGSmOZmOZ1T6Gy7A99mOZfqungmZMpMmCVJ8ZA==} + engines: {node: ^10 || ^12 || >=14} + dependencies: + nanoid: 3.3.3 + picocolors: 1.0.0 + source-map-js: 1.0.2 + dev: false + /postcss/8.4.5: resolution: {integrity: sha512-jBDboWM8qpaqwkMwItqTQTiFikhs/67OYVvblFFTM7MrZjt6yMKd6r2kgXizEbTTljacm4NldIlZnhbjr84QYg==} engines: {node: ^10 || ^12 || >=14} @@ -8096,8 +8177,8 @@ packages: resolution: {integrity: sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==} dev: true - /react-refresh/0.12.0: - resolution: {integrity: sha512-suLIhrU2IHKL5JEKR/fAwJv7bbeq4kJ+pJopf77jHwuR+HmJS/HbrPIGsTBUVfw7tXPOmYv7UJ7PCaN49e8x4A==} + /react-refresh/0.13.0: + resolution: {integrity: sha512-XP8A9BT0CpRBD+NYLLeIhld/RqG9+gktUjW1FkE+Vm7OCinbG1SshcK5tb9ls4kzvjZr9mOQc7HYgBngEyPAXg==} engines: {node: '>=0.10.0'} dev: false @@ -8392,7 +8473,7 @@ packages: /rxjs/7.5.2: resolution: {integrity: sha512-PwDt186XaL3QN5qXj/H9DGyHhP3/RYYgZZwqBv9Tv8rsAaiwFH1IsJJlcgD37J7UW5a6O67qX0KWKS3/pu0m4w==} dependencies: - tslib: 2.3.1 + tslib: 2.4.0 dev: true /safe-buffer/5.1.2: @@ -8671,6 +8752,13 @@ packages: engines: {node: '>= 8'} dev: true + /source-map/0.8.0-beta.0: + resolution: {integrity: sha512-2ymg6oRBpebeZi9UUNsgQ89bhx01TcTkmNTGnNO88imTmbSgy4nfujrgVEFKWpMTEGA11EDkTt7mqObTPdigIA==} + engines: {node: '>= 8'} + dependencies: + whatwg-url: 7.1.0 + dev: true + /sourcemap-codec/1.4.8: resolution: {integrity: sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==} @@ -9090,14 +9178,14 @@ packages: supports-hyperlinks: 2.2.0 dev: true - /terser/5.12.1: - resolution: {integrity: sha512-NXbs+7nisos5E+yXwAD+y7zrcTkMqb0dEJxIGtSKPdCBzopf7ni4odPul2aechpV7EXNvOudYOX2bb5tln1jbQ==} + /terser/5.13.1: + resolution: {integrity: sha512-hn4WKOfwnwbYfe48NgrQjqNOH9jzLqRcIfbYytOXCOv46LBfWr9bDS17MQqOi+BWGD0sJK3Sj5NC/gJjiojaoA==} engines: {node: '>=10'} hasBin: true dependencies: - acorn: 8.7.0 + acorn: 8.7.1 commander: 2.20.3 - source-map: 0.7.3 + source-map: 0.8.0-beta.0 source-map-support: 0.5.21 dev: true @@ -9203,6 +9291,12 @@ packages: /tr46/0.0.3: resolution: {integrity: sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=} + /tr46/1.0.1: + resolution: {integrity: sha1-qLE/1r/SSJUZZ0zN5VujaTtwbQk=} + dependencies: + punycode: 2.1.1 + dev: true + /tr46/2.1.0: resolution: {integrity: sha512-15Ih7phfcdP5YxqiB+iDtLoaTz4Nd35+IiAv0kQ5FNKHzXgdWqPoTIqEDDJmXceQt4JZk6lVPT8lnDlPpGDppw==} engines: {node: '>=8'} @@ -9307,6 +9401,10 @@ packages: resolution: {integrity: sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==} dev: true + /tslib/2.4.0: + resolution: {integrity: sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==} + dev: true + /tsutils/3.21.0_typescript@4.5.4: resolution: {integrity: sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==} engines: {node: '>= 6'} @@ -9389,6 +9487,12 @@ packages: hasBin: true dev: true + /typescript/4.6.4: + resolution: {integrity: sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg==} + engines: {node: '>=4.2.0'} + hasBin: true + dev: true + /typeson-registry/1.0.0-alpha.39: resolution: {integrity: sha512-NeGDEquhw+yfwNhguLPcZ9Oj0fzbADiX4R0WxvoY8nGhy98IbzQy1sezjoEFWOywOboj/DWehI+/aUlRVrJnnw==} engines: {node: '>=10.0.0'} @@ -9626,6 +9730,10 @@ packages: /webidl-conversions/3.0.1: resolution: {integrity: sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE=} + /webidl-conversions/4.0.2: + resolution: {integrity: sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg==} + dev: true + /webidl-conversions/5.0.0: resolution: {integrity: sha512-VlZwKPCkYKxQgeSbH5EyngOmRp7Ww7I9rQLERETtf5ofd9pGeswWiOtogpEO850jziPRarreGxn5QIiTqpb2wA==} engines: {node: '>=8'} @@ -9652,6 +9760,14 @@ packages: tr46: 0.0.3 webidl-conversions: 3.0.1 + /whatwg-url/7.1.0: + resolution: {integrity: sha512-WUu7Rg1DroM7oQvGWfOiAK21n74Gg+T4elXEQYkOhtyLeWiJFoOGLXPKI/9gzIie9CtwVLm8wtw6YJdKyxSjeg==} + dependencies: + lodash.sortby: 4.7.0 + tr46: 1.0.1 + webidl-conversions: 4.0.2 + dev: true + /whatwg-url/8.7.0: resolution: {integrity: sha512-gAojqb/m9Q8a5IV96E3fHJM70AzCkgt4uXYX2O7EmuyOnLrViCQlsEBmF9UQIu3/aeAIp2U17rtbpZWNntQqdg==} engines: {node: '>=10'} @@ -9767,8 +9883,8 @@ packages: optional: true dev: true - /ws/8.5.0: - resolution: {integrity: sha512-BWX0SWVgLPzYwF8lTzEy1egjhS4S4OEAHfsO8o65WOVsrnSRGaSiUaa9e0ggGlkMTtBlmOpEXiie9RUcBO86qg==} + /ws/8.6.0: + resolution: {integrity: sha512-AzmM3aH3gk0aX7/rZLYvjdvZooofDu3fFOzGqcSnQ1tOcTWwhM/o+q++E8mAyVVIyUdajrkzWUGftaVSDLn1bw==} engines: {node: '>=10.0.0'} peerDependencies: bufferutil: ^4.0.1 From cf8a48a6c8b3b1f9ef2a2cf41765d456f85c6cae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Mon, 2 May 2022 16:41:05 +0900 Subject: [PATCH 103/175] fix(css): inline css module when ssr, minify issue (fix #5471) (#7807) --- packages/playground/css/__tests__/css.spec.ts | 10 ++++++++- packages/vite/src/node/plugins/css.ts | 22 +++++++++++++------ 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/packages/playground/css/__tests__/css.spec.ts b/packages/playground/css/__tests__/css.spec.ts index 6ca00e760349b1..9869bb34d2c690 100644 --- a/packages/playground/css/__tests__/css.spec.ts +++ b/packages/playground/css/__tests__/css.spec.ts @@ -15,7 +15,11 @@ import { // in later assertions to ensure CSS HMR doesn't reload the page test('imported css', async () => { const css = await page.textContent('.imported-css') - expect(css).toContain('.imported {') + expect(css).toMatch(/\.imported ?{/) + if (isBuild) { + expect(css.trim()).not.toContain('\n') // check minified + } + const glob = await page.textContent('.imported-css-glob') expect(glob).toContain('.dir-import') const globEager = await page.textContent('.imported-css-globEager') @@ -372,6 +376,10 @@ test('inlined-code', async () => { // should resolve assets expect(code).toContain('background:') expect(code).not.toContain('__VITE_ASSET__') + + if (isBuild) { + expect(code.trim()).not.toContain('\n') // check minified + } }) test('minify css', async () => { diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index b3ea3338cecc04..9ead17822d23a9 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -300,11 +300,17 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin { return } + const isHTMLProxy = htmlProxyRE.test(id) const inlined = inlineRE.test(id) const modules = cssModulesCache.get(config)!.get(id) - const isHTMLProxy = htmlProxyRE.test(id) + + // #6984, #7552 + // `foo.module.css` => modulesCode + // `foo.module.css?inline` => cssContent const modulesCode = - modules && dataToEsm(modules, { namedExports: true, preferConst: true }) + modules && + !inlined && + dataToEsm(modules, { namedExports: true, preferConst: true }) if (config.command === 'serve') { if (isDirectCSSRequest(id)) { @@ -366,12 +372,14 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin { let code: string if (usedRE.test(id)) { - if (inlined) { - code = `export default ${JSON.stringify( - await minifyCSS(css, config) - )}` + if (modulesCode) { + code = modulesCode } else { - code = modulesCode || `export default ${JSON.stringify(css)}` + let content = css + if (config.build.minify) { + content = await minifyCSS(content, config) + } + code = `export default ${JSON.stringify(content)}` } } else { code = `export default ''` From bf40e5c88db4281b035f67d1789cccf66333ce23 Mon Sep 17 00:00:00 2001 From: xyl66 <492113976@qq.com> Date: Mon, 2 May 2022 17:25:24 +0800 Subject: [PATCH 104/175] fix(plugin-react): React is not defined when component name is lowercase (#6838) --- .../src/jsx-runtime/restore-jsx.spec.ts | 55 +++++++++++++++++++ .../src/jsx-runtime/restore-jsx.ts | 42 ++++++++------ 2 files changed, 81 insertions(+), 16 deletions(-) create mode 100644 packages/plugin-react/src/jsx-runtime/restore-jsx.spec.ts diff --git a/packages/plugin-react/src/jsx-runtime/restore-jsx.spec.ts b/packages/plugin-react/src/jsx-runtime/restore-jsx.spec.ts new file mode 100644 index 00000000000000..adbd7a60599c25 --- /dev/null +++ b/packages/plugin-react/src/jsx-runtime/restore-jsx.spec.ts @@ -0,0 +1,55 @@ +import { restoreJSX } from './restore-jsx' +import * as babel from '@babel/core' + +async function jsx(sourceCode: string) { + const [ast] = await restoreJSX(babel, sourceCode, 'test.js') + if (ast === null) { + return ast + } + const { code } = await babel.transformFromAstAsync(ast, null, { + configFile: false + }) + return code +} +// jsx(`import React__default, { PureComponent, Component, forwardRef, memo, createElement } from 'react'; +// React__default.createElement(Foo)`) +// Tests adapted from: https://github.com/flying-sheep/babel-plugin-transform-react-createelement-to-jsx/blob/63137b6/test/index.js +describe('restore-jsx', () => { + it('should trans to ', async () => { + expect( + await jsx(`import React__default, { PureComponent, Component, forwardRef, memo, createElement } from 'react'; + React__default.createElement(foo)`) + ).toBeNull() + expect( + await jsx(`import React__default, { PureComponent, Component, forwardRef, memo, createElement } from 'react'; + React__default.createElement("h1")`) + ).toMatch(`

;`) + expect( + await jsx(`import React__default, { PureComponent, Component, forwardRef, memo, createElement } from 'react'; + React__default.createElement(Foo)`) + ).toMatch(`;`) + expect( + await jsx(`import React__default, { PureComponent, Component, forwardRef, memo, createElement } from 'react'; + React__default.createElement(Foo.Bar)`) + ).toMatch(`;`) + expect( + await jsx(`import React__default, { PureComponent, Component, forwardRef, memo, createElement } from 'react'; + React__default.createElement(Foo.Bar.Baz)`) + ).toMatch(`;`) + }) + + it('should handle props', async () => { + expect( + await jsx(`import React__default, { PureComponent, Component, forwardRef, memo, createElement } from 'react'; + React__default.createElement(foo, {hi: there})`) + ).toBeNull() + expect( + await jsx(`import React__default, { PureComponent, Component, forwardRef, memo, createElement } from 'react'; + React__default.createElement("h1", {hi: there})`) + ).toMatch(`

;`) + expect( + await jsx(`import React__default, { PureComponent, Component, forwardRef, memo, createElement } from 'react'; + React__default.createElement(Foo, {hi: there})`) + ).toMatch(`;`) + }) +}) diff --git a/packages/plugin-react/src/jsx-runtime/restore-jsx.ts b/packages/plugin-react/src/jsx-runtime/restore-jsx.ts index 268153f4ba5d45..dbc2218d2343ff 100644 --- a/packages/plugin-react/src/jsx-runtime/restore-jsx.ts +++ b/packages/plugin-react/src/jsx-runtime/restore-jsx.ts @@ -20,32 +20,42 @@ export async function restoreJSX( } const [reactAlias, isCommonJS] = parseReactAlias(code) + if (!reactAlias) { return jsxNotFound } - const reactJsxRE = new RegExp( - '\\b' + reactAlias + '\\.(createElement|Fragment)\\b', - 'g' - ) - let hasCompiledJsx = false - code = code.replace(reactJsxRE, (_, prop) => { - hasCompiledJsx = true - // Replace with "React" so JSX can be reverse compiled. - return 'React.' + prop - }) + + const fragmentPattern = `\\b${reactAlias}\\.Fragment\\b` + const createElementPattern = `\\b${reactAlias}\\.createElement\\(\\s*([A-Z"'][\\w$.]*["']?)` + + // Replace the alias with "React" so JSX can be reverse compiled. + code = code + .replace(new RegExp(fragmentPattern, 'g'), () => { + hasCompiledJsx = true + return 'React.Fragment' + }) + .replace(new RegExp(createElementPattern, 'g'), (original, component) => { + if (/^[a-z][\w$]*$/.test(component)) { + // Take care not to replace the alias for `createElement` calls whose + // component is a lowercased variable, since the `restoreJSX` Babel + // plugin leaves them untouched. + return original + } + hasCompiledJsx = true + return ( + 'React.createElement(' + + // Assume `Fragment` is equivalent to `React.Fragment` so modules + // that use `import {Fragment} from 'react'` are reverse compiled. + (component === 'Fragment' ? 'React.Fragment' : component) + ) + }) if (!hasCompiledJsx) { return jsxNotFound } - // Support modules that use `import {Fragment} from 'react'` - code = code.replace( - /createElement\(Fragment,/g, - 'createElement(React.Fragment,' - ) - babelRestoreJSX ||= import('./babel-restore-jsx') const result = await babel.transformAsync(code, { From d58c03088c2eed33417866b46238070fbaffa0f2 Mon Sep 17 00:00:00 2001 From: patak-dev Date: Mon, 2 May 2022 15:49:50 +0200 Subject: [PATCH 105/175] chore: update license --- packages/vite/LICENSE.md | 56 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/packages/vite/LICENSE.md b/packages/vite/LICENSE.md index ccff3f1508a73b..30803708e30a76 100644 --- a/packages/vite/LICENSE.md +++ b/packages/vite/LICENSE.md @@ -237,6 +237,33 @@ Repository: git+https://github.com/ampproject/remapping.git --------------------------------------- +## @jridgewell/gen-mapping +License: MIT +By: Justin Ridgewell +Repository: https://github.com/jridgewell/gen-mapping + +> Copyright 2022 Justin Ridgewell +> +> Permission is hereby granted, free of charge, to any person obtaining a copy +> of this software and associated documentation files (the "Software"), to deal +> in the Software without restriction, including without limitation the rights +> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +> copies of the Software, and to permit persons to whom the Software is +> furnished to do so, subject to the following conditions: +> +> The above copyright notice and this permission notice shall be included in +> all copies or substantial portions of the Software. +> +> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +> SOFTWARE. + +--------------------------------------- + ## @jridgewell/resolve-uri License: MIT By: Justin Ridgewell @@ -264,6 +291,33 @@ Repository: https://github.com/jridgewell/resolve-uri --------------------------------------- +## @jridgewell/set-array +License: MIT +By: Justin Ridgewell +Repository: https://github.com/jridgewell/set-array + +> Copyright 2022 Justin Ridgewell +> +> Permission is hereby granted, free of charge, to any person obtaining a copy +> of this software and associated documentation files (the "Software"), to deal +> in the Software without restriction, including without limitation the rights +> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +> copies of the Software, and to permit persons to whom the Software is +> furnished to do so, subject to the following conditions: +> +> The above copyright notice and this permission notice shall be included in +> all copies or substantial portions of the Software. +> +> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +> SOFTWARE. + +--------------------------------------- + ## @jridgewell/sourcemap-codec License: MIT By: Rich Harris @@ -577,7 +631,7 @@ Repository: https://github.com/acornjs/acorn.git > MIT License > -> Copyright (C) 2012-2020 by various contributors (see AUTHORS) +> Copyright (C) 2012-2022 by various contributors (see AUTHORS) > > Permission is hereby granted, free of charge, to any person obtaining a copy > of this software and associated documentation files (the "Software"), to deal From dde774f0e42dc24ccec7a4710cc842a12f0d785d Mon Sep 17 00:00:00 2001 From: patak-dev Date: Mon, 2 May 2022 15:51:28 +0200 Subject: [PATCH 106/175] release: v2.9.7 --- packages/vite/CHANGELOG.md | 20 ++++++++++++++++++++ packages/vite/package.json | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/packages/vite/CHANGELOG.md b/packages/vite/CHANGELOG.md index c2dc1488d84b21..db8bf085dc04f6 100644 --- a/packages/vite/CHANGELOG.md +++ b/packages/vite/CHANGELOG.md @@ -1,3 +1,23 @@ +## 2.9.7 (2022-05-02) + +* chore: update license ([d58c030](https://github.com/vitejs/vite/commit/d58c030)) +* chore(css): catch postcss config error (fix #2793) (#7934) ([7f535ac](https://github.com/vitejs/vite/commit/7f535ac)), closes [#2793](https://github.com/vitejs/vite/issues/2793) [#7934](https://github.com/vitejs/vite/issues/7934) +* chore(deps): update all non-major dependencies (#7949) ([b877d30](https://github.com/vitejs/vite/commit/b877d30)), closes [#7949](https://github.com/vitejs/vite/issues/7949) +* fix: inject esbuild helpers in IIFE and UMD wrappers (#7948) ([f7d2d71](https://github.com/vitejs/vite/commit/f7d2d71)), closes [#7948](https://github.com/vitejs/vite/issues/7948) +* fix: inline css hash (#7974) ([f6ae60d](https://github.com/vitejs/vite/commit/f6ae60d)), closes [#7974](https://github.com/vitejs/vite/issues/7974) +* fix: inline style hmr, transform style code inplace (#7869) ([a30a548](https://github.com/vitejs/vite/commit/a30a548)), closes [#7869](https://github.com/vitejs/vite/issues/7869) +* fix: use NODE_ENV in optimizer (#7673) ([50672e4](https://github.com/vitejs/vite/commit/50672e4)), closes [#7673](https://github.com/vitejs/vite/issues/7673) +* fix(css): clean comments before hoist at rules (#7924) ([e48827f](https://github.com/vitejs/vite/commit/e48827f)), closes [#7924](https://github.com/vitejs/vite/issues/7924) +* fix(css): dynamic import css in package fetches removed js (fixes #7955, #6823) (#7969) ([025eebf](https://github.com/vitejs/vite/commit/025eebf)), closes [#7955](https://github.com/vitejs/vite/issues/7955) [#6823](https://github.com/vitejs/vite/issues/6823) [#7969](https://github.com/vitejs/vite/issues/7969) +* fix(css): inline css module when ssr, minify issue (fix #5471) (#7807) ([cf8a48a](https://github.com/vitejs/vite/commit/cf8a48a)), closes [#5471](https://github.com/vitejs/vite/issues/5471) [#7807](https://github.com/vitejs/vite/issues/7807) +* fix(css): sourcemap crash with postcss (#7982) ([7f9f8f1](https://github.com/vitejs/vite/commit/7f9f8f1)), closes [#7982](https://github.com/vitejs/vite/issues/7982) +* fix(css): support postcss.config.ts (#7935) ([274c10e](https://github.com/vitejs/vite/commit/274c10e)), closes [#7935](https://github.com/vitejs/vite/issues/7935) +* fix(ssr): failed ssrLoadModule call throws same error (#7177) ([891e7fc](https://github.com/vitejs/vite/commit/891e7fc)), closes [#7177](https://github.com/vitejs/vite/issues/7177) +* fix(worker): import.meta.* (#7706) ([b092697](https://github.com/vitejs/vite/commit/b092697)), closes [#7706](https://github.com/vitejs/vite/issues/7706) +* docs: `server.origin` config trailing slash (fix #6622) (#7865) ([5c1ee5a](https://github.com/vitejs/vite/commit/5c1ee5a)), closes [#6622](https://github.com/vitejs/vite/issues/6622) [#7865](https://github.com/vitejs/vite/issues/7865) + + + ## 2.9.6 (2022-04-26) * fix: `apply` condition skipped for nested plugins (#7741) ([1f2ca53](https://github.com/vitejs/vite/commit/1f2ca53)), closes [#7741](https://github.com/vitejs/vite/issues/7741) diff --git a/packages/vite/package.json b/packages/vite/package.json index 39b95bbab97769..3720837d3a5afc 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -1,6 +1,6 @@ { "name": "vite", - "version": "2.9.6", + "version": "2.9.7", "license": "MIT", "author": "Evan You", "description": "Native-ESM powered web dev build tool", From f8930432134b8ac556d088b92b812e79c7258940 Mon Sep 17 00:00:00 2001 From: patak-dev Date: Mon, 2 May 2022 15:52:58 +0200 Subject: [PATCH 107/175] release: plugin-legacy@1.8.2 --- packages/plugin-legacy/CHANGELOG.md | 9 +++++++++ packages/plugin-legacy/package.json | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/plugin-legacy/CHANGELOG.md b/packages/plugin-legacy/CHANGELOG.md index 5c00212554ce8c..035460b5816cb5 100644 --- a/packages/plugin-legacy/CHANGELOG.md +++ b/packages/plugin-legacy/CHANGELOG.md @@ -1,3 +1,12 @@ +## 1.8.2 (2022-05-02) + +* chore(deps): update all non-major dependencies (#7780) ([eba9d05](https://github.com/vitejs/vite/commit/eba9d05)), closes [#7780](https://github.com/vitejs/vite/issues/7780) +* chore(deps): update all non-major dependencies (#7847) ([e29d1d9](https://github.com/vitejs/vite/commit/e29d1d9)), closes [#7847](https://github.com/vitejs/vite/issues/7847) +* chore(deps): update all non-major dependencies (#7949) ([b877d30](https://github.com/vitejs/vite/commit/b877d30)), closes [#7949](https://github.com/vitejs/vite/issues/7949) +* refactor(legacy): remove unneeded dynamic import var init code (#7759) ([12a4e7d](https://github.com/vitejs/vite/commit/12a4e7d)), closes [#7759](https://github.com/vitejs/vite/issues/7759) + + + ## 1.8.1 (2022-04-13) * fix(deps): update all non-major dependencies (#7668) ([485263c](https://github.com/vitejs/vite/commit/485263c)), closes [#7668](https://github.com/vitejs/vite/issues/7668) diff --git a/packages/plugin-legacy/package.json b/packages/plugin-legacy/package.json index 1ba92ee5fd8565..948bbb152ce56f 100644 --- a/packages/plugin-legacy/package.json +++ b/packages/plugin-legacy/package.json @@ -1,6 +1,6 @@ { "name": "@vitejs/plugin-legacy", - "version": "1.8.1", + "version": "1.8.2", "license": "MIT", "author": "Evan You", "files": [ From 968ff695d8ddc7e31285699cf4526a324417ef17 Mon Sep 17 00:00:00 2001 From: patak-dev Date: Mon, 2 May 2022 15:54:00 +0200 Subject: [PATCH 108/175] release: plugin-react@1.3.2 --- packages/plugin-react/CHANGELOG.md | 8 ++++++++ packages/plugin-react/package.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/plugin-react/CHANGELOG.md b/packages/plugin-react/CHANGELOG.md index 958c8270b6f221..01dfee3feb7ffb 100644 --- a/packages/plugin-react/CHANGELOG.md +++ b/packages/plugin-react/CHANGELOG.md @@ -1,3 +1,11 @@ +## 1.3.2 (2022-05-02) + +* fix(plugin-react): React is not defined when component name is lowercase (#6838) ([bf40e5c](https://github.com/vitejs/vite/commit/bf40e5c)), closes [#6838](https://github.com/vitejs/vite/issues/6838) +* chore(deps): update all non-major dependencies (#7780) ([eba9d05](https://github.com/vitejs/vite/commit/eba9d05)), closes [#7780](https://github.com/vitejs/vite/issues/7780) +* chore(deps): update all non-major dependencies (#7949) ([b877d30](https://github.com/vitejs/vite/commit/b877d30)), closes [#7949](https://github.com/vitejs/vite/issues/7949) + + + ## 1.3.1 (2022-04-13) * fix(deps): update all non-major dependencies (#7668) ([485263c](https://github.com/vitejs/vite/commit/485263c)), closes [#7668](https://github.com/vitejs/vite/issues/7668) diff --git a/packages/plugin-react/package.json b/packages/plugin-react/package.json index 5698472c9dc113..4c8280a3a5ff9a 100644 --- a/packages/plugin-react/package.json +++ b/packages/plugin-react/package.json @@ -1,6 +1,6 @@ { "name": "@vitejs/plugin-react", - "version": "1.3.1", + "version": "1.3.2", "license": "MIT", "author": "Evan You", "contributors": [ From 2b6d8fec25961b34e2bfcf776be0fb4e499b4cf9 Mon Sep 17 00:00:00 2001 From: Nicolas Hedger <649677+nhedger@users.noreply.github.com> Date: Mon, 2 May 2022 20:36:19 +0200 Subject: [PATCH 109/175] chore(create-vite): update reference to volar vscode extension (#7994) --- packages/create-vite/template-vue-ts/.vscode/extensions.json | 2 +- packages/create-vite/template-vue-ts/README.md | 2 +- packages/create-vite/template-vue/.vscode/extensions.json | 2 +- packages/create-vite/template-vue/README.md | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/create-vite/template-vue-ts/.vscode/extensions.json b/packages/create-vite/template-vue-ts/.vscode/extensions.json index 3dc5b08bcdc96b..a7cea0b0678120 100644 --- a/packages/create-vite/template-vue-ts/.vscode/extensions.json +++ b/packages/create-vite/template-vue-ts/.vscode/extensions.json @@ -1,3 +1,3 @@ { - "recommendations": ["johnsoncodehk.volar"] + "recommendations": ["Vue.volar"] } diff --git a/packages/create-vite/template-vue-ts/README.md b/packages/create-vite/template-vue-ts/README.md index e432516724c1a7..30b15e215a24b7 100644 --- a/packages/create-vite/template-vue-ts/README.md +++ b/packages/create-vite/template-vue-ts/README.md @@ -4,7 +4,7 @@ This template should help get you started developing with Vue 3 and TypeScript i ## Recommended IDE Setup -- [VS Code](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=Vue.volar) ## Type Support For `.vue` Imports in TS diff --git a/packages/create-vite/template-vue/.vscode/extensions.json b/packages/create-vite/template-vue/.vscode/extensions.json index 3dc5b08bcdc96b..a7cea0b0678120 100644 --- a/packages/create-vite/template-vue/.vscode/extensions.json +++ b/packages/create-vite/template-vue/.vscode/extensions.json @@ -1,3 +1,3 @@ { - "recommendations": ["johnsoncodehk.volar"] + "recommendations": ["Vue.volar"] } diff --git a/packages/create-vite/template-vue/README.md b/packages/create-vite/template-vue/README.md index eea15cef41ea60..02124a7a0a92bc 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 -- [VS Code](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=Vue.volar) From 1db7c4939a4c589854bb7a3a85002a8f3c42a50c Mon Sep 17 00:00:00 2001 From: patak-dev Date: Mon, 2 May 2022 21:30:44 +0200 Subject: [PATCH 110/175] release: create-vite@2.9.3 --- packages/create-vite/CHANGELOG.md | 7 +++++++ packages/create-vite/package.json | 2 +- packages/create-vite/template-lit-ts/package.json | 2 +- packages/create-vite/template-lit/package.json | 2 +- packages/create-vite/template-preact-ts/package.json | 2 +- packages/create-vite/template-preact/package.json | 2 +- packages/create-vite/template-react-ts/package.json | 2 +- packages/create-vite/template-react/package.json | 2 +- packages/create-vite/template-svelte-ts/package.json | 2 +- packages/create-vite/template-svelte/package.json | 2 +- packages/create-vite/template-vanilla-ts/package.json | 2 +- packages/create-vite/template-vanilla/package.json | 2 +- packages/create-vite/template-vue-ts/package.json | 2 +- packages/create-vite/template-vue/package.json | 2 +- 14 files changed, 20 insertions(+), 13 deletions(-) diff --git a/packages/create-vite/CHANGELOG.md b/packages/create-vite/CHANGELOG.md index 7379feb81239b8..d8759a4e269c97 100644 --- a/packages/create-vite/CHANGELOG.md +++ b/packages/create-vite/CHANGELOG.md @@ -1,3 +1,10 @@ +## 2.9.3 (2022-05-02) + +* chore(create-vite): update reference to volar vscode extension (#7994) ([2b6d8fe](https://github.com/vitejs/vite/commit/2b6d8fe)), closes [#7994](https://github.com/vitejs/vite/issues/7994) +* feat(create-vite): scaffold directory with only .git (#7971) ([a5bdb9f](https://github.com/vitejs/vite/commit/a5bdb9f)), closes [#7971](https://github.com/vitejs/vite/issues/7971) + + + ## 2.9.2 (2022-04-19) * chore: remove useless code in preact template (#7789) ([e5729be](https://github.com/vitejs/vite/commit/e5729be)), closes [#7789](https://github.com/vitejs/vite/issues/7789) diff --git a/packages/create-vite/package.json b/packages/create-vite/package.json index 5a21b499d9b75d..b78537705cc14d 100644 --- a/packages/create-vite/package.json +++ b/packages/create-vite/package.json @@ -1,6 +1,6 @@ { "name": "create-vite", - "version": "2.9.2", + "version": "2.9.3", "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 eb6849d447795c..640e57b3f46089 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.9.5", + "vite": "^2.9.7", "typescript": "^4.5.4" } } diff --git a/packages/create-vite/template-lit/package.json b/packages/create-vite/template-lit/package.json index 6fc110706147f7..2b413a7effa6be 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.9.5" + "vite": "^2.9.7" } } diff --git a/packages/create-vite/template-preact-ts/package.json b/packages/create-vite/template-preact-ts/package.json index ac90637925896f..36c4e2ae644331 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.9.5" + "vite": "^2.9.7" } } diff --git a/packages/create-vite/template-preact/package.json b/packages/create-vite/template-preact/package.json index f58b6525abaa52..655779377aba28 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.9.5" + "vite": "^2.9.7" } } diff --git a/packages/create-vite/template-react-ts/package.json b/packages/create-vite/template-react-ts/package.json index 01d981f51c3414..76d8f3d637fabd 100644 --- a/packages/create-vite/template-react-ts/package.json +++ b/packages/create-vite/template-react-ts/package.json @@ -16,6 +16,6 @@ "@types/react-dom": "^18.0.0", "@vitejs/plugin-react": "^1.3.0", "typescript": "^4.6.3", - "vite": "^2.9.5" + "vite": "^2.9.7" } } diff --git a/packages/create-vite/template-react/package.json b/packages/create-vite/template-react/package.json index 4215fdea104c30..ee8097d84cd7d9 100644 --- a/packages/create-vite/template-react/package.json +++ b/packages/create-vite/template-react/package.json @@ -15,6 +15,6 @@ "@types/react": "^18.0.0", "@types/react-dom": "^18.0.0", "@vitejs/plugin-react": "^1.3.0", - "vite": "^2.9.5" + "vite": "^2.9.7" } } diff --git a/packages/create-vite/template-svelte-ts/package.json b/packages/create-vite/template-svelte-ts/package.json index ae5bf6219d8eee..f415446fa1a2a0 100644 --- a/packages/create-vite/template-svelte-ts/package.json +++ b/packages/create-vite/template-svelte-ts/package.json @@ -17,6 +17,6 @@ "svelte-preprocess": "^4.9.8", "tslib": "^2.3.1", "typescript": "^4.5.4", - "vite": "^2.9.5" + "vite": "^2.9.7" } } diff --git a/packages/create-vite/template-svelte/package.json b/packages/create-vite/template-svelte/package.json index ac224a274d1c10..f64e5f186ac840 100644 --- a/packages/create-vite/template-svelte/package.json +++ b/packages/create-vite/template-svelte/package.json @@ -11,6 +11,6 @@ "devDependencies": { "@sveltejs/vite-plugin-svelte": "^1.0.0-next.30", "svelte": "^3.44.0", - "vite": "^2.9.5" + "vite": "^2.9.7" } } diff --git a/packages/create-vite/template-vanilla-ts/package.json b/packages/create-vite/template-vanilla-ts/package.json index 94a8ccc952012a..09d074177c401c 100644 --- a/packages/create-vite/template-vanilla-ts/package.json +++ b/packages/create-vite/template-vanilla-ts/package.json @@ -9,6 +9,6 @@ }, "devDependencies": { "typescript": "^4.5.4", - "vite": "^2.9.5" + "vite": "^2.9.7" } } diff --git a/packages/create-vite/template-vanilla/package.json b/packages/create-vite/template-vanilla/package.json index ddc9844be1954f..e5eb1951cb04be 100644 --- a/packages/create-vite/template-vanilla/package.json +++ b/packages/create-vite/template-vanilla/package.json @@ -8,6 +8,6 @@ "preview": "vite preview" }, "devDependencies": { - "vite": "^2.9.5" + "vite": "^2.9.7" } } diff --git a/packages/create-vite/template-vue-ts/package.json b/packages/create-vite/template-vue-ts/package.json index c7383d48b09e3b..5072c666e52172 100644 --- a/packages/create-vite/template-vue-ts/package.json +++ b/packages/create-vite/template-vue-ts/package.json @@ -13,7 +13,7 @@ "devDependencies": { "@vitejs/plugin-vue": "^2.3.1", "typescript": "^4.5.4", - "vite": "^2.9.5", + "vite": "^2.9.7", "vue-tsc": "^0.34.7" } } diff --git a/packages/create-vite/template-vue/package.json b/packages/create-vite/template-vue/package.json index e7e9b681db608c..fe24b608b6c401 100644 --- a/packages/create-vite/template-vue/package.json +++ b/packages/create-vite/template-vue/package.json @@ -12,6 +12,6 @@ }, "devDependencies": { "@vitejs/plugin-vue": "^2.3.1", - "vite": "^2.9.5" + "vite": "^2.9.7" } } From e96b90887d4709ed1c968b658e22fbdfdb996cbb Mon Sep 17 00:00:00 2001 From: fishDog <40156382+Bigfish8@users.noreply.github.com> Date: Tue, 3 May 2022 13:44:28 +0800 Subject: [PATCH 111/175] fix(css): var in image-set (#7921) --- .../assets/__tests__/assets.spec.ts | 23 +++++++++++++++ packages/playground/assets/css/css-url.css | 23 +++++++++++++++ packages/playground/assets/index.html | 28 ++++++++++++++++++ packages/vite/src/node/plugins/css.ts | 29 ++++++++++++++----- packages/vite/src/node/utils.ts | 13 +++++---- 5 files changed, 103 insertions(+), 13 deletions(-) diff --git a/packages/playground/assets/__tests__/assets.spec.ts b/packages/playground/assets/__tests__/assets.spec.ts index 19dd52f71e114a..f1075f6fe1cb39 100644 --- a/packages/playground/assets/__tests__/assets.spec.ts +++ b/packages/playground/assets/__tests__/assets.spec.ts @@ -104,6 +104,29 @@ describe('css url() references', () => { }) }) + test('image-set with var', async () => { + const imageSet = await getBg('.css-image-set-with-var') + imageSet.split(', ').forEach((s) => { + expect(s).toMatch(assetMatch) + }) + }) + + test('image-set with mix', async () => { + const imageSet = await getBg('.css-image-set-mix-url-var') + imageSet.split(', ').forEach((s) => { + expect(s).toMatch(assetMatch) + }) + }) + + // not supported in browser now + // https://drafts.csswg.org/css-images-4/#image-set-notation + // test('image-set with multiple descriptor', async () => { + // const imageSet = await getBg('.css-image-set-multiple-descriptor') + // imageSet.split(', ').forEach((s) => { + // expect(s).toMatch(assetMatch) + // }) + // }) + test('relative in @import', async () => { expect(await getBg('.css-url-relative-at-imported')).toMatch(assetMatch) }) diff --git a/packages/playground/assets/css/css-url.css b/packages/playground/assets/css/css-url.css index 8a3f00dee17bd9..9047cd384e7d38 100644 --- a/packages/playground/assets/css/css-url.css +++ b/packages/playground/assets/css/css-url.css @@ -26,6 +26,29 @@ background-size: 10px; } +.css-image-set-with-var { + --bg-img: url('../nested/asset.png'); + background-image: -webkit-image-set(var(--bg-img) 1x, var(--bg-img) 2x); + background-size: 10px; +} + +.css-image-set-mix-url-var { + --bg-img: url('../nested/asset.png'); + background-image: -webkit-image-set( + var(--bg-img) 1x, + url('../nested/asset.png') 2x + ); + background-size: 10px; +} + +.css-image-set-multiple-descriptor { + background-image: -webkit-image-set( + '../nested/asset.png' type('image/png') 1x, + '../nested/asset.png' type('image/png') 2x + ); + background-size: 10px; +} + .css-url-public { background: url('/icon.png'); background-size: 10px; diff --git a/packages/playground/assets/index.html b/packages/playground/assets/index.html index 99c2c2fe69ae70..43eed55236abd3 100644 --- a/packages/playground/assets/index.html +++ b/packages/playground/assets/index.html @@ -46,6 +46,34 @@

CSS url references

>CSS background with image-set() (relative)

+
+ + CSS background image-set() (relative in var) + +
+
+ + CSS background image-set() (mix var and url) + +
+
+ + CSS background image-set() (with multiple descriptor) + +
+
+ + CSS background image-set() (with multiple descriptor) + +
CSS background (relative from @imported file in different dir) { @@ -1054,11 +1057,15 @@ function rewriteCssImageSet( replacer: CssUrlReplacer ): Promise { return asyncReplace(css, cssImageSetRE, async (match) => { - const [matched, rawUrl] = match - const url = await processSrcSet(rawUrl, ({ url }) => - doUrlReplace(url, matched, replacer) - ) - return `image-set(${url})` + const [, rawUrl] = match + const url = await processSrcSet(rawUrl, async ({ url }) => { + // the url maybe url(...) + if (cssUrlRE.test(url)) { + return await rewriteCssUrls(url, replacer) + } + return await doUrlReplace(url, url, replacer) + }) + return url }) } async function doUrlReplace( @@ -1073,7 +1080,13 @@ async function doUrlReplace( wrap = first rawUrl = rawUrl.slice(1, -1) } - if (isExternalUrl(rawUrl) || isDataUrl(rawUrl) || rawUrl.startsWith('#')) { + + if ( + isExternalUrl(rawUrl) || + isDataUrl(rawUrl) || + rawUrl.startsWith('#') || + varRE.test(rawUrl) + ) { return matched } diff --git a/packages/vite/src/node/utils.ts b/packages/vite/src/node/utils.ts index e7a20afbdd5ae7..32b783974dacaf 100644 --- a/packages/vite/src/node/utils.ts +++ b/packages/vite/src/node/utils.ts @@ -545,6 +545,7 @@ interface ImageCandidate { descriptor: string } const escapedSpaceCharacters = /( |\\t|\\n|\\f|\\r)+/g +const imageSetUrlRE = /^(?:[\w\-]+\(.*?\)|'.*?'|".*?"|\S*)/ export async function processSrcSet( srcs: string, replacer: (arg: ImageCandidate) => Promise @@ -552,11 +553,13 @@ export async function processSrcSet( const imageCandidates: ImageCandidate[] = srcs .split(',') .map((s) => { - const [url, descriptor] = s - .replace(escapedSpaceCharacters, ' ') - .trim() - .split(' ', 2) - return { url, descriptor } + const src = s.replace(escapedSpaceCharacters, ' ').trim() + const [url] = imageSetUrlRE.exec(src) || [] + + return { + url, + descriptor: src?.slice(url.length).trim() + } }) .filter(({ url }) => !!url) From 749e96f0dcf171795c62eb612b2ad6db5606363c Mon Sep 17 00:00:00 2001 From: Zheeeng Date: Tue, 3 May 2022 15:55:03 +0800 Subject: [PATCH 112/175] chore: fix ts checking on used-before-assigned (#6939) --- scripts/jestPerTestSetup.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/scripts/jestPerTestSetup.ts b/scripts/jestPerTestSetup.ts index f4c9db03627c7c..098784ae76c2af 100644 --- a/scripts/jestPerTestSetup.ts +++ b/scripts/jestPerTestSetup.ts @@ -243,14 +243,15 @@ function startStaticServer(config?: InlineConfig): Promise { export async function notifyRebuildComplete( watcher: RollupWatcher ): Promise { - let callback: (event: RollupWatcherEvent) => void - await new Promise((resolve, reject) => { - callback = (event) => { - if (event.code === 'END') { - resolve() - } + let resolveFn: undefined | (() => void) + const callback = (event: RollupWatcherEvent): void => { + if (event.code === 'END') { + resolveFn?.() } - watcher.on('event', callback) + } + watcher.on('event', callback) + await new Promise((resolve) => { + resolveFn = resolve }) return watcher.removeListener('event', callback) } From f1af9416a1123c617675ca0165ac401486b636dc Mon Sep 17 00:00:00 2001 From: yoho Date: Wed, 4 May 2022 02:43:32 +0800 Subject: [PATCH 113/175] chore: restore-jsx.spec.ts lint (#8004) --- packages/plugin-react/src/jsx-runtime/restore-jsx.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/plugin-react/src/jsx-runtime/restore-jsx.spec.ts b/packages/plugin-react/src/jsx-runtime/restore-jsx.spec.ts index adbd7a60599c25..c216e99bc3480d 100644 --- a/packages/plugin-react/src/jsx-runtime/restore-jsx.spec.ts +++ b/packages/plugin-react/src/jsx-runtime/restore-jsx.spec.ts @@ -3,7 +3,7 @@ import * as babel from '@babel/core' async function jsx(sourceCode: string) { const [ast] = await restoreJSX(babel, sourceCode, 'test.js') - if (ast === null) { + if (ast == null) { return ast } const { code } = await babel.transformFromAstAsync(ast, null, { From 642d65ba6190a87a2f4d534f545672a1a0f10f1c Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Wed, 4 May 2022 02:46:10 +0800 Subject: [PATCH 114/175] fix: only handle merge ssr.noExternal (#8003) --- .../vite/src/node/__tests__/config.spec.ts | 24 +++++++++++++++++++ packages/vite/src/node/config.ts | 6 ++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/packages/vite/src/node/__tests__/config.spec.ts b/packages/vite/src/node/__tests__/config.spec.ts index dd427c19433475..ca7a2e76122cd0 100644 --- a/packages/vite/src/node/__tests__/config.spec.ts +++ b/packages/vite/src/node/__tests__/config.spec.ts @@ -157,6 +157,30 @@ describe('mergeConfig', () => { expect(mergeConfig(baseConfig, newConfig)).toEqual(mergedConfig) }) + + test('handles ssr.noExternal', () => { + const baseConfig = { + ssr: { + noExternal: true + } + } + + const newConfig = { + ssr: { + noExternal: ['foo'] + } + } + + const mergedConfig = { + ssr: { + noExternal: true + } + } + + // merging either ways, `ssr.noExternal: true` should take highest priority + expect(mergeConfig(baseConfig, newConfig)).toEqual(mergedConfig) + expect(mergeConfig(newConfig, baseConfig)).toEqual(mergedConfig) + }) }) describe('resolveConfig', () => { diff --git a/packages/vite/src/node/config.ts b/packages/vite/src/node/config.ts index 27a107f3e2098c..531fe169f72de0 100644 --- a/packages/vite/src/node/config.ts +++ b/packages/vite/src/node/config.ts @@ -745,7 +745,11 @@ function mergeConfigRecursively( } else if (key === 'assetsInclude' && rootPath === '') { merged[key] = [].concat(existing, value) continue - } else if (key === 'noExternal' && (existing === true || value === true)) { + } else if ( + key === 'noExternal' && + rootPath === 'ssr' && + (existing === true || value === true) + ) { merged[key] = true continue } From f3d15f106f378c3850b62fbebd69fc8f7c7f944b Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Wed, 4 May 2022 02:48:11 +0800 Subject: [PATCH 115/175] refactor(plugin-vue): remove querystring import (#7997) --- packages/plugin-vue/src/main.ts | 5 ++--- packages/plugin-vue/src/utils/query.ts | 4 +--- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/packages/plugin-vue/src/main.ts b/packages/plugin-vue/src/main.ts index 44b1de74721efd..d4417548e2e40c 100644 --- a/packages/plugin-vue/src/main.ts +++ b/packages/plugin-vue/src/main.ts @@ -1,4 +1,3 @@ -import qs from 'querystring' import path from 'path' import type { SFCBlock, SFCDescriptor } from 'vue/compiler-sfc' import type { ResolvedOptions } from '.' @@ -426,8 +425,8 @@ function attrsToQuery( for (const name in attrs) { const value = attrs[name] if (!ignoreList.includes(name)) { - query += `&${qs.escape(name)}${ - value ? `=${qs.escape(String(value))}` : `` + query += `&${encodeURIComponent(name)}${ + value ? `=${encodeURIComponent(value)}` : `` }` } } diff --git a/packages/plugin-vue/src/utils/query.ts b/packages/plugin-vue/src/utils/query.ts index d41cb1be2cf536..060b5f28987bfa 100644 --- a/packages/plugin-vue/src/utils/query.ts +++ b/packages/plugin-vue/src/utils/query.ts @@ -1,5 +1,3 @@ -import qs from 'querystring' - export interface VueQuery { vue?: boolean src?: string @@ -14,7 +12,7 @@ export function parseVueRequest(id: string): { query: VueQuery } { const [filename, rawQuery] = id.split(`?`, 2) - const query = qs.parse(rawQuery) as VueQuery + const query = Object.fromEntries(new URLSearchParams(rawQuery)) as VueQuery if (query.vue != null) { query.vue = true } From d49e3fbfc0227e2e00ffc4a8d4152135c5cd6bb8 Mon Sep 17 00:00:00 2001 From: Saurabh Daware Date: Wed, 4 May 2022 10:32:09 +0530 Subject: [PATCH 116/175] fix: inline js and css paths for virtual html (#7993) Co-authored-by: yoho Co-authored-by: patak-dev --- packages/playground/ssr-html/server.js | 31 ++++++++-- .../src/node/server/middlewares/indexHtml.ts | 57 ++++++++++++++----- 2 files changed, 69 insertions(+), 19 deletions(-) diff --git a/packages/playground/ssr-html/server.js b/packages/playground/ssr-html/server.js index ad115f1be01163..1f2cd5331c0157 100644 --- a/packages/playground/ssr-html/server.js +++ b/packages/playground/ssr-html/server.js @@ -14,6 +14,14 @@ const DYNAMIC_SCRIPTS = ` ` +const DYNAMIC_STYLES = ` + +` + async function createServer( root = process.cwd(), isProd = process.env.NODE_ENV === 'production' @@ -42,15 +50,30 @@ async function createServer( // use vite's connect instance as middleware app.use(vite.middlewares) - app.use('*', async (req, res) => { + app.use('*', async (req, res, next) => { try { let [url] = req.originalUrl.split('?') if (url.endsWith('/')) url += 'index.html' + if (url.startsWith('/favicon.ico')) { + return res.status(404).end('404') + } + if (url.startsWith('/@id/__x00__')) { + return next() + } + const htmlLoc = resolve(`.${url}`) - let html = fs.readFileSync(htmlLoc, 'utf8') - html = html.replace('', `${DYNAMIC_SCRIPTS}`) - html = await vite.transformIndexHtml(url, html) + let template = fs.readFileSync(htmlLoc, 'utf-8') + + template = template.replace( + '', + `${DYNAMIC_SCRIPTS}${DYNAMIC_STYLES}` + ) + + // Force calling transformIndexHtml with url === '/', to simulate + // usage by ecosystem that was recommended in the SSR documentation + // as `const url = req.originalUrl` + const html = await vite.transformIndexHtml('/', template) res.status(200).set({ 'Content-Type': 'text/html' }).end(html) } catch (e) { diff --git a/packages/vite/src/node/server/middlewares/indexHtml.ts b/packages/vite/src/node/server/middlewares/indexHtml.ts index 8638492b1c2001..955ee6b708f54d 100644 --- a/packages/vite/src/node/server/middlewares/indexHtml.ts +++ b/packages/vite/src/node/server/middlewares/indexHtml.ts @@ -1,6 +1,7 @@ import fs from 'fs' import path from 'path' import MagicString from 'magic-string' +import type { SourceMapInput } from 'rollup' import type { AttributeNode, ElementNode, TextNode } from '@vue/compiler-dom' import { NodeTypes } from '@vue/compiler-dom' import type { Connect } from 'types/connect' @@ -15,7 +16,12 @@ import { } from '../../plugins/html' import type { ResolvedConfig, ViteDevServer } from '../..' import { send } from '../send' -import { CLIENT_PUBLIC_PATH, FS_PREFIX } from '../../constants' +import { + CLIENT_PUBLIC_PATH, + FS_PREFIX, + VALID_ID_PREFIX, + NULL_BYTE_PLACEHOLDER +} from '../../constants' import { cleanUrl, fsPathFromId, @@ -108,32 +114,53 @@ const devHtmlHook: IndexHtmlTransformHook = async ( const { config, moduleGraph, watcher } = server! const base = config.base || '/' + let proxyModulePath: string + let proxyModuleUrl: string + + const trailingSlash = htmlPath.endsWith('/') + if (!trailingSlash && fs.existsSync(filename)) { + proxyModulePath = htmlPath + proxyModuleUrl = base + htmlPath.slice(1) + } else { + // There are users of vite.transformIndexHtml calling it with url '/' + // for SSR integrations #7993, filename is root for this case + // A user may also use a valid name for a virtual html file + // Mark the path as virtual in both cases so sourcemaps aren't processed + // and ids are properly handled + const validPath = `${htmlPath}${trailingSlash ? 'index.html' : ''}` + proxyModulePath = `\0${validPath}` + proxyModuleUrl = `${VALID_ID_PREFIX}${NULL_BYTE_PLACEHOLDER}${validPath}` + } + const s = new MagicString(html) let inlineModuleIndex = -1 - const filePath = cleanUrl(htmlPath) + const proxyCacheUrl = cleanUrl(proxyModulePath).replace( + normalizePath(config.root), + '' + ) const styleUrl: AssetNode[] = [] const addInlineModule = (node: ElementNode, ext: 'js') => { inlineModuleIndex++ - const url = filePath.replace(normalizePath(config.root), '') - const contentNode = node.children[0] as TextNode const code = contentNode.content - const map = new MagicString(html) - .snip(contentNode.loc.start.offset, contentNode.loc.end.offset) - .generateMap({ hires: true }) - map.sources = [filename] - map.file = filename + + let map: SourceMapInput | undefined + if (!proxyModulePath.startsWith('\0')) { + map = new MagicString(html) + .snip(contentNode.loc.start.offset, contentNode.loc.end.offset) + .generateMap({ hires: true }) + map.sources = [filename] + map.file = filename + } // add HTML Proxy to Map - addToHTMLProxyCache(config, url, inlineModuleIndex, { code, map }) + addToHTMLProxyCache(config, proxyCacheUrl, inlineModuleIndex, { code, map }) // inline js module. convert to src="proxy" - const modulePath = `${ - config.base + htmlPath.slice(1) - }?html-proxy&index=${inlineModuleIndex}.${ext}` + const modulePath = `${proxyModuleUrl}?html-proxy&index=${inlineModuleIndex}.${ext}` // invalidate the module so the newly cached contents will be served const module = server?.moduleGraph.getModuleById(modulePath) @@ -190,13 +217,13 @@ const devHtmlHook: IndexHtmlTransformHook = async ( await Promise.all( styleUrl.map(async ({ start, end, code }, index) => { - const url = filename + `?html-proxy&${index}.css` + const url = `${proxyModulePath}?html-proxy&index=${index}.css` // ensure module in graph after successful load const mod = await moduleGraph.ensureEntryFromUrl(url, false) ensureWatchedFile(watcher, mod.file, config.root) - const result = await server!.pluginContainer.transform(code, url) + const result = await server!.pluginContainer.transform(code, mod.id!) s.overwrite(start, end, result?.code || '') }) ) From 72f17f89296d6b2373fb05edcc01959f30c551d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Wed, 4 May 2022 17:50:44 +0900 Subject: [PATCH 117/175] fix(css): do not clean id when passing to postcss (fix #7822) (#7827) --- packages/playground/css/__tests__/css.spec.ts | 10 ++++++++++ packages/playground/css/index.html | 3 +++ packages/playground/css/main.js | 3 +++ packages/playground/css/postcss-source-input.css | 1 + packages/playground/css/postcss.config.js | 15 ++++++++++++++- packages/vite/src/node/plugins/css.ts | 4 ++-- 6 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 packages/playground/css/postcss-source-input.css diff --git a/packages/playground/css/__tests__/css.spec.ts b/packages/playground/css/__tests__/css.spec.ts index 9869bb34d2c690..e666ca40517d57 100644 --- a/packages/playground/css/__tests__/css.spec.ts +++ b/packages/playground/css/__tests__/css.spec.ts @@ -413,3 +413,13 @@ test("relative path rewritten in Less's data-uri", async () => { /^url\("data:image\/svg\+xml,%3Csvg/ ) }) + +test('PostCSS source.input.from includes query', async () => { + const code = await page.textContent('.postcss-source-input') + // should resolve assets + expect(code).toContain( + isBuild + ? '/postcss-source-input.css?used&query=foo' + : '/postcss-source-input.css?query=foo' + ) +}) diff --git a/packages/playground/css/index.html b/packages/playground/css/index.html index fef6a0be393748..15e81192cec7f1 100644 --- a/packages/playground/css/index.html +++ b/packages/playground/css/index.html @@ -135,6 +135,9 @@

CSS

Raw Support


+
+  

PostCSS source.input.from. Should include query

+

 
diff --git a/packages/playground/css/main.js b/packages/playground/css/main.js index 0d03aafbf0ec7f..f728b0251066d1 100644 --- a/packages/playground/css/main.js +++ b/packages/playground/css/main.js @@ -87,3 +87,6 @@ Promise.all(Object.keys(glob).map((key) => glob[key]())).then((res) => { // globEager const globEager = import.meta.globEager('./glob-import/*.css') text('.imported-css-globEager', JSON.stringify(globEager, null, 2)) + +import postcssSourceInput from './postcss-source-input.css?query=foo' +text('.postcss-source-input', postcssSourceInput) diff --git a/packages/playground/css/postcss-source-input.css b/packages/playground/css/postcss-source-input.css new file mode 100644 index 00000000000000..c6c3cb0c16dece --- /dev/null +++ b/packages/playground/css/postcss-source-input.css @@ -0,0 +1 @@ +@source-input; diff --git a/packages/playground/css/postcss.config.js b/packages/playground/css/postcss.config.js index f3d6ac9548b6a9..e90b4f9c987820 100644 --- a/packages/playground/css/postcss.config.js +++ b/packages/playground/css/postcss.config.js @@ -1,5 +1,5 @@ module.exports = { - plugins: [require('postcss-nested'), testDirDep] + plugins: [require('postcss-nested'), testDirDep, testSourceInput] } const fs = require('fs') @@ -35,3 +35,16 @@ function testDirDep() { } } testDirDep.postcss = true + +function testSourceInput() { + return { + postcssPlugin: 'source-input', + AtRule(atRule) { + if (atRule.name === 'source-input') { + atRule.after(`/* ${atRule.source.input.from} */`) + atRule.remove() + } + } + } +} +testSourceInput.postcss = true diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index 04c4ebeea95332..cd57acd1690902 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -799,8 +799,8 @@ async function compileCSS( .default(postcssPlugins) .process(code, { ...postcssOptions, - to: cleanUrl(id), - from: cleanUrl(id), + to: id, + from: id, map: { inline: false, annotation: false, From 6420ba0d7d3823aeb6c46c1136e740b6d15f18a3 Mon Sep 17 00:00:00 2001 From: Yoshi Togami <62130798+togami2864@users.noreply.github.com> Date: Wed, 4 May 2022 17:51:27 +0900 Subject: [PATCH 118/175] fix(ssr): allow ssrTransform to parse hashbang (#8005) --- .../node/ssr/__tests__/ssrTransform.spec.ts | 21 +++++++++++++++++-- packages/vite/src/node/ssr/ssrTransform.ts | 3 ++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/packages/vite/src/node/ssr/__tests__/ssrTransform.spec.ts b/packages/vite/src/node/ssr/__tests__/ssrTransform.spec.ts index 14481f98a4a87a..0e9181214c2b82 100644 --- a/packages/vite/src/node/ssr/__tests__/ssrTransform.spec.ts +++ b/packages/vite/src/node/ssr/__tests__/ssrTransform.spec.ts @@ -370,7 +370,7 @@ test('overwrite bindings', async () => { `const a = { inject }\n` + `const b = { test: inject }\n` + `function c() { const { test: inject } = { test: true }; console.log(inject) }\n` + - `const d = inject \n` + + `const d = inject\n` + `function f() { console.log(inject) }\n` + `function e() { const { inject } = { inject: true } }\n` + `function g() { const f = () => { const inject = true }; console.log(inject) }\n`, @@ -383,7 +383,7 @@ test('overwrite bindings', async () => { const a = { inject: __vite_ssr_import_0__.inject } const b = { test: __vite_ssr_import_0__.inject } function c() { const { test: inject } = { test: true }; console.log(inject) } - const d = __vite_ssr_import_0__.inject + const d = __vite_ssr_import_0__.inject function f() { console.log(__vite_ssr_import_0__.inject) } function e() { const { inject } = { inject: true } } function g() { const f = () => { const inject = true }; console.log(__vite_ssr_import_0__.inject) } @@ -719,3 +719,20 @@ export default (function getRandom() { (await ssrTransform(`export default (class A {});`, null, null)).code ).toMatchInlineSnapshot(`"__vite_ssr_exports__.default = (class A {});"`) }) + +// #8002 +test('with hashbang', async () => { + expect( + ( + await ssrTransform( + `#!/usr/bin/env node +console.log("it can parse the hashbang")`, + null, + null + ) + ).code + ).toMatchInlineSnapshot(` + "#!/usr/bin/env node + console.log(\\"it can parse the hashbang\\")" + `) +}) diff --git a/packages/vite/src/node/ssr/ssrTransform.ts b/packages/vite/src/node/ssr/ssrTransform.ts index 238482a0ceac2f..c1aa572864776a 100644 --- a/packages/vite/src/node/ssr/ssrTransform.ts +++ b/packages/vite/src/node/ssr/ssrTransform.ts @@ -37,7 +37,8 @@ export async function ssrTransform( ast = parser.parse(code, { sourceType: 'module', ecmaVersion: 'latest', - locations: true + locations: true, + allowHashBang: true }) } catch (err) { if (!err.loc || !err.loc.line) throw err From e85164ecb07e32bf3bc49ae33c7bd9ba3065482d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Wed, 4 May 2022 18:05:18 +0900 Subject: [PATCH 119/175] chore: remove maybeVirtualHtmlSet (#8010) --- packages/vite/src/node/plugins/html.ts | 4 ---- packages/vite/src/node/server/sourcemap.ts | 4 +--- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/packages/vite/src/node/plugins/html.ts b/packages/vite/src/node/plugins/html.ts index c33811008ccb17..bf3d662066630b 100644 --- a/packages/vite/src/node/plugins/html.ts +++ b/packages/vite/src/node/plugins/html.ts @@ -722,8 +722,6 @@ export function resolveHtmlTransforms( return [preHooks, postHooks] } -export const maybeVirtualHtmlSet = new Set() - export async function applyHtmlTransforms( html: string, hooks: IndexHtmlTransformHook[], @@ -734,8 +732,6 @@ export async function applyHtmlTransforms( const bodyTags: HtmlTagDescriptor[] = [] const bodyPrependTags: HtmlTagDescriptor[] = [] - maybeVirtualHtmlSet.add(ctx.filename) - for (const hook of hooks) { const res = await hook(html, ctx) if (!res) { diff --git a/packages/vite/src/node/server/sourcemap.ts b/packages/vite/src/node/server/sourcemap.ts index 0b9bcf9284754b..88cbafc344c739 100644 --- a/packages/vite/src/node/server/sourcemap.ts +++ b/packages/vite/src/node/server/sourcemap.ts @@ -1,9 +1,8 @@ import path from 'path' import { promises as fs } from 'fs' import type { Logger } from '../logger' -import { createDebugger, normalizePath } from '../utils' +import { createDebugger } from '../utils' import type { SourceMap } from 'rollup' -import { maybeVirtualHtmlSet } from '../plugins/html' const isDebug = !!process.env.DEBUG const debug = createDebugger('vite:sourcemap', { @@ -43,7 +42,6 @@ export async function injectSourcesContent( sourcePath = path.resolve(sourceRoot, sourcePath) } return fs.readFile(sourcePath, 'utf-8').catch(() => { - if (maybeVirtualHtmlSet.has(normalizePath(sourcePath))) return null missingSources.push(sourcePath) return null }) From 67c86dee44f18425bff6c1b1d36ab7f7d56f758b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Wed, 4 May 2022 18:30:46 +0900 Subject: [PATCH 120/175] test(css): fix postcss cleanid test (#8013) --- packages/playground/css/postcss.config.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/playground/css/postcss.config.js b/packages/playground/css/postcss.config.js index e90b4f9c987820..33058023541515 100644 --- a/packages/playground/css/postcss.config.js +++ b/packages/playground/css/postcss.config.js @@ -41,7 +41,11 @@ function testSourceInput() { postcssPlugin: 'source-input', AtRule(atRule) { if (atRule.name === 'source-input') { - atRule.after(`/* ${atRule.source.input.from} */`) + atRule.after( + `.source-input::before { content: ${JSON.stringify( + atRule.source.input.from + )}; }` + ) atRule.remove() } } From 0861adec967b692e41ae19dd09a264cf582f3a5e Mon Sep 17 00:00:00 2001 From: patak Date: Wed, 4 May 2022 12:05:56 +0200 Subject: [PATCH 121/175] chore: use pnpm@6 in netlify (#8011) --- netlify.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netlify.toml b/netlify.toml index ba9d1c55f567c5..ba62bdbe4d6be1 100644 --- a/netlify.toml +++ b/netlify.toml @@ -3,4 +3,4 @@ NPM_FLAGS = "--version" # prevent Netlify npm install [build] publish = "docs/.vitepress/dist" - command = "npx pnpm i --store=node_modules/.pnpm-store && npm run ci-docs" \ No newline at end of file + command = "npx pnpm@6 i --store=node_modules/.pnpm-store --frozen-lockfile && npx pnpm@6 run ci-docs" \ No newline at end of file From 99740949b77509c442a27fb0e017fcbe376f3391 Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Wed, 4 May 2022 22:32:06 +0800 Subject: [PATCH 122/175] feat: import ts with .js in vue (#7998) --- packages/playground/vue-jsx/TsImport.vue | 8 ++++++++ packages/playground/vue-jsx/TsImportFile.ts | 1 + packages/playground/vue-jsx/__tests__/vue-jsx.spec.ts | 1 + packages/playground/vue-jsx/main.jsx | 2 ++ packages/playground/vue/Main.vue | 2 ++ packages/playground/vue/TsImport.vue | 8 ++++++++ packages/playground/vue/TsImportFile.ts | 1 + packages/playground/vue/__tests__/vue.spec.ts | 4 ++++ packages/plugin-vue/src/main.ts | 5 +++++ packages/vite/src/node/plugins/resolve.ts | 11 +++++++++-- packages/vite/src/node/utils.ts | 2 +- 11 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 packages/playground/vue-jsx/TsImport.vue create mode 100644 packages/playground/vue-jsx/TsImportFile.ts create mode 100644 packages/playground/vue/TsImport.vue create mode 100644 packages/playground/vue/TsImportFile.ts diff --git a/packages/playground/vue-jsx/TsImport.vue b/packages/playground/vue-jsx/TsImport.vue new file mode 100644 index 00000000000000..c63923d51947fa --- /dev/null +++ b/packages/playground/vue-jsx/TsImport.vue @@ -0,0 +1,8 @@ + + + diff --git a/packages/playground/vue-jsx/TsImportFile.ts b/packages/playground/vue-jsx/TsImportFile.ts new file mode 100644 index 00000000000000..62761d5733b432 --- /dev/null +++ b/packages/playground/vue-jsx/TsImportFile.ts @@ -0,0 +1 @@ +export const foo = 'success' diff --git a/packages/playground/vue-jsx/__tests__/vue-jsx.spec.ts b/packages/playground/vue-jsx/__tests__/vue-jsx.spec.ts index 999fdc19af51ec..275c918684119d 100644 --- a/packages/playground/vue-jsx/__tests__/vue-jsx.spec.ts +++ b/packages/playground/vue-jsx/__tests__/vue-jsx.spec.ts @@ -9,6 +9,7 @@ test('should render', async () => { expect(await page.textContent('.src-import')).toMatch('5') expect(await page.textContent('.jsx-with-query')).toMatch('6') expect(await page.textContent('.other-ext')).toMatch('Other Ext') + expect(await page.textContent('.ts-import')).toMatch('success') }) test('should update', async () => { diff --git a/packages/playground/vue-jsx/main.jsx b/packages/playground/vue-jsx/main.jsx index e304e7788e49e7..f13e60c45367c0 100644 --- a/packages/playground/vue-jsx/main.jsx +++ b/packages/playground/vue-jsx/main.jsx @@ -7,6 +7,7 @@ import JsxSrcImport from './SrcImport.vue' import JsxSetupSyntax from './setup-syntax-jsx.vue' // eslint-disable-next-line import JsxWithQuery from './Query.jsx?query=true' +import TsImport from './TsImport.vue' function App() { return ( @@ -20,6 +21,7 @@ function App() { + ) } diff --git a/packages/playground/vue/Main.vue b/packages/playground/vue/Main.vue index 87319acdf6f736..c5f3d27402fda7 100644 --- a/packages/playground/vue/Main.vue +++ b/packages/playground/vue/Main.vue @@ -15,6 +15,7 @@
this should be red
+ @@ -33,6 +34,7 @@ import CustomBlock from './CustomBlock.vue' import SrcImport from './src-import/SrcImport.vue' import Slotted from './Slotted.vue' import ScanDep from './ScanDep.vue' +import TsImport from './TsImport.vue' import AsyncComponent from './AsyncComponent.vue' import ReactivityTransform from './ReactivityTransform.vue' import SetupImportTemplate from './setup-import-template/SetupImportTemplate.vue' diff --git a/packages/playground/vue/TsImport.vue b/packages/playground/vue/TsImport.vue new file mode 100644 index 00000000000000..986c383b2b9f4b --- /dev/null +++ b/packages/playground/vue/TsImport.vue @@ -0,0 +1,8 @@ + + + diff --git a/packages/playground/vue/TsImportFile.ts b/packages/playground/vue/TsImportFile.ts new file mode 100644 index 00000000000000..62761d5733b432 --- /dev/null +++ b/packages/playground/vue/TsImportFile.ts @@ -0,0 +1 @@ +export const foo = 'success' diff --git a/packages/playground/vue/__tests__/vue.spec.ts b/packages/playground/vue/__tests__/vue.spec.ts index 025c05f53e8688..0bce5d1e1a03f5 100644 --- a/packages/playground/vue/__tests__/vue.spec.ts +++ b/packages/playground/vue/__tests__/vue.spec.ts @@ -14,6 +14,10 @@ test('template/script latest syntax support', async () => { expect(await page.textContent('.syntax')).toBe('baz') }) +test('import ts with .js extension with lang="ts"', async () => { + expect(await page.textContent('.ts-import')).toBe('success') +}) + test('should remove comments in prod', async () => { expect(await page.innerHTML('.comments')).toBe(isBuild ? `` : ``) }) diff --git a/packages/plugin-vue/src/main.ts b/packages/plugin-vue/src/main.ts index d4417548e2e40c..1b24856be1ecab 100644 --- a/packages/plugin-vue/src/main.ts +++ b/packages/plugin-vue/src/main.ts @@ -211,6 +211,11 @@ export async function transformMain( code: resolvedCode, map: resolvedMap || { mappings: '' + }, + meta: { + vite: { + lang: descriptor.script?.lang || descriptor.scriptSetup?.lang || 'js' + } } } } diff --git a/packages/vite/src/node/plugins/resolve.ts b/packages/vite/src/node/plugins/resolve.ts index 1b59503a9d43ed..98a2cd8a9f776e 100644 --- a/packages/vite/src/node/plugins/resolve.ts +++ b/packages/vite/src/node/plugins/resolve.ts @@ -128,12 +128,19 @@ export function resolvePlugin(baseOptions: InternalResolveOptions): Plugin { const options: InternalResolveOptions = { isRequire, - ...baseOptions, - isFromTsImporter: isTsRequest(importer ?? ''), scan: resolveOpts?.scan ?? baseOptions.scan } + if (importer) { + if (isTsRequest(importer)) { + options.isFromTsImporter = true + } else { + const moduleLang = this.getModuleInfo(importer)?.meta?.vite?.lang + options.isFromTsImporter = moduleLang && isTsRequest(`.${moduleLang}`) + } + } + let res: string | PartialResolvedId | undefined // resolve pre-bundled deps requests, these could be resolved by diff --git a/packages/vite/src/node/utils.ts b/packages/vite/src/node/utils.ts index 32b783974dacaf..688e4c0f9cd44d 100644 --- a/packages/vite/src/node/utils.ts +++ b/packages/vite/src/node/utils.ts @@ -228,7 +228,7 @@ export const isJSRequest = (url: string): boolean => { const knownTsRE = /\.(ts|mts|cts|tsx)$/ const knownTsOutputRE = /\.(js|mjs|cjs|jsx)$/ -export const isTsRequest = (url: string) => knownTsRE.test(cleanUrl(url)) +export const isTsRequest = (url: string) => knownTsRE.test(url) export const isPossibleTsOutput = (url: string) => knownTsOutputRE.test(cleanUrl(url)) export function getPotentialTsSrcPaths(filePath: string) { From e5fe1c65203a3509e096baeed1ef176d21f93851 Mon Sep 17 00:00:00 2001 From: patak Date: Wed, 4 May 2022 18:35:58 +0200 Subject: [PATCH 123/175] fix: optimized processing folder renaming in win (fix #7939) (#8019) --- packages/vite/src/node/optimizer/index.ts | 23 ++++----- .../src/node/optimizer/registerMissing.ts | 8 ++-- packages/vite/src/node/utils.ts | 48 +++++++++++++++++++ 3 files changed, 61 insertions(+), 18 deletions(-) diff --git a/packages/vite/src/node/optimizer/index.ts b/packages/vite/src/node/optimizer/index.ts index 4e4fb5a8c895ae..03df61ae3e3ac2 100644 --- a/packages/vite/src/node/optimizer/index.ts +++ b/packages/vite/src/node/optimizer/index.ts @@ -13,7 +13,9 @@ import { normalizePath, writeFile, flattenId, - normalizeId + normalizeId, + removeDirSync, + renameDir } from '../utils' import { esbuildDepPlugin } from './esbuildDepPlugin' import { init, parse } from 'es-module-lexer' @@ -116,7 +118,7 @@ export interface DepOptimizationResult { * the page reload will be delayed until the next rerun so we need * to be able to discard the result */ - commit: () => void + commit: () => Promise cancel: () => void } @@ -194,7 +196,7 @@ export async function optimizeDeps( const result = await runOptimizeDeps(config, depsInfo) - result.commit() + await result.commit() return result.metadata } @@ -376,7 +378,7 @@ export async function runOptimizeDeps( metadata, commit() { // Write metadata file, delete `deps` folder and rename the `processing` folder to `deps` - commitProcessingDepsCacheSync() + return commitProcessingDepsCacheSync() }, cancel } @@ -529,16 +531,16 @@ export async function runOptimizeDeps( metadata, commit() { // Write metadata file, delete `deps` folder and rename the new `processing` folder to `deps` in sync - commitProcessingDepsCacheSync() + return commitProcessingDepsCacheSync() }, cancel } - function commitProcessingDepsCacheSync() { + async function commitProcessingDepsCacheSync() { // Processing is done, we can now replace the depsCacheDir with processingCacheDir // Rewire the file paths from the temporal processing dir to the final deps cache dir removeDirSync(depsCacheDir) - fs.renameSync(processingCacheDir, depsCacheDir) + await renameDir(processingCacheDir, depsCacheDir) } function cancel() { @@ -546,13 +548,6 @@ export async function runOptimizeDeps( } } -function removeDirSync(dir: string) { - if (fs.existsSync(dir)) { - const rmSync = fs.rmSync ?? fs.rmdirSync // TODO: Remove after support for Node 12 is dropped - rmSync(dir, { recursive: true }) - } -} - export async function findKnownImports( config: ResolvedConfig ): Promise { diff --git a/packages/vite/src/node/optimizer/registerMissing.ts b/packages/vite/src/node/optimizer/registerMissing.ts index ee4824389c202b..2262c7be96bb0a 100644 --- a/packages/vite/src/node/optimizer/registerMissing.ts +++ b/packages/vite/src/node/optimizer/registerMissing.ts @@ -189,8 +189,8 @@ export function createOptimizedDeps(server: ViteDevServer): OptimizedDeps { ) }) - const commitProcessing = () => { - processingResult.commit() + const commitProcessing = async () => { + await processingResult.commit() // While optimizeDeps is running, new missing deps may be discovered, // in which case they will keep being added to metadata.discovered @@ -240,7 +240,7 @@ export function createOptimizedDeps(server: ViteDevServer): OptimizedDeps { } if (!needsReload) { - commitProcessing() + await commitProcessing() if (!isDebugEnabled) { if (newDepsToLogHandle) clearTimeout(newDepsToLogHandle) @@ -270,7 +270,7 @@ export function createOptimizedDeps(server: ViteDevServer): OptimizedDeps { } ) } else { - commitProcessing() + await commitProcessing() if (!isDebugEnabled) { if (newDepsToLogHandle) clearTimeout(newDepsToLogHandle) diff --git a/packages/vite/src/node/utils.ts b/packages/vite/src/node/utils.ts index 688e4c0f9cd44d..d41dd6850ebb56 100644 --- a/packages/vite/src/node/utils.ts +++ b/packages/vite/src/node/utils.ts @@ -3,6 +3,7 @@ import colors from 'picocolors' import fs from 'fs' import os from 'os' import path from 'path' +import { promisify } from 'util' import { pathToFileURL, URL } from 'url' import { FS_PREFIX, @@ -522,6 +523,15 @@ export function copyDir(srcDir: string, destDir: string): void { } } +export function removeDirSync(dir: string) { + if (fs.existsSync(dir)) { + const rmSync = fs.rmSync ?? fs.rmdirSync // TODO: Remove after support for Node 12 is dropped + rmSync(dir, { recursive: true }) + } +} + +export const renameDir = isWindows ? promisify(gracefulRename) : fs.renameSync + export function ensureWatchedFile( watcher: FSWatcher, file: string | null, @@ -737,3 +747,41 @@ export function parseRequest(id: string): Record | null { } export const blankReplacer = (match: string) => ' '.repeat(match.length) + +// Based on node-graceful-fs + +// The ISC License +// Copyright (c) 2011-2022 Isaac Z. Schlueter, Ben Noordhuis, and Contributors +// https://github.com/isaacs/node-graceful-fs/blob/main/LICENSE + +// On Windows, A/V software can lock the directory, causing this +// to fail with an EACCES or EPERM if the directory contains newly +// created files. The original tried for up to 60 seconds, we only +// wait for 5 seconds, as a longer time would be seen as an error + +const GRACEFUL_RENAME_TIMEOUT = 5000 +function gracefulRename( + from: string, + to: string, + cb: (error: NodeJS.ErrnoException | null) => void +) { + const start = Date.now() + let backoff = 0 + fs.rename(from, to, function CB(er) { + if ( + er && + (er.code === 'EACCES' || er.code === 'EPERM') && + Date.now() - start < GRACEFUL_RENAME_TIMEOUT + ) { + setTimeout(function () { + fs.stat(to, function (stater, st) { + if (stater && stater.code === 'ENOENT') gracefulRename(from, to, CB) + else cb(er) + }) + }, backoff) + if (backoff < 100) backoff += 10 + return + } + if (cb) cb(er) + }) +} From 77865b44b2f69642ca106716f6208a812cab9c24 Mon Sep 17 00:00:00 2001 From: patak-dev Date: Wed, 4 May 2022 19:28:34 +0200 Subject: [PATCH 124/175] release: v2.9.8 --- 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 db8bf085dc04f6..3c967f289c1f34 100644 --- a/packages/vite/CHANGELOG.md +++ b/packages/vite/CHANGELOG.md @@ -1,3 +1,16 @@ +## 2.9.8 (2022-05-04) + +* fix: inline js and css paths for virtual html (#7993) ([d49e3fb](https://github.com/vitejs/vite/commit/d49e3fb)), closes [#7993](https://github.com/vitejs/vite/issues/7993) +* fix: only handle merge ssr.noExternal (#8003) ([642d65b](https://github.com/vitejs/vite/commit/642d65b)), closes [#8003](https://github.com/vitejs/vite/issues/8003) +* fix: optimized processing folder renaming in win (fix #7939) (#8019) ([e5fe1c6](https://github.com/vitejs/vite/commit/e5fe1c6)), closes [#7939](https://github.com/vitejs/vite/issues/7939) [#8019](https://github.com/vitejs/vite/issues/8019) +* fix(css): do not clean id when passing to postcss (fix #7822) (#7827) ([72f17f8](https://github.com/vitejs/vite/commit/72f17f8)), closes [#7822](https://github.com/vitejs/vite/issues/7822) [#7827](https://github.com/vitejs/vite/issues/7827) +* fix(css): var in image-set (#7921) ([e96b908](https://github.com/vitejs/vite/commit/e96b908)), closes [#7921](https://github.com/vitejs/vite/issues/7921) +* fix(ssr): allow ssrTransform to parse hashbang (#8005) ([6420ba0](https://github.com/vitejs/vite/commit/6420ba0)), closes [#8005](https://github.com/vitejs/vite/issues/8005) +* feat: import ts with .js in vue (#7998) ([9974094](https://github.com/vitejs/vite/commit/9974094)), closes [#7998](https://github.com/vitejs/vite/issues/7998) +* chore: remove maybeVirtualHtmlSet (#8010) ([e85164e](https://github.com/vitejs/vite/commit/e85164e)), closes [#8010](https://github.com/vitejs/vite/issues/8010) + + + ## 2.9.7 (2022-05-02) * chore: update license ([d58c030](https://github.com/vitejs/vite/commit/d58c030)) diff --git a/packages/vite/package.json b/packages/vite/package.json index 3720837d3a5afc..07d0025c449e75 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -1,6 +1,6 @@ { "name": "vite", - "version": "2.9.7", + "version": "2.9.8", "license": "MIT", "author": "Evan You", "description": "Native-ESM powered web dev build tool", From b0e9234251b723a3cfe37d9187dfd71c1a654e77 Mon Sep 17 00:00:00 2001 From: patak-dev Date: Wed, 4 May 2022 19:31:32 +0200 Subject: [PATCH 125/175] release: plugin-vue@2.3.2 --- packages/plugin-vue/CHANGELOG.md | 8 ++++++++ packages/plugin-vue/package.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/plugin-vue/CHANGELOG.md b/packages/plugin-vue/CHANGELOG.md index 135daffbfaaa67..4990d5fc10bd50 100644 --- a/packages/plugin-vue/CHANGELOG.md +++ b/packages/plugin-vue/CHANGELOG.md @@ -1,3 +1,11 @@ +## 2.3.2 (2022-05-04) + +* feat: import ts with .js in vue (#7998) ([9974094](https://github.com/vitejs/vite/commit/9974094)), closes [#7998](https://github.com/vitejs/vite/issues/7998) +* refactor(plugin-vue): remove querystring import (#7997) ([f3d15f1](https://github.com/vitejs/vite/commit/f3d15f1)), closes [#7997](https://github.com/vitejs/vite/issues/7997) +* chore(deps): update all non-major dependencies (#7780) ([eba9d05](https://github.com/vitejs/vite/commit/eba9d05)), closes [#7780](https://github.com/vitejs/vite/issues/7780) + + + ## 2.3.1 (2022-03-30) * chore(plugin-vue): revert #7527, lower vite peer dep ([447bbeb](https://github.com/vitejs/vite/commit/447bbeb)), closes [#7527](https://github.com/vitejs/vite/issues/7527) diff --git a/packages/plugin-vue/package.json b/packages/plugin-vue/package.json index 9f401ac7fa86b1..d9e1e0cc9c4ba1 100644 --- a/packages/plugin-vue/package.json +++ b/packages/plugin-vue/package.json @@ -1,6 +1,6 @@ { "name": "@vitejs/plugin-vue", - "version": "2.3.1", + "version": "2.3.2", "license": "MIT", "author": "Evan You", "files": [ From ba95a2a03ceeb68fe674082677f656ce50fe94d0 Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Thu, 5 May 2022 02:24:21 +0800 Subject: [PATCH 126/175] fix: handle optimize failure (#8006) --- packages/vite/src/node/optimizer/registerMissing.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/vite/src/node/optimizer/registerMissing.ts b/packages/vite/src/node/optimizer/registerMissing.ts index 2262c7be96bb0a..53cd7e981b1b61 100644 --- a/packages/vite/src/node/optimizer/registerMissing.ts +++ b/packages/vite/src/node/optimizer/registerMissing.ts @@ -296,7 +296,6 @@ export function createOptimizedDeps(server: ViteDevServer): OptimizedDeps { // Reset missing deps, let the server rediscover the dependencies metadata.discovered = {} - fullReload() } currentlyProcessing = false From 2b58cb3faaa8f0da983888d0bd1f0f2a3a34de56 Mon Sep 17 00:00:00 2001 From: yoho Date: Thu, 5 May 2022 02:45:48 +0800 Subject: [PATCH 127/175] fix: warn for unresolved css in html (#7911) --- packages/playground/html/index.html | 3 +++ packages/vite/src/node/plugins/html.ts | 29 ++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/packages/playground/html/index.html b/packages/playground/html/index.html index 7320ff2b097db0..783cad93172f7a 100644 --- a/packages/playground/html/index.html +++ b/packages/playground/html/index.html @@ -5,3 +5,6 @@

Hello

+ + + diff --git a/packages/vite/src/node/plugins/html.ts b/packages/vite/src/node/plugins/html.ts index bf3d662066630b..0223c351af6071 100644 --- a/packages/vite/src/node/plugins/html.ts +++ b/packages/vite/src/node/plugins/html.ts @@ -247,6 +247,7 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin { const s = new MagicString(html) const assetUrls: AttributeNode[] = [] const scriptUrls: ScriptAssetsUrl[] = [] + const styleUrls: ScriptAssetsUrl[] = [] let inlineModuleIndex = -1 let everyScriptIsAsync = true @@ -339,8 +340,13 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin { if (!isExcludedUrl(url)) { if (node.tag === 'link' && isCSSRequest(url)) { // CSS references, convert to import - js += `\nimport ${JSON.stringify(url)}` - shouldRemove = true + const importExpression = `\nimport ${JSON.stringify(url)}` + styleUrls.push({ + url, + start: node.loc.start.offset, + end: node.loc.end.offset + }) + js += importExpression } else { assetUrls.push(p) } @@ -470,6 +476,25 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin { } } + // ignore if its url can't be resolved + const resolvedStyleUrls = await Promise.all( + styleUrls.map(async (styleUrl) => ({ + ...styleUrl, + resolved: await this.resolve(styleUrl.url, id) + })) + ) + for (const { start, end, url, resolved } of resolvedStyleUrls) { + if (resolved == null) { + config.logger.warnOnce( + `\n${url} doesn't exist at build time, it will remain unchanged to be resolved at runtime` + ) + const importExpression = `\nimport ${JSON.stringify(url)}` + js = js.replace(importExpression, '') + } else { + s.remove(start, end) + } + } + processedHtml.set(id, s.toString()) // inject module preload polyfill only when configured and needed From 70f032f0d84df995a600f0a282ee736f8edef26e Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Wed, 4 May 2022 13:08:27 -0700 Subject: [PATCH 128/175] docs: clarify code comments in `optimize-missing-deps` (#7332) --- packages/playground/optimize-missing-deps/server.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/playground/optimize-missing-deps/server.js b/packages/playground/optimize-missing-deps/server.js index b9422feb622584..65675fe0feb589 100644 --- a/packages/playground/optimize-missing-deps/server.js +++ b/packages/playground/optimize-missing-deps/server.js @@ -25,10 +25,11 @@ async function createServer(root = process.cwd()) { let template = fs.readFileSync(resolve('index.html'), 'utf-8') template = await vite.transformIndexHtml(req.originalUrl, template) - // this will import missing deps nest built-in deps that should not be optimized + // `main.js` imports dependencies that are yet to be discovered and optimized, aka "missing" deps. + // Loading `main.js` in SSR should not trigger optimizing the "missing" deps const { name } = await vite.ssrLoadModule('./main.js') - // this will import missing deps that should be optimized correctly + // Loading `main.js` in the client should trigger optimizing the "missing" deps const appHtml = `
${name}
diff --git a/packages/playground/lib/vite.config.js b/packages/playground/lib/vite.config.js index 50cd188b1a40cc..72c040d38d6dcf 100644 --- a/packages/playground/lib/vite.config.js +++ b/packages/playground/lib/vite.config.js @@ -10,7 +10,7 @@ module.exports = { entry: path.resolve(__dirname, 'src/main.js'), name: 'MyLib', formats: ['es', 'umd', 'iife'], - fileName: (format) => `my-lib-custom-filename.${format}.js` + fileName: 'my-lib-custom-filename' } }, plugins: [ diff --git a/packages/playground/resolve-config/__tests__/resolve-config.spec.ts b/packages/playground/resolve-config/__tests__/resolve-config.spec.ts index 13ea5ea6f59a4f..cde329afde2f50 100644 --- a/packages/playground/resolve-config/__tests__/resolve-config.spec.ts +++ b/packages/playground/resolve-config/__tests__/resolve-config.spec.ts @@ -10,42 +10,45 @@ const fromTestDir = (...p: string[]) => path.resolve(testDir, ...p) const build = (configName: string) => { commandSync(`${viteBin} build`, { cwd: fromTestDir(configName) }) } -const getDistFile = (configName: string) => { - return fs.readFileSync(fromTestDir(`${configName}/dist/index.es.js`), 'utf8') +const getDistFile = (configName: string, extension: string) => { + return fs.readFileSync( + fromTestDir(`${configName}/dist/index.es.${extension}`), + 'utf8' + ) } if (isBuild) { it('loads vite.config.js', () => { build('js') - expect(getDistFile('js')).toContain('console.log(true)') + expect(getDistFile('js', 'mjs')).toContain('console.log(true)') }) it('loads vite.config.js with package#type module', () => { build('js-module') - expect(getDistFile('js-module')).toContain('console.log(true)') + expect(getDistFile('js-module', 'js')).toContain('console.log(true)') }) it('loads vite.config.cjs', () => { build('cjs') - expect(getDistFile('cjs')).toContain('console.log(true)') + expect(getDistFile('cjs', 'mjs')).toContain('console.log(true)') }) it('loads vite.config.cjs with package#type module', () => { build('cjs-module') - expect(getDistFile('cjs-module')).toContain('console.log(true)') + expect(getDistFile('cjs-module', 'js')).toContain('console.log(true)') }) it('loads vite.config.mjs', () => { build('mjs') - expect(getDistFile('mjs')).toContain('console.log(true)') + expect(getDistFile('mjs', 'mjs')).toContain('console.log(true)') }) it('loads vite.config.mjs with package#type module', () => { build('mjs-module') - expect(getDistFile('mjs-module')).toContain('console.log(true)') + expect(getDistFile('mjs-module', 'js')).toContain('console.log(true)') }) it('loads vite.config.ts', () => { build('ts') - expect(getDistFile('ts')).toContain('console.log(true)') + expect(getDistFile('ts', 'mjs')).toContain('console.log(true)') }) it('loads vite.config.ts with package#type module', () => { build('ts-module') - expect(getDistFile('ts-module')).toContain('console.log(true)') + expect(getDistFile('ts-module', 'js')).toContain('console.log(true)') }) } else { // this test doesn't support serve mode diff --git a/packages/playground/vue-lib/vite.config.lib.ts b/packages/playground/vue-lib/vite.config.lib.ts index a888382d008a8c..0cc082c7ceea85 100644 --- a/packages/playground/vue-lib/vite.config.lib.ts +++ b/packages/playground/vue-lib/vite.config.lib.ts @@ -10,7 +10,7 @@ export default defineConfig({ entry: path.resolve(__dirname, 'src-lib/index.ts'), name: 'MyVueLib', formats: ['es'], - fileName: (format) => `my-vue-lib.${format}.js` + fileName: 'my-vue-lib' }, rollupOptions: { external: ['vue'], diff --git a/packages/vite/src/node/__tests__/build.spec.ts b/packages/vite/src/node/__tests__/build.spec.ts index b3ef37e64fd28e..578e3a4c68ff8d 100644 --- a/packages/vite/src/node/__tests__/build.spec.ts +++ b/packages/vite/src/node/__tests__/build.spec.ts @@ -1,6 +1,13 @@ +import type { LibraryFormats, LibraryOptions } from '../build' import { resolveLibFilename } from '../build' import { resolve } from 'path' +type FormatsToFileNames = [LibraryFormats, string][] +const baseLibOptions: LibraryOptions = { + fileName: 'my-lib', + entry: 'mylib.js' +} + describe('resolveLibFilename', () => { test('custom filename function', () => { const filename = resolveLibFilename( @@ -25,7 +32,7 @@ describe('resolveLibFilename', () => { resolve(__dirname, 'packages/name') ) - expect(filename).toBe('custom-filename.es.js') + expect(filename).toBe('custom-filename.es.mjs') }) test('package name as filename', () => { @@ -37,7 +44,7 @@ describe('resolveLibFilename', () => { resolve(__dirname, 'packages/name') ) - expect(filename).toBe('mylib.es.js') + expect(filename).toBe('mylib.es.mjs') }) test('custom filename and no package name', () => { @@ -50,7 +57,7 @@ describe('resolveLibFilename', () => { resolve(__dirname, 'packages/noname') ) - expect(filename).toBe('custom-filename.es.js') + expect(filename).toBe('custom-filename.es.mjs') }) test('missing filename', () => { @@ -64,4 +71,42 @@ describe('resolveLibFilename', () => { ) }).toThrow() }) + + test('commonjs package extensions', () => { + const formatsToFilenames: FormatsToFileNames = [ + ['es', 'my-lib.es.mjs'], + ['umd', 'my-lib.umd.js'], + ['cjs', 'my-lib.cjs.js'], + ['iife', 'my-lib.iife.js'] + ] + + for (const [format, expectedFilename] of formatsToFilenames) { + const filename = resolveLibFilename( + baseLibOptions, + format, + resolve(__dirname, 'packages/noname') + ) + + expect(filename).toBe(expectedFilename) + } + }) + + test('module package extensions', () => { + const formatsToFilenames: FormatsToFileNames = [ + ['es', 'my-lib.es.js'], + ['umd', 'my-lib.umd.cjs'], + ['cjs', 'my-lib.cjs.cjs'], + ['iife', 'my-lib.iife.js'] + ] + + for (const [format, expectedFilename] of formatsToFilenames) { + const filename = resolveLibFilename( + baseLibOptions, + format, + resolve(__dirname, 'packages/module') + ) + + expect(filename).toBe(expectedFilename) + } + }) }) diff --git a/packages/vite/src/node/__tests__/packages/module/package.json b/packages/vite/src/node/__tests__/packages/module/package.json new file mode 100644 index 00000000000000..3dbc1ca591c055 --- /dev/null +++ b/packages/vite/src/node/__tests__/packages/module/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/packages/vite/src/node/build.ts b/packages/vite/src/node/build.ts index f584f007f2df5e..d4d4085bb829ed 100644 --- a/packages/vite/src/node/build.ts +++ b/packages/vite/src/node/build.ts @@ -38,6 +38,7 @@ import type { DepOptimizationMetadata } from './optimizer' import { getDepsCacheDir, findKnownImports } from './optimizer' import { assetImportMetaUrlPlugin } from './plugins/assetImportMetaUrl' import { loadFallbackPlugin } from './plugins/loadFallback' +import type { PackageData } from './packages' import { watchPackageDataPlugin } from './packages' import { ensureWatchPlugin } from './plugins/ensureWatch' @@ -563,9 +564,11 @@ function prepareOutDir( } } -function getPkgName(root: string) { - const { name } = JSON.parse(lookupFile(root, ['package.json']) || `{}`) +function getPkgJson(root: string): PackageData['data'] { + return JSON.parse(lookupFile(root, ['package.json']) || `{}`) +} +function getPkgName(name: string) { return name?.startsWith('@') ? name.split('/')[1] : name } @@ -578,14 +581,23 @@ export function resolveLibFilename( return libOptions.fileName(format) } - const name = libOptions.fileName || getPkgName(root) + const packageJson = getPkgJson(root) + const name = libOptions.fileName || getPkgName(packageJson.name) if (!name) throw new Error( 'Name in package.json is required if option "build.lib.fileName" is not provided.' ) - return `${name}.${format}.js` + let extension: string + + if (packageJson?.type === 'module') { + extension = format === 'cjs' || format === 'umd' ? 'cjs' : 'js' + } else { + extension = format === 'es' ? 'mjs' : 'js' + } + + return `${name}.${format}.${extension}` } function resolveBuildOutputs( diff --git a/packages/vite/src/node/packages.ts b/packages/vite/src/node/packages.ts index 1424977164de85..1fb2e7b4a21c06 100644 --- a/packages/vite/src/node/packages.ts +++ b/packages/vite/src/node/packages.ts @@ -22,6 +22,8 @@ export interface PackageData { getResolvedCache: (key: string, targetWeb: boolean) => string | undefined data: { [field: string]: any + name: string + type: string version: string main: string module: string From 0e67fe8ae23d4e21db578d9a18a63861e1cdade0 Mon Sep 17 00:00:00 2001 From: yoho Date: Fri, 6 May 2022 04:27:05 +0800 Subject: [PATCH 135/175] fix: vite client types (#7877) Co-authored-by: Bjorn Lu --- docs/guide/env-and-mode.md | 8 ++++++++ packages/vite/client.d.ts | 1 - 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/guide/env-and-mode.md b/docs/guide/env-and-mode.md index b2b1264e85a8e4..d5f45ea1158808 100644 --- a/docs/guide/env-and-mode.md +++ b/docs/guide/env-and-mode.md @@ -81,6 +81,14 @@ interface ImportMeta { } ``` +If your code relies on types from browser environments such as [DOM](https://github.com/microsoft/TypeScript/blob/main/lib/lib.dom.d.ts) and [WebWorker](https://github.com/microsoft/TypeScript/blob/main/lib/lib.webworker.d.ts), you can update the [lib](https://www.typescriptlang.org/tsconfig#lib) field in `tsconfig.json`. + +```json +{ + "lib": ["WebWorker"] +} +``` + ## Modes By default, the dev server (`dev` command) runs in `development` mode and the `build` command run in `production` mode. diff --git a/packages/vite/client.d.ts b/packages/vite/client.d.ts index aaac1ea986251d..af8e6a6f9d1494 100644 --- a/packages/vite/client.d.ts +++ b/packages/vite/client.d.ts @@ -1,4 +1,3 @@ -/// /// // CSS modules From 95eb45b15fa66b8e9707adfbed315d4a57d5c5ed Mon Sep 17 00:00:00 2001 From: Jonas <30421456+jonaskuske@users.noreply.github.com> Date: Thu, 5 May 2022 22:29:14 +0200 Subject: [PATCH 136/175] feat: allow any JS identifier in define, not ASCII-only (#5972) --- docs/config/index.md | 2 +- packages/playground/define/__tests__/define.spec.ts | 8 ++++++++ packages/playground/define/index.html | 13 +++++++++++++ packages/playground/define/vite.config.js | 6 ++++-- packages/vite/src/node/plugins/define.ts | 12 +++++++----- 5 files changed, 33 insertions(+), 8 deletions(-) diff --git a/docs/config/index.md b/docs/config/index.md index db2dc932efbf30..5862419405aa89 100644 --- a/docs/config/index.md +++ b/docs/config/index.md @@ -164,7 +164,7 @@ export default defineConfig(({ command, mode }) => { - 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`). + - Replacements are performed only when the match isn't surrounded by other letters, numbers, `_` or `$`. ::: warning Because it's implemented as straightforward text replacements without any syntax analysis, we recommend using `define` for CONSTANTS only. diff --git a/packages/playground/define/__tests__/define.spec.ts b/packages/playground/define/__tests__/define.spec.ts index 709f7a935dc8c1..5d9707e70b47ba 100644 --- a/packages/playground/define/__tests__/define.spec.ts +++ b/packages/playground/define/__tests__/define.spec.ts @@ -20,6 +20,14 @@ test('string', async () => { expect(await page.textContent('.spread-array')).toBe( JSON.stringify([...defines.__STRING__]) ) + expect(await page.textContent('.dollar-identifier')).toBe( + String(defines.$DOLLAR) + ) + expect(await page.textContent('.unicode-identifier')).toBe( + String(defines.ÖUNICODE_LETTERɵ) + ) + expect(await page.textContent('.no-identifier-substring')).toBe(String(true)) + expect(await page.textContent('.no-property')).toBe(String(true)) // html would't need to define replacement expect(await page.textContent('.exp-define')).toBe('__EXP__') expect(await page.textContent('.import-json')).toBe('__EXP__') diff --git a/packages/playground/define/index.html b/packages/playground/define/index.html index da78d192216b11..c89a3fe02218ff 100644 --- a/packages/playground/define/index.html +++ b/packages/playground/define/index.html @@ -9,6 +9,10 @@

Define

process as property:

spread object:

spread array:

+

dollar identifier:

+

unicode identifier:

+

no property:

+

no identifier substring:

define variable in html: __EXP__

import json:

@@ -28,6 +32,15 @@

Define

}) ) text('.spread-array', JSON.stringify([...`"${__STRING__}"`])) + text('.dollar-identifier', $DOLLAR) + text('.unicode-identifier', ÖUNICODE_LETTERɵ) + + // make sure these kinds of use are NOT replaced: + const obj = { [`${'_'}_EXP__`]: true } + text('.no-property', obj.__EXP__) + + window[`${'_'}_EXP__SUBSTR__`] = true + text('.no-identifier-substring', __EXP__SUBSTR__) import dataJson from './data.json' text('.import-json', dataJson.foo) diff --git a/packages/playground/define/vite.config.js b/packages/playground/define/vite.config.js index 848abd09322df6..88173fe654b58d 100644 --- a/packages/playground/define/vite.config.js +++ b/packages/playground/define/vite.config.js @@ -15,7 +15,9 @@ module.exports = { } } }, - __VAR_NAME__: false, - 'process.env.SOMEVAR': '"SOMEVAR"' + 'process.env.SOMEVAR': '"SOMEVAR"', + $DOLLAR: 456, + ÖUNICODE_LETTERɵ: 789, + __VAR_NAME__: false } } diff --git a/packages/vite/src/node/plugins/define.ts b/packages/vite/src/node/plugins/define.ts index 19ca28b34433a0..ca0f446cc1f58e 100644 --- a/packages/vite/src/node/plugins/define.ts +++ b/packages/vite/src/node/plugins/define.ts @@ -68,16 +68,18 @@ export function definePlugin(config: ResolvedConfig): Plugin { const replacementsKeys = Object.keys(replacements) const pattern = replacementsKeys.length ? new RegExp( - // Do not allow preceding '.', but do allow preceding '...' for spread operations - '(? { return str.replace(/[-[\]/{}()*+?.\\^$|]/g, '\\$&') }) .join('|') + - // prevent trailing assignments - ')\\b(?!\\s*?=[^=])', - 'g' + // Mustn't be followed by a char that can be part of an identifier + // or an assignment (but allow equality operators) + ')(?![\\p{L}\\p{N}_$]|\\s*?=[^=])', + 'gu' ) : null From c7eeb8d69253d16dc9413d59cc13e45977a8c105 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Fri, 6 May 2022 14:07:41 +0800 Subject: [PATCH 137/175] chore: remove redundant pnpm version in ci (#8039) --- .github/workflows/ci.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4818124be2430f..9768ca4ebc3df2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,8 +47,6 @@ jobs: - name: Install pnpm uses: pnpm/action-setup@v2 - with: - version: 6 - name: Set node version to ${{ matrix.node_version }} uses: actions/setup-node@v3 @@ -85,8 +83,6 @@ jobs: - name: Install pnpm uses: pnpm/action-setup@v2 - with: - version: 6 - name: Set node version to 16 uses: actions/setup-node@v3 From 63cd53d2480e40db717aff78966240eb6482aba4 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Fri, 6 May 2022 16:00:31 +0800 Subject: [PATCH 138/175] fix: use Vitest for unit testing, clean regex bug (#8040) --- .eslintrc.cjs | 4 +- .github/workflows/ci.yml | 3 + CONTRIBUTING.md | 14 ++- jest.config.ts | 4 +- package.json | 8 +- packages/create-vite/__tests__/cli.spec.ts | 1 + .../src/jsx-runtime/babel-restore-jsx.spec.ts | 1 + .../src/jsx-runtime/restore-jsx.spec.ts | 1 + .../vite/src/node/__tests__/asset.spec.ts | 1 + .../vite/src/node/__tests__/build.spec.ts | 1 + .../src/node/__tests__/cleanString.spec.ts | Bin 4284 -> 4756 bytes .../vite/src/node/__tests__/config.spec.ts | 1 + packages/vite/src/node/__tests__/dev.spec.ts | 1 + .../src/node/__tests__/plugins/css.spec.ts | 3 +- .../src/node/__tests__/plugins/define.spec.ts | 1 + .../src/node/__tests__/plugins/import.spec.ts | 1 + packages/vite/src/node/__tests__/scan.spec.ts | 1 + .../vite/src/node/__tests__/utils.spec.ts | 1 + packages/vite/src/node/cleanString.ts | 9 +- .../server/__tests__/pluginContainer.spec.ts | 1 + .../node/server/__tests__/search-root.spec.ts | 1 + .../node/ssr/__tests__/ssrExternal.spec.ts | 1 + .../ssr/__tests__/ssrModuleLoader.spec.ts | 3 +- .../node/ssr/__tests__/ssrTransform.spec.ts | 1 + pnpm-lock.yaml | 97 ++++++++++++++++++ vitest.config.ts | 15 +++ 26 files changed, 160 insertions(+), 15 deletions(-) create mode 100644 vitest.config.ts diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 48a0bd7773b0d7..5e00df0d89e1e0 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -63,7 +63,7 @@ module.exports = defineConfig({ 'node/no-extraneous-import': [ 'error', { - allowModules: ['vite', 'less', 'sass'] + allowModules: ['vite', 'less', 'sass', 'vitest'] } ], 'node/no-extraneous-require': [ @@ -103,7 +103,7 @@ module.exports = defineConfig({ } }, { - files: ['packages/vite/types/**'], + files: ['packages/vite/types/**', '*.spec.ts'], rules: { 'node/no-extraneous-import': 'off' } diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9768ca4ebc3df2..5173da859417be 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -66,6 +66,9 @@ jobs: - name: Build plugin-react run: pnpm run build-plugin-react + - name: Test unit + run: pnpm run test-unit + - name: Test serve run: pnpm run test-serve -- --runInBand diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 621f8de145835f..40d2bb28605167 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -67,13 +67,15 @@ And re-run `pnpm install` to link the package. ## Running Tests +### Integration Tests + Each package under `packages/playground/` contains a `__tests__` directory. The tests are run using [Jest](https://jestjs.io/) + [Playwright](https://playwright.dev/) with custom integrations to make writing tests simple. The detailed setup is inside `jest.config.js` and `scripts/jest*` files. Before running the tests, make sure that [Vite has been built](#repo-setup). On Windows, you may want to [activate Developer Mode](https://docs.microsoft.com/en-us/windows/apps/get-started/enable-your-device-for-development) to solve [issues with symlink creation for non-admins](https://github.com/vitejs/vite/issues/7390). Also you may want to [set git `core.symlinks` to `true` to solve issues with symlinks in git](https://github.com/vitejs/vite/issues/5242). -Each test can be run under either dev server mode or build mode. +Each integration test can be run under either dev server mode or build mode. -- `pnpm test` by default runs every test in both serve and build mode. +- `pnpm test` by default runs every integration test in both serve and build mode, and also unit tests. - `pnpm run test-serve` runs tests only under serve mode. This is just calling `jest` so you can pass any Jest flags to this command. Since Jest will attempt to run tests in parallel, if your machine has many cores this may cause flaky test failures with multiple Playwright instances running at the same time. You can force the tests to run in series with `pnpm run test-serve -- --runInBand`. @@ -83,6 +85,14 @@ Each test can be run under either dev server mode or build mode. Note package matching is not available for the `pnpm test` script, which always runs all tests. +### Unit Tests + +Other than tests under `packages/playground/` for integration tests, packages might contains unit tests under their `__tests__` directory. Unit tests are powered by [Vitest](https://vitest.dev/). The detailed config is inside `vitest.config.ts` files. + +- `pnpm run test-unit` runs unit tests under each package. + +- You can also use `pnpm run test-unit -- [match]` to run related tests. + ### Test Env and Helpers Inside playground tests, a global `page` object is automatically available, which is a Playwright [`Page`](https://playwright.dev/docs/api/class-page) instance that has already navigated to the served page of the current playground. So writing a test is as simple as: diff --git a/jest.config.ts b/jest.config.ts index 11663af4e08107..941fccbae2af36 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -3,9 +3,7 @@ import type { Config } from '@jest/types' const config: Config.InitialOptions = { preset: 'ts-jest', - testMatch: process.env.VITE_TEST_BUILD - ? ['**/playground/**/*.spec.[jt]s?(x)'] - : ['**/*.spec.[jt]s?(x)'], + testMatch: ['**/playground/**/*.spec.[jt]s?(x)'], testTimeout: process.env.CI ? 50000 : 20000, globalSetup: './scripts/jestGlobalSetup.cjs', globalTeardown: './scripts/jestGlobalTeardown.cjs', diff --git a/package.json b/package.json index 269f1bb99cb826..843b6a4e030e39 100644 --- a/package.json +++ b/package.json @@ -16,10 +16,11 @@ "preinstall": "npx only-allow pnpm", "format": "prettier --write .", "lint": "eslint packages/*/{src,types}/**", - "test": "run-s test-serve test-build", + "test": "run-s test-serve test-build test-unit", "test-serve": "jest", - "debug-serve": "cross-env VITE_DEBUG_SERVE=1 node --inspect-brk ./node_modules/.bin/jest", "test-build": "cross-env VITE_TEST_BUILD=1 jest", + "test-unit": "vitest run", + "debug-serve": "cross-env VITE_DEBUG_SERVE=1 node --inspect-brk ./node_modules/.bin/jest", "debug-build": "cross-env VITE_TEST_BUILD=1 VITE_PRESERVE_BUILD_ARTIFACTS=1 node --inspect-brk ./node_modules/.bin/jest", "docs": "vitepress dev docs", "build-docs": "vitepress build docs", @@ -68,7 +69,8 @@ "ts-node": "^10.4.0", "typescript": "~4.5.4", "vite": "workspace:*", - "vitepress": "^0.22.3" + "vitepress": "^0.22.3", + "vitest": "^0.10.4" }, "simple-git-hooks": { "pre-commit": "pnpm exec lint-staged --concurrent false", diff --git a/packages/create-vite/__tests__/cli.spec.ts b/packages/create-vite/__tests__/cli.spec.ts index c52998172149e6..fbfb606f486885 100644 --- a/packages/create-vite/__tests__/cli.spec.ts +++ b/packages/create-vite/__tests__/cli.spec.ts @@ -3,6 +3,7 @@ import type { ExecaSyncReturnValue, SyncOptions } from 'execa' import { commandSync } from 'execa' import { mkdirpSync, readdirSync, remove, writeFileSync } from 'fs-extra' import { join } from 'path' +import { test, expect, beforeAll, afterEach } from 'vitest' const CLI_PATH = join(__dirname, '..') diff --git a/packages/plugin-react/src/jsx-runtime/babel-restore-jsx.spec.ts b/packages/plugin-react/src/jsx-runtime/babel-restore-jsx.spec.ts index 59d6661bedd11b..391007f68c1329 100644 --- a/packages/plugin-react/src/jsx-runtime/babel-restore-jsx.spec.ts +++ b/packages/plugin-react/src/jsx-runtime/babel-restore-jsx.spec.ts @@ -1,5 +1,6 @@ import babelRestoreJSX from './babel-restore-jsx' import * as babel from '@babel/core' +import { describe, it, expect } from 'vitest' function jsx(code: string) { return babel.transform(code, { diff --git a/packages/plugin-react/src/jsx-runtime/restore-jsx.spec.ts b/packages/plugin-react/src/jsx-runtime/restore-jsx.spec.ts index c216e99bc3480d..4f6a34ee60d915 100644 --- a/packages/plugin-react/src/jsx-runtime/restore-jsx.spec.ts +++ b/packages/plugin-react/src/jsx-runtime/restore-jsx.spec.ts @@ -1,5 +1,6 @@ import { restoreJSX } from './restore-jsx' import * as babel from '@babel/core' +import { describe, it, expect } from 'vitest' async function jsx(sourceCode: string) { const [ast] = await restoreJSX(babel, sourceCode, 'test.js') diff --git a/packages/vite/src/node/__tests__/asset.spec.ts b/packages/vite/src/node/__tests__/asset.spec.ts index 6e6b969bcbd38c..8727aa6485eb26 100644 --- a/packages/vite/src/node/__tests__/asset.spec.ts +++ b/packages/vite/src/node/__tests__/asset.spec.ts @@ -1,3 +1,4 @@ +import { describe, test, expect } from 'vitest' import { assetFileNamesToFileName, getAssetHash } from '../plugins/asset' describe('getAssetHash', () => { diff --git a/packages/vite/src/node/__tests__/build.spec.ts b/packages/vite/src/node/__tests__/build.spec.ts index 578e3a4c68ff8d..b49847f1d955a4 100644 --- a/packages/vite/src/node/__tests__/build.spec.ts +++ b/packages/vite/src/node/__tests__/build.spec.ts @@ -1,6 +1,7 @@ import type { LibraryFormats, LibraryOptions } from '../build' import { resolveLibFilename } from '../build' import { resolve } from 'path' +import { describe, test, expect } from 'vitest' type FormatsToFileNames = [LibraryFormats, string][] const baseLibOptions: LibraryOptions = { diff --git a/packages/vite/src/node/__tests__/cleanString.spec.ts b/packages/vite/src/node/__tests__/cleanString.spec.ts index f307c4816b7cd31bdd579b94fab09618e0af1bdb..99ecbcaad444023d10ed467f6cd9b2794fa935bd 100644 GIT binary patch delta 402 zcmdm^I7M|rmP%%BL4Hw*LbXCkYH^8fINqMQ|F)_v38sYgx*{MY}!5N7~sVNYS zCQw2vCPo89X+YJ52KgY1sz=AE$7-wBC`HF9#cC_n#3V$=#U#XP$0UF?>wwfk+#3_4 zmz!FW2&75{igF-kXlm-Gb15h!Og_&fJNX{BOuc7bPG(+ea9(0TaYlZLMgmY$K|u*j if>_DXKy6@v-#~q+LqHBn(B!Js { test('handles configs with different alias schemas', () => { diff --git a/packages/vite/src/node/__tests__/dev.spec.ts b/packages/vite/src/node/__tests__/dev.spec.ts index 3eefd7b4b903c1..cdb0fc123f4b4f 100644 --- a/packages/vite/src/node/__tests__/dev.spec.ts +++ b/packages/vite/src/node/__tests__/dev.spec.ts @@ -1,4 +1,5 @@ import { resolveConfig } from '..' +import { describe, test, expect } from 'vitest' describe('resolveBuildOptions in dev', () => { test('build.rollupOptions should not have input in lib', async () => { diff --git a/packages/vite/src/node/__tests__/plugins/css.spec.ts b/packages/vite/src/node/__tests__/plugins/css.spec.ts index e0d1f04a6510b2..eeacaf482b0c31 100644 --- a/packages/vite/src/node/__tests__/plugins/css.spec.ts +++ b/packages/vite/src/node/__tests__/plugins/css.spec.ts @@ -2,6 +2,7 @@ import { cssUrlRE, cssPlugin, hoistAtRules } from '../../plugins/css' import { resolveConfig } from '../../config' import fs from 'fs' import path from 'path' +import { describe, vi, test, expect } from 'vitest' describe('search css url function', () => { test('some spaces before it', () => { @@ -69,7 +70,7 @@ describe('css path resolutions', () => { await buildStart.call({}) - const mockFs = jest + const mockFs = vi .spyOn(fs, 'readFile') // @ts-ignore jest.spyOn not recognize overrided `fs.readFile` definition. .mockImplementationOnce((p, encoding, callback) => { diff --git a/packages/vite/src/node/__tests__/plugins/define.spec.ts b/packages/vite/src/node/__tests__/plugins/define.spec.ts index 9a65f8f3a51cea..b9acc81cb790d5 100644 --- a/packages/vite/src/node/__tests__/plugins/define.spec.ts +++ b/packages/vite/src/node/__tests__/plugins/define.spec.ts @@ -1,3 +1,4 @@ +import { describe, test, expect } from 'vitest' import { definePlugin } from '../../plugins/define' import { resolveConfig } from '../../config' diff --git a/packages/vite/src/node/__tests__/plugins/import.spec.ts b/packages/vite/src/node/__tests__/plugins/import.spec.ts index f0341e81b50f3c..e232702d57d354 100644 --- a/packages/vite/src/node/__tests__/plugins/import.spec.ts +++ b/packages/vite/src/node/__tests__/plugins/import.spec.ts @@ -1,3 +1,4 @@ +import { describe, test, expect } from 'vitest' import { transformCjsImport } from '../../plugins/importAnalysis' describe('transformCjsImport', () => { diff --git a/packages/vite/src/node/__tests__/scan.spec.ts b/packages/vite/src/node/__tests__/scan.spec.ts index db11bcc45b284c..8d5a275fca0292 100644 --- a/packages/vite/src/node/__tests__/scan.spec.ts +++ b/packages/vite/src/node/__tests__/scan.spec.ts @@ -1,5 +1,6 @@ import { scriptRE, commentRE, importsRE } from '../optimizer/scan' import { multilineCommentsRE, singlelineCommentsRE } from '../utils' +import { describe, test, expect } from 'vitest' describe('optimizer-scan:script-test', () => { const scriptContent = `import { defineComponent } from 'vue' diff --git a/packages/vite/src/node/__tests__/utils.spec.ts b/packages/vite/src/node/__tests__/utils.spec.ts index 1162105c3f19c7..29fd53f3c9a32e 100644 --- a/packages/vite/src/node/__tests__/utils.spec.ts +++ b/packages/vite/src/node/__tests__/utils.spec.ts @@ -4,6 +4,7 @@ import { isWindows, resolveHostname } from '../utils' +import { describe, test, expect } from 'vitest' describe('injectQuery', () => { if (isWindows) { diff --git a/packages/vite/src/node/cleanString.ts b/packages/vite/src/node/cleanString.ts index 9b9ef656f4e017..d990ab75f15d7c 100644 --- a/packages/vite/src/node/cleanString.ts +++ b/packages/vite/src/node/cleanString.ts @@ -5,6 +5,7 @@ import { multilineCommentsRE, singlelineCommentsRE } from './utils' // /`([^`\$\{\}]|\$\{(`|\g<1>)*\})*`/g can match nested string template // but js not support match expression(\g<0>). so clean string template(`...`) in other ways. const stringsRE = /"([^"\r\n]|(?<=\\)")*"|'([^'\r\n]|(?<=\\)')*'/g +const regexRE = /\/.*?(? `${s[0]}${'\0'.repeat(s.length - 2)}${s[0]}` export function emptyString(raw: string): string { - let res = raw.replace(cleanerRE, (s: string) => - s[0] === '/' ? blankReplacer(s) : stringBlankReplacer(s) - ) + let res = raw + .replace(cleanerRE, (s: string) => + s[0] === '/' ? blankReplacer(s) : stringBlankReplacer(s) + ) + .replace(regexRE, (s) => stringBlankReplacer(s)) let lastEnd = 0 let start = 0 diff --git a/packages/vite/src/node/server/__tests__/pluginContainer.spec.ts b/packages/vite/src/node/server/__tests__/pluginContainer.spec.ts index 9fbd07e90aa089..ab0555ae7982e9 100644 --- a/packages/vite/src/node/server/__tests__/pluginContainer.spec.ts +++ b/packages/vite/src/node/server/__tests__/pluginContainer.spec.ts @@ -4,6 +4,7 @@ import type { Plugin } from '../../plugin' import { ModuleGraph } from '../moduleGraph' import type { PluginContainer } from '../pluginContainer' import { createPluginContainer } from '../pluginContainer' +import { describe, it, expect, beforeEach } from 'vitest' let resolveId: (id: string) => any let moduleGraph: ModuleGraph diff --git a/packages/vite/src/node/server/__tests__/search-root.spec.ts b/packages/vite/src/node/server/__tests__/search-root.spec.ts index 7322768286809e..ff9366e8791534 100644 --- a/packages/vite/src/node/server/__tests__/search-root.spec.ts +++ b/packages/vite/src/node/server/__tests__/search-root.spec.ts @@ -1,5 +1,6 @@ import { searchForWorkspaceRoot } from '../searchRoot' import { resolve } from 'path' +import { describe, test, expect } from 'vitest' describe('searchForWorkspaceRoot', () => { test('lerna', () => { diff --git a/packages/vite/src/node/ssr/__tests__/ssrExternal.spec.ts b/packages/vite/src/node/ssr/__tests__/ssrExternal.spec.ts index ad16534b088e2b..5fb51093405250 100644 --- a/packages/vite/src/node/ssr/__tests__/ssrExternal.spec.ts +++ b/packages/vite/src/node/ssr/__tests__/ssrExternal.spec.ts @@ -1,4 +1,5 @@ import { stripNesting } from '../ssrExternal' +import { test, expect } from 'vitest' test('stripNesting', async () => { expect(stripNesting(['c', 'p1>c1', 'p2 > c2'])).toEqual(['c', 'c1', 'c2']) diff --git a/packages/vite/src/node/ssr/__tests__/ssrModuleLoader.spec.ts b/packages/vite/src/node/ssr/__tests__/ssrModuleLoader.spec.ts index 6a45a2b70509d0..93a04734840d31 100644 --- a/packages/vite/src/node/ssr/__tests__/ssrModuleLoader.spec.ts +++ b/packages/vite/src/node/ssr/__tests__/ssrModuleLoader.spec.ts @@ -1,12 +1,13 @@ import { resolve } from 'path' import { createServer } from '../../index' +import { test, vi, expect } from 'vitest' const badjs = resolve(__dirname, './fixtures/ssrModuleLoader-bad.js') const THROW_MESSAGE = 'it is an expected error' test('always throw error when evaluating an wrong SSR module', async () => { const viteServer = await createServer() - const spy = jest.spyOn(console, 'error').mockImplementation(() => {}) + const spy = vi.spyOn(console, 'error').mockImplementation(() => {}) const expectedErrors = [] for (const i of [0, 1]) { try { diff --git a/packages/vite/src/node/ssr/__tests__/ssrTransform.spec.ts b/packages/vite/src/node/ssr/__tests__/ssrTransform.spec.ts index 0e9181214c2b82..9c1fdea5939793 100644 --- a/packages/vite/src/node/ssr/__tests__/ssrTransform.spec.ts +++ b/packages/vite/src/node/ssr/__tests__/ssrTransform.spec.ts @@ -1,6 +1,7 @@ import { transformWithEsbuild } from '../../plugins/esbuild' import { traverseHtml } from '../../plugins/html' import { ssrTransform } from '../ssrTransform' +import { test, expect } from 'vitest' test('default import', async () => { expect( diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d3aea697843c5b..3f15dbb27aae88 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -45,6 +45,7 @@ importers: typescript: ~4.5.4 vite: workspace:* vitepress: ^0.22.3 + vitest: ^0.10.4 devDependencies: '@microsoft/api-extractor': 7.23.0 '@types/fs-extra': 9.0.13 @@ -81,6 +82,7 @@ importers: typescript: 4.5.4 vite: link:packages/vite vitepress: 0.22.3 + vitest: 0.10.4 packages/create-vite: specifiers: @@ -2579,6 +2581,16 @@ packages: resolution: {integrity: sha512-+euflG6ygo4bn0JHtn4pYqcXwRtLvElQ7/nnjDu7iYG56H0+OhCd7d6Ug0IE3WcFpZozBKW2+80FUbv5QGk5AQ==} dev: true + /@types/chai-subset/1.3.3: + resolution: {integrity: sha512-frBecisrNGz+F4T6bcc+NLeolfiojh5FxW2klu669+8BARtyQv2C/GkNW6FUodVe4BroGMP/wER/YDGc7rEllw==} + dependencies: + '@types/chai': 4.3.1 + dev: true + + /@types/chai/4.3.1: + resolution: {integrity: sha512-/zPMqDkzSZ8t3VtxOa4KPq7uzzW978M9Tvh+j7GHKuo6k6GTLxPJ4J5gE5cjfJ26pnXst0N5Hax8Sr0T2Mi9zQ==} + dev: true + /@types/convert-source-map/1.5.2: resolution: {integrity: sha512-tHs++ZeXer40kCF2JpE51Hg7t4HPa18B1b1Dzy96S0eCw8QKECNMYMfwa1edK/x8yCN0r4e6ewvLcc5CsVGkdg==} dev: true @@ -3370,6 +3382,10 @@ packages: resolution: {integrity: sha512-TaTivMB6pYI1kXwrFlEhLeGfOqoDNdTxjCdwRfFFkEA30Eu+k48W34nlok2EYWJfFFzqaEmichdNM7th6M5HNw==} dev: true + /assertion-error/1.1.0: + resolution: {integrity: sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==} + dev: true + /astral-regex/2.0.0: resolution: {integrity: sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==} engines: {node: '>=8'} @@ -3666,6 +3682,19 @@ packages: resolution: {integrity: sha512-kbaCEBRRVSoeNs74sCuq92MJyGrMtjWVfhltoHUCW4t4pXFvGjUBrfo47weBRViHkiV3eBYyIsfl956NtHGazw==} dev: false + /chai/4.3.6: + resolution: {integrity: sha512-bbcp3YfHCUzMOvKqsztczerVgBKSsEijCySNlHHbX3VG1nskvqjz5Rfso1gGwD6w6oOV3eI60pKuMOV5MV7p3Q==} + engines: {node: '>=4'} + dependencies: + assertion-error: 1.1.0 + check-error: 1.0.2 + deep-eql: 3.0.1 + get-func-name: 2.0.0 + loupe: 2.3.4 + pathval: 1.1.1 + type-detect: 4.0.8 + dev: true + /chalk/2.4.2: resolution: {integrity: sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==} engines: {node: '>=4'} @@ -3692,6 +3721,10 @@ packages: is-regex: 1.1.4 dev: true + /check-error/1.0.2: + resolution: {integrity: sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=} + dev: true + /chokidar/3.5.2: resolution: {integrity: sha512-ekGhOnNVPgT77r4K/U3GDhu+FQ2S8TnK/s2KbIGXi0SZWuwkZ2QNyfWdZW+TVfn84DpEP7rLeCt2UI6bJ8GwbQ==} engines: {node: '>= 8.10.0'} @@ -4374,6 +4407,13 @@ packages: resolution: {integrity: sha1-JJXduvbrh0q7Dhvp3yLS5aVEMmw=} dev: true + /deep-eql/3.0.1: + resolution: {integrity: sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==} + engines: {node: '>=0.12'} + dependencies: + type-detect: 4.0.8 + dev: true + /deep-is/0.1.4: resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==} dev: true @@ -5356,6 +5396,10 @@ packages: engines: {node: 6.* || 8.* || >= 10.*} dev: true + /get-func-name/2.0.0: + resolution: {integrity: sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=} + dev: true + /get-intrinsic/1.1.1: resolution: {integrity: sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==} dependencies: @@ -6786,6 +6830,11 @@ packages: engines: {node: '>= 12.13.0'} dev: true + /local-pkg/0.4.1: + resolution: {integrity: sha512-lL87ytIGP2FU5PWwNDo0w3WhIo2gopIAxPg9RxDYF7m4rr5ahuZxP22xnJHIvaLTe4Z9P6uKKY2UHiwyB4pcrw==} + engines: {node: '>=14'} + dev: true + /locate-path/2.0.0: resolution: {integrity: sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=} engines: {node: '>=4'} @@ -6869,6 +6918,12 @@ packages: js-tokens: 4.0.0 dev: false + /loupe/2.3.4: + resolution: {integrity: sha512-OvKfgCC2Ndby6aSTREl5aCCPTNIzlDfQZvZxNUrBrihDhL3xcrYegTblhmEiCrg2kKQz4XsFIaemE5BF4ybSaQ==} + dependencies: + get-func-name: 2.0.0 + dev: true + /lru-cache/6.0.0: resolution: {integrity: sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==} engines: {node: '>=10'} @@ -7560,6 +7615,10 @@ packages: resolution: {integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==} engines: {node: '>=8'} + /pathval/1.1.1: + resolution: {integrity: sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==} + dev: true + /pend/1.2.0: resolution: {integrity: sha1-elfrVQpng/kRUzH89GY9XI4AelA=} dev: true @@ -9242,6 +9301,16 @@ packages: resolution: {integrity: sha512-lBN9zLN/oAf68o3zNXYrdCt1kP8WsiGW8Oo2ka41b2IM5JL/S1CTyX1rW0mb/zSuJun0ZUrDxx4sqvYS2FWzPA==} dev: false + /tinypool/0.1.3: + resolution: {integrity: sha512-2IfcQh7CP46XGWGGbdyO4pjcKqsmVqFAPcXfPxcPXmOWt9cYkTP9HcDmGgsfijYoAEc4z9qcpM/BaBz46Y9/CQ==} + engines: {node: '>=14.0.0'} + dev: true + + /tinyspy/0.3.2: + resolution: {integrity: sha512-2+40EP4D3sFYy42UkgkFFB+kiX2Tg3URG/lVvAZFfLxgGpnWl5qQJuBw1gaLttq8UOS+2p3C0WrhJnQigLTT2Q==} + engines: {node: '>=14.0.0'} + dev: true + /tmp/0.2.1: resolution: {integrity: sha512-76SUhtfqR2Ijn+xllcI5P1oyannHNHByD80W1q447gU3mp9G9PSpGdWmjUOHRDPiHYacIk66W7ubDTuPF3BEtQ==} engines: {node: '>=8.17.0'} @@ -9623,6 +9692,34 @@ packages: - react-dom dev: true + /vitest/0.10.4: + resolution: {integrity: sha512-FJ2av2PVozmyz9nqHRoC3H8j2z0OQXj8P8jS5oyMY9mfPWB06GS5k/1Ot++TkVBLQRHZCcVzjbK4BO7zqAJZGQ==} + engines: {node: '>=v14.16.0'} + hasBin: true + peerDependencies: + '@vitest/ui': '*' + c8: '*' + happy-dom: '*' + jsdom: '*' + peerDependenciesMeta: + '@vitest/ui': + optional: true + c8: + optional: true + happy-dom: + optional: true + jsdom: + optional: true + dependencies: + '@types/chai': 4.3.1 + '@types/chai-subset': 1.3.3 + chai: 4.3.6 + local-pkg: 0.4.1 + tinypool: 0.1.3 + tinyspy: 0.3.2 + vite: link:packages/vite + dev: true + /void-elements/3.1.0: resolution: {integrity: sha1-YU9/v42AHwu18GYfWy9XhXUOTwk=} engines: {node: '>=0.10.0'} diff --git a/vitest.config.ts b/vitest.config.ts new file mode 100644 index 00000000000000..78e54e98cc02d9 --- /dev/null +++ b/vitest.config.ts @@ -0,0 +1,15 @@ +import { defineConfig } from 'vitest/config' + +export default defineConfig({ + test: { + exclude: [ + '**/node_modules/**', + '**/dist/**', + './packages/playground/**/*.*', + './packages/temp/**/*.*' + ] + }, + esbuild: { + target: 'node14' + } +}) From 5280908972219392a0d8daa2a33553868ca7072b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Fri, 6 May 2022 18:26:47 +0900 Subject: [PATCH 139/175] fix(css): hoist external @import for non-split css (#8022) --- packages/playground/lib/__tests__/lib.spec.ts | 7 +++++ packages/playground/lib/__tests__/serve.js | 14 +++++++++- packages/playground/lib/src/dynamic.css | 4 +++ packages/playground/lib/src/index.css | 3 ++ packages/playground/lib/src/main2.js | 5 ++++ .../playground/lib/vite.dyimport.config.js | 1 - packages/vite/src/node/plugins/css.ts | 28 +++++++++++-------- 7 files changed, 49 insertions(+), 13 deletions(-) create mode 100644 packages/playground/lib/src/dynamic.css create mode 100644 packages/playground/lib/src/index.css diff --git a/packages/playground/lib/__tests__/lib.spec.ts b/packages/playground/lib/__tests__/lib.spec.ts index f1e93e90d8357b..cc5887c2777fcb 100644 --- a/packages/playground/lib/__tests__/lib.spec.ts +++ b/packages/playground/lib/__tests__/lib.spec.ts @@ -35,6 +35,13 @@ if (isBuild) { ) expect(code).not.toMatch('__vitePreload') }) + + test('@import hoist', async () => { + serverLogs.forEach((log) => { + // no warning from esbuild css minifier + expect(log).not.toMatch('All "@import" rules must come first') + }) + }) } else { test('dev', async () => { expect(await page.textContent('.demo')).toBe('It works') diff --git a/packages/playground/lib/__tests__/serve.js b/packages/playground/lib/__tests__/serve.js index eac6980286af52..2534545de5c221 100644 --- a/packages/playground/lib/__tests__/serve.js +++ b/packages/playground/lib/__tests__/serve.js @@ -9,6 +9,8 @@ const { ports } = require('../../testUtils') const port = (exports.port = ports.lib) +global.serverLogs = [] + /** * @param {string} root * @param {boolean} isBuildTest @@ -16,6 +18,8 @@ const port = (exports.port = ports.lib) exports.serve = async function serve(root, isBuildTest) { // build first + setupConsoleWarnCollector() + if (!isBuildTest) { const { createServer } = require('vite') process.env.VITE_INLINE = 'inline-serve' @@ -55,7 +59,7 @@ exports.serve = async function serve(root, isBuildTest) { await build({ root, - logLevel: 'silent', + logLevel: 'warn', // output esbuild warns configFile: path.resolve(__dirname, '../vite.dyimport.config.js') }) @@ -89,3 +93,11 @@ exports.serve = async function serve(root, isBuildTest) { }) } } + +function setupConsoleWarnCollector() { + const warn = console.warn + console.warn = (...args) => { + global.serverLogs.push(args.join(' ')) + return warn.call(console, ...args) + } +} diff --git a/packages/playground/lib/src/dynamic.css b/packages/playground/lib/src/dynamic.css new file mode 100644 index 00000000000000..4378c8d328cfbe --- /dev/null +++ b/packages/playground/lib/src/dynamic.css @@ -0,0 +1,4 @@ +@import 'https://cdn.jsdelivr.net/npm/@mdi/font@5.9.55/css/materialdesignicons.min.css'; +.dynamic { + color: red; +} diff --git a/packages/playground/lib/src/index.css b/packages/playground/lib/src/index.css new file mode 100644 index 00000000000000..b0bd670bd9ecad --- /dev/null +++ b/packages/playground/lib/src/index.css @@ -0,0 +1,3 @@ +.index { + color: blue; +} diff --git a/packages/playground/lib/src/main2.js b/packages/playground/lib/src/main2.js index 0c729fad8d165c..f19a16bb128949 100644 --- a/packages/playground/lib/src/main2.js +++ b/packages/playground/lib/src/main2.js @@ -1,4 +1,9 @@ +import './index.css' + export default async function message(sel) { const message = await import('./message.js') + + await import('./dynamic.css') + document.querySelector(sel).textContent = message.default } diff --git a/packages/playground/lib/vite.dyimport.config.js b/packages/playground/lib/vite.dyimport.config.js index 76311f4b8ba138..d738503f0c9d09 100644 --- a/packages/playground/lib/vite.dyimport.config.js +++ b/packages/playground/lib/vite.dyimport.config.js @@ -6,7 +6,6 @@ const path = require('path') */ module.exports = { build: { - minify: false, lib: { entry: path.resolve(__dirname, 'src/main2.js'), formats: ['es'], diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index cd57acd1690902..c61e059867080b 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -443,13 +443,7 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin { } }) // only external @imports and @charset should exist at this point - // hoist them to the top of the CSS chunk per spec (#1845 and #6333) - if (css.includes('@import') || css.includes('@charset')) { - css = await hoistAtRules(css) - } - if (minify && config.build.minify) { - css = await minifyCSS(css, config) - } + css = await finalizeCss(css, minify, config) return css } @@ -559,10 +553,7 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin { let extractedCss = outputToExtractedCSSMap.get(opts) if (extractedCss && !hasEmitted) { hasEmitted = true - // minify css - if (config.build.minify) { - extractedCss = await minifyCSS(extractedCss, config) - } + extractedCss = await finalizeCss(extractedCss, true, config) this.emitFile({ name: 'style.css', type: 'asset', @@ -922,6 +913,21 @@ function combineSourcemapsIfExists( : map1 } +async function finalizeCss( + css: string, + minify: boolean, + config: ResolvedConfig +) { + // hoist external @imports and @charset to the top of the CSS chunk per spec (#1845 and #6333) + if (css.includes('@import') || css.includes('@charset')) { + css = await hoistAtRules(css) + } + if (minify && config.build.minify) { + css = await minifyCSS(css, config) + } + return css +} + interface PostCSSConfigResult { options: PostCSS.ProcessOptions plugins: PostCSS.Plugin[] From e0fe2008b248aec4813efba34db9e644b851943a Mon Sep 17 00:00:00 2001 From: Enzo Innocenzi Date: Fri, 6 May 2022 14:24:40 +0200 Subject: [PATCH 140/175] fix(plugin-vue): allow overwriting template.transformAssetUrls.includeAbsolute (fix #4836) (#6779) --- packages/plugin-vue/src/template.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/plugin-vue/src/template.ts b/packages/plugin-vue/src/template.ts index 72e9588967556e..c7eed9015d6339 100644 --- a/packages/plugin-vue/src/template.ts +++ b/packages/plugin-vue/src/template.ts @@ -139,7 +139,7 @@ export function resolveTemplateCompilerOptions( tags: transformAssetUrls as any } } else { - transformAssetUrls = { ...transformAssetUrls, ...assetUrlOptions } + transformAssetUrls = { ...assetUrlOptions, ...transformAssetUrls } } } else { transformAssetUrls = assetUrlOptions From c7356e0f8e7a8f7476db90204638d9834cb58101 Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Fri, 6 May 2022 16:42:51 -0400 Subject: [PATCH 141/175] fix: invalidate ssrError when HMR update occurs (#8052) --- packages/vite/src/node/server/hmr.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/vite/src/node/server/hmr.ts b/packages/vite/src/node/server/hmr.ts index 8d33554706dee2..8eca99268e93d7 100644 --- a/packages/vite/src/node/server/hmr.ts +++ b/packages/vite/src/node/server/hmr.ts @@ -294,6 +294,7 @@ function invalidate(mod: ModuleNode, timestamp: number, seen: Set) { mod.lastHMRTimestamp = timestamp mod.transformResult = null mod.ssrModule = null + mod.ssrError = null mod.ssrTransformResult = null mod.importers.forEach((importer) => { if (!importer.acceptedHmrDeps.has(mod)) { From 8897da18a084d138dd32a5b4734220520e08e5a4 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Sat, 7 May 2022 11:07:05 +0800 Subject: [PATCH 142/175] chore: update workspace setup --- package.json | 2 +- pnpm-lock.yaml | 23 ----------------------- pnpm-workspace.yaml | 2 ++ 3 files changed, 3 insertions(+), 24 deletions(-) diff --git a/package.json b/package.json index 843b6a4e030e39..eae96bb7fa8dd1 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "preinstall": "npx only-allow pnpm", "format": "prettier --write .", "lint": "eslint packages/*/{src,types}/**", - "test": "run-s test-serve test-build test-unit", + "test": "run-s test-unit test-serve test-build", "test-serve": "jest", "test-build": "cross-env VITE_TEST_BUILD=1 jest", "test-unit": "vitest run", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3f15dbb27aae88..d1d5b496892229 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -280,32 +280,9 @@ importers: test-package-d: link:test-package-d test-package-e: link:test-package-e - packages/playground/nested-deps/test-package-a: - specifiers: {} - - packages/playground/nested-deps/test-package-b: - specifiers: {} - - packages/playground/nested-deps/test-package-c: - specifiers: {} - - packages/playground/nested-deps/test-package-d: - specifiers: - test-package-d-nested: link:./test-package-d-nested - dependencies: - test-package-d-nested: link:test-package-d-nested - packages/playground/nested-deps/test-package-d/test-package-d-nested: specifiers: {} - packages/playground/nested-deps/test-package-e: - specifiers: - test-package-e-excluded: link:./test-package-e-excluded - test-package-e-included: link:./test-package-e-included - dependencies: - test-package-e-excluded: link:test-package-e-excluded - test-package-e-included: link:test-package-e-included - packages/playground/nested-deps/test-package-e/test-package-e-excluded: specifiers: {} diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index f8a7dd53d45fb0..a4e6b07cfdf222 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -1,3 +1,5 @@ packages: - 'packages/*' - 'packages/playground/**' + - '!packages/temp' + - '!packages/playground/nested-deps/test-package-*' From b44d745360435d9eb607eaca239cc396ae41c1c0 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Sat, 7 May 2022 11:32:35 +0800 Subject: [PATCH 143/175] chore: revert workspace change --- pnpm-workspace.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index a4e6b07cfdf222..f8a7dd53d45fb0 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -1,5 +1,3 @@ packages: - 'packages/*' - 'packages/playground/**' - - '!packages/temp' - - '!packages/playground/nested-deps/test-package-*' From dc323a0a230f57de0d102782dd4e673fb6b2d06c Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Sat, 7 May 2022 11:32:52 +0800 Subject: [PATCH 144/175] chore: update lock --- pnpm-lock.yaml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d1d5b496892229..3f15dbb27aae88 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -280,9 +280,32 @@ importers: test-package-d: link:test-package-d test-package-e: link:test-package-e + packages/playground/nested-deps/test-package-a: + specifiers: {} + + packages/playground/nested-deps/test-package-b: + specifiers: {} + + packages/playground/nested-deps/test-package-c: + specifiers: {} + + packages/playground/nested-deps/test-package-d: + specifiers: + test-package-d-nested: link:./test-package-d-nested + dependencies: + test-package-d-nested: link:test-package-d-nested + packages/playground/nested-deps/test-package-d/test-package-d-nested: specifiers: {} + packages/playground/nested-deps/test-package-e: + specifiers: + test-package-e-excluded: link:./test-package-e-excluded + test-package-e-included: link:./test-package-e-included + dependencies: + test-package-e-excluded: link:test-package-e-excluded + test-package-e-included: link:test-package-e-included + packages/playground/nested-deps/test-package-e/test-package-e-excluded: specifiers: {} From fe704f1ff7a5532d9efd9999d9fc8793884e9fe8 Mon Sep 17 00:00:00 2001 From: patak Date: Sat, 7 May 2022 07:20:00 +0200 Subject: [PATCH 145/175] fix: graceful rename in windows (#8036) --- packages/vite/src/node/utils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/vite/src/node/utils.ts b/packages/vite/src/node/utils.ts index d41dd6850ebb56..29741989ea2326 100644 --- a/packages/vite/src/node/utils.ts +++ b/packages/vite/src/node/utils.ts @@ -775,8 +775,8 @@ function gracefulRename( ) { setTimeout(function () { fs.stat(to, function (stater, st) { - if (stater && stater.code === 'ENOENT') gracefulRename(from, to, CB) - else cb(er) + if (stater && stater.code === 'ENOENT') fs.rename(from, to, CB) + else CB(er) }) }, backoff) if (backoff < 100) backoff += 10 From 1ffc0107e81d9196284a42dd450b8ff9d038b245 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Sat, 7 May 2022 13:30:08 +0800 Subject: [PATCH 146/175] fix: use `strip-literal` to strip string lterals (#8054) --- packages/vite/LICENSE.md | 29 ++++ packages/vite/package.json | 1 + .../src/node/__tests__/cleanString.spec.ts | Bin 4756 -> 0 bytes packages/vite/src/node/cleanString.ts | 145 ------------------ .../src/node/plugins/assetImportMetaUrl.ts | 4 +- packages/vite/src/node/plugins/css.ts | 2 +- packages/vite/src/node/plugins/html.ts | 4 +- .../src/node/plugins/workerImportMetaUrl.ts | 4 +- packages/vite/src/node/utils.ts | 4 + pnpm-lock.yaml | 8 + 10 files changed, 49 insertions(+), 152 deletions(-) delete mode 100644 packages/vite/src/node/__tests__/cleanString.spec.ts delete mode 100644 packages/vite/src/node/cleanString.ts diff --git a/packages/vite/LICENSE.md b/packages/vite/LICENSE.md index 30803708e30a76..80feb7f95c6941 100644 --- a/packages/vite/LICENSE.md +++ b/packages/vite/LICENSE.md @@ -3465,6 +3465,35 @@ Repository: chalk/strip-ansi --------------------------------------- +## strip-literal +License: MIT +By: Anthony Fu +Repository: git+https://github.com/antfu/strip-literal.git + +> MIT License +> +> Copyright (c) 2022 Anthony Fu +> +> Permission is hereby granted, free of charge, to any person obtaining a copy +> of this software and associated documentation files (the "Software"), to deal +> in the Software without restriction, including without limitation the rights +> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +> copies of the Software, and to permit persons to whom the Software is +> furnished to do so, subject to the following conditions: +> +> The above copyright notice and this permission notice shall be included in all +> copies or substantial portions of the Software. +> +> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +> SOFTWARE. + +--------------------------------------- + ## to-regex-range License: MIT By: Jon Schlinkert, Rouven Weßling diff --git a/packages/vite/package.json b/packages/vite/package.json index 55c86878622111..b508842619033e 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -112,6 +112,7 @@ "source-map-js": "^1.0.2", "source-map-support": "^0.5.21", "strip-ansi": "^6.0.1", + "strip-literal": "^0.2.0", "terser": "^5.13.1", "tsconfck": "^1.2.2", "tslib": "^2.4.0", diff --git a/packages/vite/src/node/__tests__/cleanString.spec.ts b/packages/vite/src/node/__tests__/cleanString.spec.ts deleted file mode 100644 index 99ecbcaad444023d10ed467f6cd9b2794fa935bd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4756 zcmc&&TW{h<6z(&>;>e0LHbgjVyDwE)sqNEBttvID`Vc4bULVgdHr(Vhw5>j>q99dtRn_6|U?$ zQ-ic-GV6`~a&OBt@6aXe3caIwaIOz zZov;=`T@2Ba4bIdu-|I-W1a~^a9k5;`>&T|JS0+-{|<(so8bl=CoX->6U}mGq2=jM z9@YxqK*%adC%hK{aWF>U)_#DBuv`3Ke5HcHE~qi67}q`oNs(6;7+07c2Z8MudX2P7 z<45tN*wS@h$Yx09&G6$nGH%Ypq}hZ6KBGw4d7qsi$A8u~S@~Ya)aXwBlt zDA?wj-s|CKszh%LBr9F&#G0}fOTv8^NHvKfH4(f#?0XXdMf&|Q(sd_rSkvM>3*vR8 z!GBp&6Y7)Py2Y+&Qy%JS`!wi`c<9ESLRGac#e>d>)?_t)i(+2b26-gxhFxivh&brQ z0`v1M%t9r}gaRdiJQ)ji=UL%`zfNh$@mMhPo;fZqSk)<)8)u%zly$M* z#_hWfHQU_AsEavDC$AfGZIGU5j5^C0M|~}0qWCOpYVu2&vv)sevdGLhE0%IH;D8T< z>u4QH6dcqF7>CViGefwD{wk&@IL{QJzltfi(dXIX7)~^%Ep&@CpGz$RNqbmidI@O` zrT&D?+YekgtBs~f z75jD>H84WYV*Ea&kO)vCQ(RRyA&d^5Z;-(6Sg&a+hTF|HK?8lt=k4rUnCt=^&UgO| zphU<~_6wnl`2d_8HJB%u-NpU{a>_Z5OQ(x0Z}30W(^uPeDjVs(KQ$Jo_0m*f zR_HlCzw36qOc!|m%L{$HHdc?H%PbhLO0(ES9_Y+YmHI#hQrw6eJh!}8*8~} z({BlwK;4@@p0%9{!u#8nGKRFhWc>MD;7<#Dsh|hWNf!!!3Zc$0ie|V2QB;lm-;44O zQ@-5etJ2J65a7ZvihOE(M~9o$omCG{>T#rAyoV?6apb*3@xxOTKaQf9nQw_!_AH8c z*Ra8T6A?iWE^)v9{nh1To~60D&-JES71sS;B6lQ8dnwzEvtRwUA9*7J-!<{-h&%Q- DgfAcj diff --git a/packages/vite/src/node/cleanString.ts b/packages/vite/src/node/cleanString.ts deleted file mode 100644 index d990ab75f15d7c..00000000000000 --- a/packages/vite/src/node/cleanString.ts +++ /dev/null @@ -1,145 +0,0 @@ -import type { RollupError } from 'rollup' -import { multilineCommentsRE, singlelineCommentsRE } from './utils' - -// bank on the non-overlapping nature of regex matches and combine all filters into one giant regex -// /`([^`\$\{\}]|\$\{(`|\g<1>)*\})*`/g can match nested string template -// but js not support match expression(\g<0>). so clean string template(`...`) in other ways. -const stringsRE = /"([^"\r\n]|(?<=\\)")*"|'([^'\r\n]|(?<=\\)')*'/g -const regexRE = /\/.*?(? ' '.repeat(s.length) -const stringBlankReplacer = (s: string) => - `${s[0]}${'\0'.repeat(s.length - 2)}${s[0]}` - -export function emptyString(raw: string): string { - let res = raw - .replace(cleanerRE, (s: string) => - s[0] === '/' ? blankReplacer(s) : stringBlankReplacer(s) - ) - .replace(regexRE, (s) => stringBlankReplacer(s)) - - let lastEnd = 0 - let start = 0 - while ((start = res.indexOf('`', lastEnd)) >= 0) { - let clean - ;[clean, lastEnd] = lexStringTemplateExpression(res, start) - res = replaceAt(res, start, lastEnd, clean) - } - - return res -} - -export function emptyCssComments(raw: string) { - return raw.replace(multilineCommentsRE, blankReplacer) -} - -const enum LexerState { - // template string - inTemplateString, - inInterpolationExpression, - inObjectExpression, - // strings - inSingleQuoteString, - inDoubleQuoteString, - // comments - inMultilineCommentsRE, - inSinglelineCommentsRE -} - -function replaceAt( - string: string, - start: number, - end: number, - replacement: string -): string { - return string.slice(0, start) + replacement + string.slice(end) -} - -/** - * lex string template and clean it. - */ -function lexStringTemplateExpression( - code: string, - start: number -): [string, number] { - let state = LexerState.inTemplateString as LexerState - let clean = '`' - const opStack: LexerState[] = [state] - - function pushStack(newState: LexerState) { - state = newState - opStack.push(state) - } - - function popStack() { - opStack.pop() - state = opStack[opStack.length - 1] - } - - let i = start + 1 - outer: for (; i < code.length; i++) { - const char = code.charAt(i) - switch (state) { - case LexerState.inTemplateString: - if (char === '$' && code.charAt(i + 1) === '{') { - pushStack(LexerState.inInterpolationExpression) - clean += '${' - i++ // jump next - } else if (char === '`') { - popStack() - clean += char - if (opStack.length === 0) { - break outer - } - } else { - clean += '\0' - } - break - case LexerState.inInterpolationExpression: - if (char === '{') { - pushStack(LexerState.inObjectExpression) - clean += char - } else if (char === '}') { - popStack() - clean += char - } else if (char === '`') { - pushStack(LexerState.inTemplateString) - clean += char - } else { - clean += char - } - break - case LexerState.inObjectExpression: - if (char === '}') { - popStack() - clean += char - } else if (char === '`') { - pushStack(LexerState.inTemplateString) - clean += char - } else { - clean += char - } - break - default: - throw new Error('unknown string template lexer state') - } - } - - if (opStack.length !== 0) { - error(start) - } - - return [clean, i + 1] -} - -function error(pos: number) { - const err = new Error( - `can not match string template expression.` - ) as RollupError - err.pos = pos - throw err -} diff --git a/packages/vite/src/node/plugins/assetImportMetaUrl.ts b/packages/vite/src/node/plugins/assetImportMetaUrl.ts index b8c16f76d2b93f..217b0d3fee1564 100644 --- a/packages/vite/src/node/plugins/assetImportMetaUrl.ts +++ b/packages/vite/src/node/plugins/assetImportMetaUrl.ts @@ -3,7 +3,7 @@ import MagicString from 'magic-string' import path from 'path' import { fileToUrl } from './asset' import type { ResolvedConfig } from '../config' -import { emptyString } from '../cleanString' +import { stripLiteral } from 'strip-literal' /** * Convert `new URL('./foo.png', import.meta.url)` to its resolved built URL @@ -27,7 +27,7 @@ export function assetImportMetaUrlPlugin(config: ResolvedConfig): Plugin { let s: MagicString | undefined const assetImportMetaUrlRE = /\bnew\s+URL\s*\(\s*('[^']+'|"[^"]+"|`[^`]+`)\s*,\s*import\.meta\.url\s*,?\s*\)/g - const cleanString = emptyString(code) + const cleanString = stripLiteral(code) let match: RegExpExecArray | null while ((match = assetImportMetaUrlRE.exec(cleanString))) { diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index c61e059867080b..22dfc33f67a509 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -49,7 +49,7 @@ import { transform, formatMessages } from 'esbuild' import { addToHTMLProxyTransformResult } from './html' import { injectSourcesContent, getCodeWithSourcemap } from '../server/sourcemap' import type { RawSourceMap } from '@ampproject/remapping' -import { emptyCssComments } from '../cleanString' +import { emptyCssComments } from '../utils' // const debug = createDebugger('vite:css') diff --git a/packages/vite/src/node/plugins/html.ts b/packages/vite/src/node/plugins/html.ts index 0223c351af6071..6d793c416ce60a 100644 --- a/packages/vite/src/node/plugins/html.ts +++ b/packages/vite/src/node/plugins/html.ts @@ -36,7 +36,7 @@ import type { TextNode } from '@vue/compiler-dom' import { NodeTypes } from '@vue/compiler-dom' -import { emptyString } from '../cleanString' +import { stripLiteral } from 'strip-literal' interface ScriptAssetsUrl { start: number @@ -308,7 +308,7 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin { } } else if (node.children.length) { const scriptNode = node.children.pop()! as TextNode - const cleanCode = emptyString(scriptNode.content) + const cleanCode = stripLiteral(scriptNode.content) let match: RegExpExecArray | null while ((match = inlineImportRE.exec(cleanCode))) { diff --git a/packages/vite/src/node/plugins/workerImportMetaUrl.ts b/packages/vite/src/node/plugins/workerImportMetaUrl.ts index 3d8970b746349c..bfd8c22dcad372 100644 --- a/packages/vite/src/node/plugins/workerImportMetaUrl.ts +++ b/packages/vite/src/node/plugins/workerImportMetaUrl.ts @@ -10,7 +10,7 @@ import { ENV_ENTRY, ENV_PUBLIC_PATH } from '../constants' import MagicString from 'magic-string' import type { ViteDevServer } from '..' import type { RollupError } from 'rollup' -import { emptyString } from '../cleanString' +import { stripLiteral } from 'strip-literal' type WorkerType = 'classic' | 'module' | 'ignore' const ignoreFlagRE = /\/\*\s*@vite-ignore\s*\*\// @@ -110,7 +110,7 @@ export function workerImportMetaUrlPlugin(config: ResolvedConfig): Plugin { code.includes('new URL') && code.includes(`import.meta.url`) ) { - const cleanString = emptyString(code) + const cleanString = stripLiteral(code) const workerImportMetaUrlRE = /\bnew\s+(Worker|SharedWorker)\s*\(\s*(new\s+URL\s*\(\s*('[^']+'|"[^"]+"|`[^`]+`)\s*,\s*import\.meta\.url\s*\))/g diff --git a/packages/vite/src/node/utils.ts b/packages/vite/src/node/utils.ts index 29741989ea2326..ddcaced9832bc1 100644 --- a/packages/vite/src/node/utils.ts +++ b/packages/vite/src/node/utils.ts @@ -785,3 +785,7 @@ function gracefulRename( if (cb) cb(er) }) } + +export function emptyCssComments(raw: string) { + return raw.replace(multilineCommentsRE, (s) => ' '.repeat(s.length)) +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3f15dbb27aae88..a20eb4e3bb7d1f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -893,6 +893,7 @@ importers: source-map-js: ^1.0.2 source-map-support: ^0.5.21 strip-ansi: ^6.0.1 + strip-literal: ^0.2.0 terser: ^5.13.1 tsconfck: ^1.2.2 tslib: ^2.4.0 @@ -966,6 +967,7 @@ importers: source-map-js: 1.0.2 source-map-support: 0.5.21 strip-ansi: 6.0.1 + strip-literal: 0.2.0 terser: 5.13.1 tsconfck: 1.2.2_typescript@4.5.4 tslib: 2.4.0 @@ -9016,6 +9018,12 @@ packages: engines: {node: '>=8'} dev: true + /strip-literal/0.2.0: + resolution: {integrity: sha512-pqhiiFRDifA2CRVH0Gmv6MDbd2b27MS0oIqqy7JCqfL5m2sh68223lmEK2eoBXp4vNaq8G1Wzwd9dfQcWszUlg==} + dependencies: + acorn: 8.7.1 + dev: true + /stylis/4.0.13: resolution: {integrity: sha512-xGPXiFVl4YED9Jh7Euv2V220mriG9u4B2TA6Ybjc1catrstKD2PpIdU3U0RKpkVBC2EhmL/F0sPCr9vrFTNRag==} From 20ea9999765ea372c20acc39e05cd81b98c9f6fe Mon Sep 17 00:00:00 2001 From: Rom Date: Sat, 7 May 2022 21:23:54 +0200 Subject: [PATCH 147/175] feat: new hook `configurePreviewServer` (#7658) --- docs/guide/api-plugin.md | 22 ++++++++++++++++++++++ packages/vite/src/node/index.ts | 1 + packages/vite/src/node/plugin.ts | 10 ++++++++++ packages/vite/src/node/preview.ts | 20 ++++++++++++++++++++ 4 files changed, 53 insertions(+) diff --git a/docs/guide/api-plugin.md b/docs/guide/api-plugin.md index 50353765261e34..76b9984a069828 100644 --- a/docs/guide/api-plugin.md +++ b/docs/guide/api-plugin.md @@ -305,6 +305,28 @@ Vite plugins can also provide hooks that serve Vite-specific purposes. These hoo Note `configureServer` is not called when running the production build so your other hooks need to guard against its absence. +### `configurePreviewServer` + +- **Type:** `(server: { middlewares: Connect.Server, httpServer: http.Server }) => (() => void) | void | Promise<(() => void) | void>` +- **Kind:** `async`, `sequential` + + Same as [`configureServer`](/guide/api-plugin.html#configureserver) but for the preview server. It provides the [connect](https://github.com/senchalabs/connect) server and its underlying [http server](https://nodejs.org/api/http.html). Similarly to `configureServer`, the `configurePreviewServer` hook is called before other middlewares are installed. If you want to inject a middleware **after** other middlewares, you can return a function from `configurePreviewServer`, which will be called after internal middlewares are installed: + + ```js + const myPlugin = () => ({ + name: 'configure-preview-server', + configurePreviewServer(server) { + // return a post hook that is called after other middlewares are + // installed + return () => { + server.middlewares.use((req, res, next) => { + // custom handle request... + }) + } + } + }) + ``` + ### `transformIndexHtml` - **Type:** `IndexHtmlTransformHook | { enforce?: 'pre' | 'post', transform: IndexHtmlTransformHook }` diff --git a/packages/vite/src/node/index.ts b/packages/vite/src/node/index.ts index c15359f45b69de..e56f4c6e765756 100644 --- a/packages/vite/src/node/index.ts +++ b/packages/vite/src/node/index.ts @@ -33,6 +33,7 @@ export type { export type { PreviewOptions, PreviewServer, + PreviewServerHook, ResolvedPreviewOptions } from './preview' export type { diff --git a/packages/vite/src/node/plugin.ts b/packages/vite/src/node/plugin.ts index 354b246dd9f182..3bfe789a299987 100644 --- a/packages/vite/src/node/plugin.ts +++ b/packages/vite/src/node/plugin.ts @@ -13,6 +13,7 @@ import type { IndexHtmlTransform } from './plugins/html' import type { ModuleNode } from './server/moduleGraph' import type { ConfigEnv, ResolvedConfig } from './' import type { HmrContext } from './server/hmr' +import type { PreviewServerHook } from './preview' /** * Vite plugins extends the Rollup plugin interface with a few extra @@ -79,6 +80,15 @@ export interface Plugin extends RollupPlugin { * are applied. Hook can be async functions and will be called in series. */ configureServer?: ServerHook + /** + * Configure the preview server. The hook receives the connect server and + * its underlying http server. + * + * The hooks are called before other middlewares are applied. A hook can + * return a post hook that will be called after other middlewares are + * applied. Hooks can be async functions and will be called in series. + */ + configurePreviewServer?: PreviewServerHook /** * Transform index.html. * The hook receives the following arguments: diff --git a/packages/vite/src/node/preview.ts b/packages/vite/src/node/preview.ts index c1670c5d7efa72..e48f2e6231933f 100644 --- a/packages/vite/src/node/preview.ts +++ b/packages/vite/src/node/preview.ts @@ -14,6 +14,7 @@ import corsMiddleware from 'cors' import { proxyMiddleware } from './server/middlewares/proxy' import { resolveHostname } from './utils' import { printCommonServerUrls } from './logger' +import type * as http from 'http' export interface PreviewOptions extends CommonServerOptions {} @@ -53,6 +54,11 @@ export interface PreviewServer { printUrls: () => void } +export type PreviewServerHook = (server: { + middlewares: Connect.Server + httpServer: http.Server +}) => (() => void) | void | Promise<(() => void) | void> + /** * Starts the Vite server in preview mode, to simulate a production deployment * @experimental @@ -69,6 +75,16 @@ export async function preview( await resolveHttpsConfig(config.preview?.https, config.cacheDir) ) + // apply server hooks from plugins + const postHooks: ((() => void) | void)[] = [] + for (const plugin of config.plugins) { + if (plugin.configurePreviewServer) { + postHooks.push( + await plugin.configurePreviewServer({ middlewares: app, httpServer }) + ) + } + } + // cors const { cors } = config.preview if (cors !== false) { @@ -83,6 +99,7 @@ export async function preview( app.use(compression()) + // static assets const distDir = path.resolve(config.root, config.build.outDir) app.use( config.base, @@ -93,6 +110,9 @@ export async function preview( }) ) + // apply post server hooks from plugins + postHooks.forEach((fn) => fn && fn()) + const options = config.preview const hostname = resolveHostname(options.host) const port = options.port ?? 4173 From 9f8381eb70375d460f8b410f44e0b758eb714234 Mon Sep 17 00:00:00 2001 From: "Jeff Yang (Nay Thu Ya Aung)" <32727188+ydcjeff@users.noreply.github.com> Date: Sun, 8 May 2022 01:57:44 +0630 Subject: [PATCH 148/175] refactor: use optional chaining in config `define` of vue-jsx (#8046) --- packages/plugin-vue-jsx/index.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/packages/plugin-vue-jsx/index.js b/packages/plugin-vue-jsx/index.js index 248270765d19a1..929f4fb44cd434 100644 --- a/packages/plugin-vue-jsx/index.js +++ b/packages/plugin-vue-jsx/index.js @@ -48,12 +48,6 @@ function vueJsxPlugin(options = {}) { name: 'vite:vue-jsx', config(config) { - const optionsApi = config.define - ? config.define.__VUE_OPTIONS_API__ - : undefined - const devTools = config.define - ? config.define.__VUE_PROD_DEVTOOLS__ - : undefined return { // only apply esbuild to ts files // since we are handling jsx and tsx now @@ -61,8 +55,8 @@ function vueJsxPlugin(options = {}) { include: /\.ts$/ }, define: { - __VUE_OPTIONS_API__: optionsApi != null ? optionsApi : true, - __VUE_PROD_DEVTOOLS__: devTools != null ? devTools : false + __VUE_OPTIONS_API__: config.define?.__VUE_OPTIONS_API__ ?? true, + __VUE_PROD_DEVTOOLS__: config.define?.__VUE_PROD_DEVTOOLS__ ?? false } } }, From 939848866d365908749ed257706abd47f60493a5 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Sun, 8 May 2022 13:13:40 +0800 Subject: [PATCH 149/175] chore: enable ci for v1 and v2 branch --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5173da859417be..b1c663db40e80f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,6 +13,8 @@ on: - feat/* - fix/* - perf/* + - v1 + - v2 pull_request: workflow_dispatch: From cc3129e4336e7c09cc3e4beee0f4f5f964bb8b0f Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Sun, 8 May 2022 13:28:32 +0800 Subject: [PATCH 150/175] chore: ignore empty chunk test warning (#8063) --- scripts/jestEnv.cjs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/jestEnv.cjs b/scripts/jestEnv.cjs index 255b83063efc5a..b576155644a27f 100644 --- a/scripts/jestEnv.cjs +++ b/scripts/jestEnv.cjs @@ -29,13 +29,13 @@ module.exports = class PlaywrightEnvironment extends NodeEnvironment { })) this.global.page = await browser.newPage() - // suppress @vue/ref-transform warning const console = this.global.console const warn = console.warn console.warn = (msg, ...args) => { - if (!msg.includes('@vue/ref-transform')) { - warn.call(console, msg, ...args) - } + // suppress @vue/ref-transform warning + if (msg.includes('@vue/ref-transform')) return + if (msg.includes('Generated an empty chunk')) return + warn.call(console, msg, ...args) } } From ed4c7598d4c1715a8306190f6e8e2aa8d851b95b Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Sun, 8 May 2022 13:52:45 +0800 Subject: [PATCH 151/175] docs: version selector (#8065) --- docs/.vitepress/{config.js => config.ts} | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) rename docs/.vitepress/{config.js => config.ts} (94%) diff --git a/docs/.vitepress/config.js b/docs/.vitepress/config.ts similarity index 94% rename from docs/.vitepress/config.js rename to docs/.vitepress/config.ts index ee76a29986d3fb..4659ea5ab7ae4f 100644 --- a/docs/.vitepress/config.js +++ b/docs/.vitepress/config.ts @@ -1,9 +1,6 @@ -// @ts-check +import { defineConfig } from 'vitepress' -/** - * @type {import('vitepress').UserConfig} - */ -module.exports = { +export default defineConfig({ title: 'Vite', description: 'Next Generation Frontend Tooling', head: [['link', { rel: 'icon', type: 'image/svg+xml', href: '/logo.svg' }]], @@ -64,6 +61,15 @@ module.exports = { } ] }, + { + text: 'v3 (next)', + items: [ + { + text: 'v2.x (stable)', + link: 'https://v2.vitejs.dev' + } + ] + }, { text: 'Languages', items: [ @@ -169,4 +175,4 @@ module.exports = { ] } } -} +}) From b215493b6c01d9d299094e27a0f6bae694b71eff Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Sun, 8 May 2022 15:19:01 +0800 Subject: [PATCH 152/175] docs: note about v3.0 branch (#8064) --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 546014a12c7116..e07879c7ece2a6 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,8 @@ In addition, Vite is highly extensible via its [Plugin API](https://vitejs.dev/g ## Packages +> This branch is for upcoming v3.0, if you are looking for current stable releases, check the [`2.x` branch](https://github.com/vitejs/vite/tree/2.x) instead. + | Package | Version (click for changelogs) | | ------------------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------- | | [vite](packages/vite) | [![vite version](https://img.shields.io/npm/v/vite.svg?label=%20)](packages/vite/CHANGELOG.md) | From 330e0a90988509454e31067984bf0cdbe2465325 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Sun, 8 May 2022 16:16:44 +0800 Subject: [PATCH 153/175] feat!: rework `import.meta.glob` (#7537) --- docs/guide/features.md | 115 ++++- .../assets/__tests__/assets.spec.ts | 4 +- packages/playground/css/main.js | 4 +- .../glob-import/__tests__/glob-import.spec.ts | 4 +- packages/vite/LICENSE.md | 28 ++ packages/vite/package.json | 3 +- .../__snapshots__/fixture.test.ts.snap | 154 ++++++ .../plugins/importGlob/fixture-a/.gitignore | 1 + .../plugins/importGlob/fixture-a/index.ts | 64 +++ .../plugins/importGlob/fixture-a/modules/a.ts | 1 + .../plugins/importGlob/fixture-a/modules/b.ts | 1 + .../importGlob/fixture-a/modules/index.ts | 6 + .../framework/pages/hello.page.js | 4 + .../plugins/importGlob/fixture-a/sibling.ts | 1 + .../plugins/importGlob/fixture-b/a.ts | 1 + .../plugins/importGlob/fixture-b/b.ts | 1 + .../plugins/importGlob/fixture-b/index.ts | 2 + .../plugins/importGlob/fixture.test.ts | 59 +++ .../plugins/importGlob/parse.test.ts | 202 ++++++++ .../plugins/importGlob/utils.test.ts | 31 ++ packages/vite/src/node/config.ts | 18 + packages/vite/src/node/importGlob.ts | 246 --------- packages/vite/src/node/index.ts | 13 +- packages/vite/src/node/optimizer/scan.ts | 78 +-- .../src/node/plugins/assetImportMetaUrl.ts | 6 +- packages/vite/src/node/plugins/css.ts | 13 - .../vite/src/node/plugins/importAnalysis.ts | 44 -- .../src/node/plugins/importAnalysisBuild.ts | 46 +- .../vite/src/node/plugins/importMetaGlob.ts | 465 ++++++++++++++++++ packages/vite/src/node/plugins/index.ts | 2 + packages/vite/src/node/plugins/worker.ts | 4 +- packages/vite/src/node/server/hmr.ts | 37 +- packages/vite/src/node/server/index.ts | 21 +- packages/vite/types/chokidar.d.ts | 6 +- packages/vite/types/importGlob.d.ts | 89 ++++ packages/vite/types/importMeta.d.ts | 14 +- packages/vite/types/shims.d.ts | 8 - pnpm-lock.yaml | 14 +- 38 files changed, 1308 insertions(+), 502 deletions(-) create mode 100644 packages/vite/src/node/__tests__/plugins/importGlob/__snapshots__/fixture.test.ts.snap create mode 100644 packages/vite/src/node/__tests__/plugins/importGlob/fixture-a/.gitignore create mode 100644 packages/vite/src/node/__tests__/plugins/importGlob/fixture-a/index.ts create mode 100644 packages/vite/src/node/__tests__/plugins/importGlob/fixture-a/modules/a.ts create mode 100644 packages/vite/src/node/__tests__/plugins/importGlob/fixture-a/modules/b.ts create mode 100644 packages/vite/src/node/__tests__/plugins/importGlob/fixture-a/modules/index.ts create mode 100644 packages/vite/src/node/__tests__/plugins/importGlob/fixture-a/node_modules/framework/pages/hello.page.js create mode 100644 packages/vite/src/node/__tests__/plugins/importGlob/fixture-a/sibling.ts create mode 100644 packages/vite/src/node/__tests__/plugins/importGlob/fixture-b/a.ts create mode 100644 packages/vite/src/node/__tests__/plugins/importGlob/fixture-b/b.ts create mode 100644 packages/vite/src/node/__tests__/plugins/importGlob/fixture-b/index.ts create mode 100644 packages/vite/src/node/__tests__/plugins/importGlob/fixture.test.ts create mode 100644 packages/vite/src/node/__tests__/plugins/importGlob/parse.test.ts create mode 100644 packages/vite/src/node/__tests__/plugins/importGlob/utils.test.ts delete mode 100644 packages/vite/src/node/importGlob.ts create mode 100644 packages/vite/src/node/plugins/importMetaGlob.ts create mode 100644 packages/vite/types/importGlob.d.ts diff --git a/docs/guide/features.md b/docs/guide/features.md index 1a8c03bbd0be22..01798ad0d4ea56 100644 --- a/docs/guide/features.md +++ b/docs/guide/features.md @@ -282,10 +282,10 @@ for (const path in modules) { } ``` -Matched files are by default lazy loaded via dynamic import and will be split into separate chunks during build. If you'd rather import all the modules directly (e.g. relying on side-effects in these modules to be applied first), you can use `import.meta.globEager` instead: +Matched files are by default lazy-loaded via dynamic import and will be split into separate chunks during build. If you'd rather import all the modules directly (e.g. relying on side-effects in these modules to be applied first), you can pass `{ eager: true }` as the second argument: ```js -const modules = import.meta.globEager('./dir/*.js') +const modules = import.meta.glob('./dir/*.js', { eager: true }) ``` The above will be transformed into the following: @@ -300,7 +300,9 @@ const modules = { } ``` -`import.meta.glob` and `import.meta.globEager` also support importing files as strings (similar to [Importing Asset as String](https://vitejs.dev/guide/assets.html#importing-asset-as-string)) with the [Import Reflection](https://github.com/tc39/proposal-import-reflection) syntax: +### Glob Import As + +`import.meta.glob` also supports importing files as strings (similar to [Importing Asset as String](https://vitejs.dev/guide/assets.html#importing-asset-as-string)) with the [Import Reflection](https://github.com/tc39/proposal-import-reflection) syntax: ```js const modules = import.meta.glob('./dir/*.js', { as: 'raw' }) @@ -311,18 +313,115 @@ The above will be transformed into the following: ```js // code produced by vite const modules = { - './dir/foo.js': '{\n "msg": "foo"\n}\n', - './dir/bar.js': '{\n "msg": "bar"\n}\n' + './dir/foo.js': 'export default "foo"\n', + './dir/bar.js': 'export default "bar"\n' +} +``` + +`{ as: 'url' }` is also supported for loading assets as URLs. + +### Multiple Patterns + +The first argument can be an array of globs, for example + +```js +const modules = import.meta.glob(['./dir/*.js', './another/*.js']) +``` + +### Negative Patterns + +Negative glob patterns are also supported (prefixed with `!`). To ignore some files from the result, you can add exclude glob patterns to the first argument: + +```js +const modules = import.meta.glob(['./dir/*.js', '!**/bar.js']) +``` + +```js +// code produced by vite +const modules = { + './dir/foo.js': () => import('./dir/foo.js') +} +``` + +#### Named Imports + +It's possible to only import parts of the modules with the `import` options. + +```ts +const modules = import.meta.glob('./dir/*.js', { import: 'setup' }) +``` + +```ts +// code produced by vite +const modules = { + './dir/foo.js': () => import('./dir/foo.js').then((m) => m.setup), + './dir/bar.js': () => import('./dir/bar.js').then((m) => m.setup) +} +``` + +When combined with `eager` it's even possible to have tree-shaking enabled for those modules. + +```ts +const modules = import.meta.glob('./dir/*.js', { import: 'setup', eager: true }) +``` + +```ts +// code produced by vite: +import { setup as __glob__0_0 } from './dir/foo.js' +import { setup as __glob__0_1 } from './dir/bar.js' +const modules = { + './dir/foo.js': __glob__0_0, + './dir/bar.js': __glob__0_1 +} +``` + +Set `import` to `default` to import the default export. + +```ts +const modules = import.meta.glob('./dir/*.js', { + import: 'default', + eager: true +}) +``` + +```ts +// code produced by vite: +import __glob__0_0 from './dir/foo.js' +import __glob__0_1 from './dir/bar.js' +const modules = { + './dir/foo.js': __glob__0_0, + './dir/bar.js': __glob__0_1 +} +``` + +#### Custom Queries + +You can also use the `query` option to provide custom queries to imports for other plugins to consume. + +```ts +const modules = import.meta.glob('./dir/*.js', { + query: { foo: 'bar', bar: true } +}) +``` + +```ts +// code produced by vite: +const modules = { + './dir/foo.js': () => + import('./dir/foo.js?foo=bar&bar=true').then((m) => m.setup), + './dir/bar.js': () => + import('./dir/bar.js?foo=bar&bar=true').then((m) => m.setup) } ``` +### Glob Import Caveats + Note that: - This is a Vite-only feature and is not a web or ES standard. - The glob patterns are treated like import specifiers: they must be either relative (start with `./`) or absolute (start with `/`, resolved relative to project root) or an alias path (see [`resolve.alias` option](/config/#resolve-alias)). -- The glob matching is done via `fast-glob` - check out its documentation for [supported glob patterns](https://github.com/mrmlnc/fast-glob#pattern-syntax). -- You should also be aware that glob imports do not accept variables, you need to directly pass the string pattern. -- The glob patterns cannot contain the same quote string (i.e. `'`, `"`, `` ` ``) as outer quotes, e.g. `'/Tom\'s files/**'`, use `"/Tom's files/**"` instead. +- The glob matching is done via [`fast-glob`](https://github.com/mrmlnc/fast-glob) - check out its documentation for [supported glob patterns](https://github.com/mrmlnc/fast-glob#pattern-syntax). +- You should also be aware that all the arguments in the `import.meta.glob` must be **passed as literals**. You can NOT use variables or expressions in them. ## WebAssembly diff --git a/packages/playground/assets/__tests__/assets.spec.ts b/packages/playground/assets/__tests__/assets.spec.ts index f1075f6fe1cb39..c63ffc7cc1c0c2 100644 --- a/packages/playground/assets/__tests__/assets.spec.ts +++ b/packages/playground/assets/__tests__/assets.spec.ts @@ -145,8 +145,8 @@ describe('css url() references', () => { expect(await getBg('.css-url-quotes-base64-inline')).toMatch(match) const icoMatch = isBuild ? `data:image/x-icon;base64` : `favicon.ico` const el = await page.$(`link.ico`) - const herf = await el.getAttribute('href') - expect(herf).toMatch(icoMatch) + const href = await el.getAttribute('href') + expect(href).toMatch(icoMatch) }) test('multiple urls on the same line', async () => { diff --git a/packages/playground/css/main.js b/packages/playground/css/main.js index f728b0251066d1..f6072ae751df76 100644 --- a/packages/playground/css/main.js +++ b/packages/playground/css/main.js @@ -80,7 +80,9 @@ text('.inlined-code', inlined) // glob const glob = import.meta.glob('./glob-import/*.css') -Promise.all(Object.keys(glob).map((key) => glob[key]())).then((res) => { +Promise.all( + Object.keys(glob).map((key) => glob[key]().then((i) => i.default)) +).then((res) => { text('.imported-css-glob', JSON.stringify(res, null, 2)) }) diff --git a/packages/playground/glob-import/__tests__/glob-import.spec.ts b/packages/playground/glob-import/__tests__/glob-import.spec.ts index ebdf6c0ab29193..d738ccec1d4c97 100644 --- a/packages/playground/glob-import/__tests__/glob-import.spec.ts +++ b/packages/playground/glob-import/__tests__/glob-import.spec.ts @@ -42,7 +42,7 @@ const allResult = { }, '/dir/index.js': { globWithAlias: { - './alias.js': { + '/dir/alias.js': { default: 'hi' } }, @@ -67,7 +67,7 @@ const rawResult = { } const relativeRawResult = { - '../glob-import/dir/baz.json': { + './dir/baz.json': { msg: 'baz' } } diff --git a/packages/vite/LICENSE.md b/packages/vite/LICENSE.md index 80feb7f95c6941..2b43883f1b2b67 100644 --- a/packages/vite/LICENSE.md +++ b/packages/vite/LICENSE.md @@ -3606,6 +3606,34 @@ Repository: git+https://github.com/dominikg/tsconfck.git --------------------------------------- +## ufo +License: MIT +Repository: unjs/ufo + +> MIT License +> +> Copyright (c) 2020 Nuxt Contrib +> +> Permission is hereby granted, free of charge, to any person obtaining a copy +> of this software and associated documentation files (the "Software"), to deal +> in the Software without restriction, including without limitation the rights +> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +> copies of the Software, and to permit persons to whom the Software is +> furnished to do so, subject to the following conditions: +> +> The above copyright notice and this permission notice shall be included in all +> copies or substantial portions of the Software. +> +> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +> SOFTWARE. + +--------------------------------------- + ## unpipe License: MIT By: Douglas Christopher Wilson diff --git a/packages/vite/package.json b/packages/vite/package.json index b508842619033e..2e930f0f1f6741 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -112,11 +112,12 @@ "source-map-js": "^1.0.2", "source-map-support": "^0.5.21", "strip-ansi": "^6.0.1", - "strip-literal": "^0.2.0", + "strip-literal": "^0.3.0", "terser": "^5.13.1", "tsconfck": "^1.2.2", "tslib": "^2.4.0", "types": "link:./types", + "ufo": "^0.8.4", "ws": "^8.6.0" }, "peerDependencies": { diff --git a/packages/vite/src/node/__tests__/plugins/importGlob/__snapshots__/fixture.test.ts.snap b/packages/vite/src/node/__tests__/plugins/importGlob/__snapshots__/fixture.test.ts.snap new file mode 100644 index 00000000000000..3b611c60c9cedc --- /dev/null +++ b/packages/vite/src/node/__tests__/plugins/importGlob/__snapshots__/fixture.test.ts.snap @@ -0,0 +1,154 @@ +// Vitest Snapshot v1 + +exports[`fixture > transform 1`] = ` +"import * as __vite_glob_1_0 from \\"./modules/a.ts\\" +import * as __vite_glob_1_1 from \\"./modules/b.ts\\" +import * as __vite_glob_1_2 from \\"./modules/index.ts\\" +import { name as __vite_glob_3_0 } from \\"./modules/a.ts\\" +import { name as __vite_glob_3_1 } from \\"./modules/b.ts\\" +import { name as __vite_glob_3_2 } from \\"./modules/index.ts\\" +import { default as __vite_glob_5_0 } from \\"./modules/a.ts?raw\\" +import { default as __vite_glob_5_1 } from \\"./modules/b.ts?raw\\" +import \\"../../../../../../types/importMeta\\"; +export const basic = { +\\"./modules/a.ts\\": () => import(\\"./modules/a.ts\\"), +\\"./modules/b.ts\\": () => import(\\"./modules/b.ts\\"), +\\"./modules/index.ts\\": () => import(\\"./modules/index.ts\\") +}; +export const basicEager = { +\\"./modules/a.ts\\": __vite_glob_1_0, +\\"./modules/b.ts\\": __vite_glob_1_1, +\\"./modules/index.ts\\": __vite_glob_1_2 +}; +export const ignore = { +\\"./modules/a.ts\\": () => import(\\"./modules/a.ts\\"), +\\"./modules/b.ts\\": () => import(\\"./modules/b.ts\\") +}; +export const namedEager = { +\\"./modules/a.ts\\": __vite_glob_3_0, +\\"./modules/b.ts\\": __vite_glob_3_1, +\\"./modules/index.ts\\": __vite_glob_3_2 +}; +export const namedDefault = { +\\"./modules/a.ts\\": () => import(\\"./modules/a.ts\\").then(m => m[\\"default\\"]), +\\"./modules/b.ts\\": () => import(\\"./modules/b.ts\\").then(m => m[\\"default\\"]), +\\"./modules/index.ts\\": () => import(\\"./modules/index.ts\\").then(m => m[\\"default\\"]) +}; +export const eagerAs = { +\\"./modules/a.ts\\": __vite_glob_5_0, +\\"./modules/b.ts\\": __vite_glob_5_1 +}; +export const excludeSelf = { +\\"./sibling.ts\\": () => import(\\"./sibling.ts\\") +}; +export const customQueryString = { +\\"./sibling.ts\\": () => import(\\"./sibling.ts?custom\\") +}; +export const customQueryObject = { +\\"./sibling.ts\\": () => import(\\"./sibling.ts?foo=bar&raw=true\\") +}; +export const parent = { + +}; +export const rootMixedRelative = { +\\"/css.spec.ts\\": () => import(\\"../../css.spec.ts?url\\").then(m => m[\\"default\\"]), +\\"/define.spec.ts\\": () => import(\\"../../define.spec.ts?url\\").then(m => m[\\"default\\"]), +\\"/import.spec.ts\\": () => import(\\"../../import.spec.ts?url\\").then(m => m[\\"default\\"]), +\\"/importGlob/fixture-b/a.ts\\": () => import(\\"../fixture-b/a.ts?url\\").then(m => m[\\"default\\"]), +\\"/importGlob/fixture-b/b.ts\\": () => import(\\"../fixture-b/b.ts?url\\").then(m => m[\\"default\\"]), +\\"/importGlob/fixture-b/index.ts\\": () => import(\\"../fixture-b/index.ts?url\\").then(m => m[\\"default\\"]) +}; +export const cleverCwd1 = { +\\"./node_modules/framework/pages/hello.page.js\\": () => import(\\"./node_modules/framework/pages/hello.page.js\\") +}; +export const cleverCwd2 = { +\\"./modules/a.ts\\": () => import(\\"./modules/a.ts\\"), +\\"./modules/b.ts\\": () => import(\\"./modules/b.ts\\"), +\\"../fixture-b/a.ts\\": () => import(\\"../fixture-b/a.ts\\"), +\\"../fixture-b/b.ts\\": () => import(\\"../fixture-b/b.ts\\") +}; +" +`; + +exports[`fixture > transform with restoreQueryExtension 1`] = ` +"import * as __vite_glob_1_0 from \\"./modules/a.ts\\" +import * as __vite_glob_1_1 from \\"./modules/b.ts\\" +import * as __vite_glob_1_2 from \\"./modules/index.ts\\" +import { name as __vite_glob_3_0 } from \\"./modules/a.ts\\" +import { name as __vite_glob_3_1 } from \\"./modules/b.ts\\" +import { name as __vite_glob_3_2 } from \\"./modules/index.ts\\" +import { default as __vite_glob_5_0 } from \\"./modules/a.ts?raw\\" +import { default as __vite_glob_5_1 } from \\"./modules/b.ts?raw\\" +import \\"../../../../../../types/importMeta\\"; +export const basic = { +\\"./modules/a.ts\\": () => import(\\"./modules/a.ts\\"), +\\"./modules/b.ts\\": () => import(\\"./modules/b.ts\\"), +\\"./modules/index.ts\\": () => import(\\"./modules/index.ts\\") +}; +export const basicEager = { +\\"./modules/a.ts\\": __vite_glob_1_0, +\\"./modules/b.ts\\": __vite_glob_1_1, +\\"./modules/index.ts\\": __vite_glob_1_2 +}; +export const ignore = { +\\"./modules/a.ts\\": () => import(\\"./modules/a.ts\\"), +\\"./modules/b.ts\\": () => import(\\"./modules/b.ts\\") +}; +export const namedEager = { +\\"./modules/a.ts\\": __vite_glob_3_0, +\\"./modules/b.ts\\": __vite_glob_3_1, +\\"./modules/index.ts\\": __vite_glob_3_2 +}; +export const namedDefault = { +\\"./modules/a.ts\\": () => import(\\"./modules/a.ts\\").then(m => m[\\"default\\"]), +\\"./modules/b.ts\\": () => import(\\"./modules/b.ts\\").then(m => m[\\"default\\"]), +\\"./modules/index.ts\\": () => import(\\"./modules/index.ts\\").then(m => m[\\"default\\"]) +}; +export const eagerAs = { +\\"./modules/a.ts\\": __vite_glob_5_0, +\\"./modules/b.ts\\": __vite_glob_5_1 +}; +export const excludeSelf = { +\\"./sibling.ts\\": () => import(\\"./sibling.ts\\") +}; +export const customQueryString = { +\\"./sibling.ts\\": () => import(\\"./sibling.ts?custom&lang.ts\\") +}; +export const customQueryObject = { +\\"./sibling.ts\\": () => import(\\"./sibling.ts?foo=bar&raw=true&lang.ts\\") +}; +export const parent = { + +}; +export const rootMixedRelative = { +\\"/css.spec.ts\\": () => import(\\"../../css.spec.ts?url&lang.ts\\").then(m => m[\\"default\\"]), +\\"/define.spec.ts\\": () => import(\\"../../define.spec.ts?url&lang.ts\\").then(m => m[\\"default\\"]), +\\"/import.spec.ts\\": () => import(\\"../../import.spec.ts?url&lang.ts\\").then(m => m[\\"default\\"]), +\\"/importGlob/fixture-b/a.ts\\": () => import(\\"../fixture-b/a.ts?url&lang.ts\\").then(m => m[\\"default\\"]), +\\"/importGlob/fixture-b/b.ts\\": () => import(\\"../fixture-b/b.ts?url&lang.ts\\").then(m => m[\\"default\\"]), +\\"/importGlob/fixture-b/index.ts\\": () => import(\\"../fixture-b/index.ts?url&lang.ts\\").then(m => m[\\"default\\"]) +}; +export const cleverCwd1 = { +\\"./node_modules/framework/pages/hello.page.js\\": () => import(\\"./node_modules/framework/pages/hello.page.js\\") +}; +export const cleverCwd2 = { +\\"./modules/a.ts\\": () => import(\\"./modules/a.ts\\"), +\\"./modules/b.ts\\": () => import(\\"./modules/b.ts\\"), +\\"../fixture-b/a.ts\\": () => import(\\"../fixture-b/a.ts\\"), +\\"../fixture-b/b.ts\\": () => import(\\"../fixture-b/b.ts\\") +}; +" +`; + +exports[`fixture > virtual modules 1`] = ` +"{ +\\"/modules/a.ts\\": () => import(\\"/modules/a.ts\\"), +\\"/modules/b.ts\\": () => import(\\"/modules/b.ts\\"), +\\"/modules/index.ts\\": () => import(\\"/modules/index.ts\\") +} +{ +\\"/../fixture-b/a.ts\\": () => import(\\"/../fixture-b/a.ts\\"), +\\"/../fixture-b/b.ts\\": () => import(\\"/../fixture-b/b.ts\\"), +\\"/../fixture-b/index.ts\\": () => import(\\"/../fixture-b/index.ts\\") +}" +`; diff --git a/packages/vite/src/node/__tests__/plugins/importGlob/fixture-a/.gitignore b/packages/vite/src/node/__tests__/plugins/importGlob/fixture-a/.gitignore new file mode 100644 index 00000000000000..2b9b8877da603f --- /dev/null +++ b/packages/vite/src/node/__tests__/plugins/importGlob/fixture-a/.gitignore @@ -0,0 +1 @@ +!/node_modules/ diff --git a/packages/vite/src/node/__tests__/plugins/importGlob/fixture-a/index.ts b/packages/vite/src/node/__tests__/plugins/importGlob/fixture-a/index.ts new file mode 100644 index 00000000000000..c5b806da06a4b4 --- /dev/null +++ b/packages/vite/src/node/__tests__/plugins/importGlob/fixture-a/index.ts @@ -0,0 +1,64 @@ +import '../../../../../../types/importMeta' + +/* eslint-disable @typescript-eslint/comma-dangle */ +export interface ModuleType { + name: string +} + +export const basic = import.meta.glob('./modules/*.ts') + +export const basicEager = import.meta.glob('./modules/*.ts', { + eager: true +}) + +export const ignore = import.meta.glob(['./modules/*.ts', '!**/index.ts']) + +export const namedEager = import.meta.glob('./modules/*.ts', { + eager: true, + import: 'name' +}) + +export const namedDefault = import.meta.glob('./modules/*.ts', { + import: 'default' +}) + +export const eagerAs = import.meta.glob( + ['./modules/*.ts', '!**/index.ts'], + { eager: true, as: 'raw' } +) + +export const excludeSelf = import.meta.glob( + './*.ts' + // for test: annotation contain ")" + /* + * for test: annotation contain ")" + * */ +) + +export const customQueryString = import.meta.glob('./*.ts', { query: 'custom' }) + +export const customQueryObject = import.meta.glob('./*.ts', { + query: { + foo: 'bar', + raw: true + } +}) + +export const parent = import.meta.glob('../../playground/src/*.ts', { + as: 'url' +}) + +export const rootMixedRelative = import.meta.glob( + ['/*.ts', '../fixture-b/*.ts'], + { as: 'url' } +) + +export const cleverCwd1 = import.meta.glob( + './node_modules/framework/**/*.page.js' +) + +export const cleverCwd2 = import.meta.glob([ + './modules/*.ts', + '../fixture-b/*.ts', + '!**/index.ts' +]) diff --git a/packages/vite/src/node/__tests__/plugins/importGlob/fixture-a/modules/a.ts b/packages/vite/src/node/__tests__/plugins/importGlob/fixture-a/modules/a.ts new file mode 100644 index 00000000000000..facd48a0875e65 --- /dev/null +++ b/packages/vite/src/node/__tests__/plugins/importGlob/fixture-a/modules/a.ts @@ -0,0 +1 @@ +export const name = 'a' diff --git a/packages/vite/src/node/__tests__/plugins/importGlob/fixture-a/modules/b.ts b/packages/vite/src/node/__tests__/plugins/importGlob/fixture-a/modules/b.ts new file mode 100644 index 00000000000000..0b1eb38d9087a2 --- /dev/null +++ b/packages/vite/src/node/__tests__/plugins/importGlob/fixture-a/modules/b.ts @@ -0,0 +1 @@ +export const name = 'b' diff --git a/packages/vite/src/node/__tests__/plugins/importGlob/fixture-a/modules/index.ts b/packages/vite/src/node/__tests__/plugins/importGlob/fixture-a/modules/index.ts new file mode 100644 index 00000000000000..25b59ae7d30714 --- /dev/null +++ b/packages/vite/src/node/__tests__/plugins/importGlob/fixture-a/modules/index.ts @@ -0,0 +1,6 @@ +export { name as a } from './a' +export { name as b } from './b' + +export const name = 'index' + +export default 'indexDefault' diff --git a/packages/vite/src/node/__tests__/plugins/importGlob/fixture-a/node_modules/framework/pages/hello.page.js b/packages/vite/src/node/__tests__/plugins/importGlob/fixture-a/node_modules/framework/pages/hello.page.js new file mode 100644 index 00000000000000..cbe518a8e79477 --- /dev/null +++ b/packages/vite/src/node/__tests__/plugins/importGlob/fixture-a/node_modules/framework/pages/hello.page.js @@ -0,0 +1,4 @@ +// A fake Page file. (This technique of globbing into `node_modules/` +// is used by vite-plugin-ssr frameworks and Hydrogen.) + +export const a = 1 diff --git a/packages/vite/src/node/__tests__/plugins/importGlob/fixture-a/sibling.ts b/packages/vite/src/node/__tests__/plugins/importGlob/fixture-a/sibling.ts new file mode 100644 index 00000000000000..b286816bf5d63a --- /dev/null +++ b/packages/vite/src/node/__tests__/plugins/importGlob/fixture-a/sibling.ts @@ -0,0 +1 @@ +export const name = 'I am your sibling!' diff --git a/packages/vite/src/node/__tests__/plugins/importGlob/fixture-b/a.ts b/packages/vite/src/node/__tests__/plugins/importGlob/fixture-b/a.ts new file mode 100644 index 00000000000000..facd48a0875e65 --- /dev/null +++ b/packages/vite/src/node/__tests__/plugins/importGlob/fixture-b/a.ts @@ -0,0 +1 @@ +export const name = 'a' diff --git a/packages/vite/src/node/__tests__/plugins/importGlob/fixture-b/b.ts b/packages/vite/src/node/__tests__/plugins/importGlob/fixture-b/b.ts new file mode 100644 index 00000000000000..0b1eb38d9087a2 --- /dev/null +++ b/packages/vite/src/node/__tests__/plugins/importGlob/fixture-b/b.ts @@ -0,0 +1 @@ +export const name = 'b' diff --git a/packages/vite/src/node/__tests__/plugins/importGlob/fixture-b/index.ts b/packages/vite/src/node/__tests__/plugins/importGlob/fixture-b/index.ts new file mode 100644 index 00000000000000..39bdbfd1a8befb --- /dev/null +++ b/packages/vite/src/node/__tests__/plugins/importGlob/fixture-b/index.ts @@ -0,0 +1,2 @@ +export { name as a } from './a' +export { name as b } from './b' diff --git a/packages/vite/src/node/__tests__/plugins/importGlob/fixture.test.ts b/packages/vite/src/node/__tests__/plugins/importGlob/fixture.test.ts new file mode 100644 index 00000000000000..985263d91db85a --- /dev/null +++ b/packages/vite/src/node/__tests__/plugins/importGlob/fixture.test.ts @@ -0,0 +1,59 @@ +import { resolve } from 'path' +import { promises as fs } from 'fs' +import { describe, expect, it } from 'vitest' +import { transformGlobImport } from '../../../plugins/importMetaGlob' +import { transformWithEsbuild } from '../../../plugins/esbuild' + +describe('fixture', async () => { + const resolveId = (id: string) => id + const root = resolve(__dirname, '..') + + it('transform', async () => { + const id = resolve(__dirname, './fixture-a/index.ts') + const code = ( + await transformWithEsbuild(await fs.readFile(id, 'utf-8'), id) + ).code + + expect( + (await transformGlobImport(code, id, root, resolveId))?.s.toString() + ).toMatchSnapshot() + }) + + it('virtual modules', async () => { + const root = resolve(__dirname, './fixture-a') + const code = [ + "import.meta.glob('/modules/*.ts')", + "import.meta.glob(['/../fixture-b/*.ts'])" + ].join('\n') + expect( + ( + await transformGlobImport(code, 'virtual:module', root, resolveId) + )?.s.toString() + ).toMatchSnapshot() + + try { + await transformGlobImport( + "import.meta.glob('./modules/*.ts')", + 'virtual:module', + root, + resolveId + ) + expect('no error').toBe('should throw an error') + } catch (err) { + expect(err).toMatchInlineSnapshot( + "[Error: In virtual modules, all globs must start with '/']" + ) + } + }) + + it('transform with restoreQueryExtension', async () => { + const id = resolve(__dirname, './fixture-a/index.ts') + const code = ( + await transformWithEsbuild(await fs.readFile(id, 'utf-8'), id) + ).code + + expect( + (await transformGlobImport(code, id, root, resolveId, true))?.s.toString() + ).toMatchSnapshot() + }) +}) diff --git a/packages/vite/src/node/__tests__/plugins/importGlob/parse.test.ts b/packages/vite/src/node/__tests__/plugins/importGlob/parse.test.ts new file mode 100644 index 00000000000000..df1e0d758e8849 --- /dev/null +++ b/packages/vite/src/node/__tests__/plugins/importGlob/parse.test.ts @@ -0,0 +1,202 @@ +import { describe, expect, it } from 'vitest' +import { parseImportGlob } from '../../../plugins/importMetaGlob' + +async function run(input: string) { + const items = await parseImportGlob( + input, + process.cwd(), + process.cwd(), + (id) => id + ) + return items.map((i) => ({ globs: i.globs, options: i.options })) +} + +async function runError(input: string) { + try { + await run(input) + } catch (e) { + return e + } +} + +describe('parse positives', async () => { + it('basic', async () => { + expect( + await run(` + import.meta.importGlob(\'./modules/*.ts\') + `) + ).toMatchInlineSnapshot('[]') + }) + + it('array', async () => { + expect( + await run(` + import.meta.importGlob([\'./modules/*.ts\', './dir/*.{js,ts}\']) + `) + ).toMatchInlineSnapshot('[]') + }) + + it('options with multilines', async () => { + expect( + await run(` + import.meta.importGlob([ + \'./modules/*.ts\', + "!./dir/*.{js,ts}" + ], { + eager: true, + import: 'named' + }) + `) + ).toMatchInlineSnapshot('[]') + }) + + it('options with multilines', async () => { + expect( + await run(` + const modules = import.meta.glob( + '/dir/**' + // for test: annotation contain ")" + /* + * for test: annotation contain ")" + * */ + ) + `) + ).toMatchInlineSnapshot(` + [ + { + "globs": [ + "/dir/**", + ], + "options": {}, + }, + ] + `) + }) + + it('options query', async () => { + expect( + await run(` + const modules = import.meta.glob( + '/dir/**', + { + query: { + foo: 'bar', + raw: true, + } + } + ) + `) + ).toMatchInlineSnapshot(` + [ + { + "globs": [ + "/dir/**", + ], + "options": { + "query": { + "foo": "bar", + "raw": true, + }, + }, + }, + ] + `) + }) +}) + +describe('parse negatives', async () => { + it('syntax error', async () => { + expect(await runError('import.meta.importGlob(')).toMatchInlineSnapshot( + 'undefined' + ) + }) + + it('empty', async () => { + expect(await runError('import.meta.importGlob()')).toMatchInlineSnapshot( + 'undefined' + ) + }) + + it('3 args', async () => { + expect( + await runError('import.meta.importGlob("", {}, {})') + ).toMatchInlineSnapshot('undefined') + }) + + it('in string', async () => { + expect(await runError('"import.meta.importGlob()"')).toBeUndefined() + }) + + it('variable', async () => { + expect(await runError('import.meta.importGlob(hey)')).toMatchInlineSnapshot( + 'undefined' + ) + }) + + it('template', async () => { + // eslint-disable-next-line no-template-curly-in-string + expect( + await runError('import.meta.importGlob(`hi ${hey}`)') + ).toMatchInlineSnapshot('undefined') + }) + + it('be string', async () => { + expect(await runError('import.meta.importGlob(1)')).toMatchInlineSnapshot( + 'undefined' + ) + }) + + it('be array variable', async () => { + expect( + await runError('import.meta.importGlob([hey])') + ).toMatchInlineSnapshot('undefined') + expect( + await runError('import.meta.importGlob(["1", hey])') + ).toMatchInlineSnapshot('undefined') + }) + + it('options', async () => { + expect( + await runError('import.meta.importGlob("hey", hey)') + ).toMatchInlineSnapshot('undefined') + expect( + await runError('import.meta.importGlob("hey", [])') + ).toMatchInlineSnapshot('undefined') + }) + + it('options props', async () => { + expect( + await runError('import.meta.importGlob("hey", { hey: 1 })') + ).toMatchInlineSnapshot('undefined') + expect( + await runError('import.meta.importGlob("hey", { import: hey })') + ).toMatchInlineSnapshot('undefined') + expect( + await runError('import.meta.importGlob("hey", { eager: 123 })') + ).toMatchInlineSnapshot('undefined') + }) + + it('options query', async () => { + expect( + await runError( + 'import.meta.importGlob("./*.js", { as: "raw", query: "hi" })' + ) + ).toMatchInlineSnapshot('undefined') + expect( + await runError('import.meta.importGlob("./*.js", { query: 123 })') + ).toMatchInlineSnapshot('undefined') + expect( + await runError('import.meta.importGlob("./*.js", { query: { foo: {} } })') + ).toMatchInlineSnapshot('undefined') + expect( + await runError( + 'import.meta.importGlob("./*.js", { query: { foo: hey } })' + ) + ).toMatchInlineSnapshot('undefined') + expect( + await runError( + 'import.meta.importGlob("./*.js", { query: { foo: 123, ...a } })' + ) + ).toMatchInlineSnapshot('undefined') + }) +}) diff --git a/packages/vite/src/node/__tests__/plugins/importGlob/utils.test.ts b/packages/vite/src/node/__tests__/plugins/importGlob/utils.test.ts new file mode 100644 index 00000000000000..302df97ec92ede --- /dev/null +++ b/packages/vite/src/node/__tests__/plugins/importGlob/utils.test.ts @@ -0,0 +1,31 @@ +import { describe, expect, it } from 'vitest' +import { getCommonBase } from '../../../plugins/importMetaGlob' + +describe('getCommonBase()', async () => { + it('basic', () => { + expect(getCommonBase(['/a/b/*.js', '/a/c/*.js'])).toBe('/a') + }) + it('common base', () => { + expect(getCommonBase(['/a/b/**/*.vue', '/a/b/**/*.jsx'])).toBe('/a/b') + }) + it('static file', () => { + expect( + getCommonBase(['/a/b/**/*.vue', '/a/b/**/*.jsx', '/a/b/foo.js']) + ).toBe('/a/b') + expect(getCommonBase(['/a/b/**/*.vue', '/a/b/**/*.jsx', '/a/foo.js'])).toBe( + '/a' + ) + }) + it('correct `scan()`', () => { + expect(getCommonBase(['/a/*.vue'])).toBe('/a') + expect(getCommonBase(['/a/some.vue'])).toBe('/a') + expect(getCommonBase(['/a/b/**/c/foo.vue', '/a/b/c/**/*.jsx'])).toBe('/a/b') + }) + it('single', () => { + expect(getCommonBase(['/a/b/c/*.vue'])).toBe('/a/b/c') + expect(getCommonBase(['/a/b/c/foo.vue'])).toBe('/a/b/c') + }) + it('no common base', () => { + expect(getCommonBase(['/a/b/*.js', '/c/a/b/*.js'])).toBe('/') + }) +}) diff --git a/packages/vite/src/node/config.ts b/packages/vite/src/node/config.ts index 29dc3fe2045a5a..e7fcaefeb2a799 100644 --- a/packages/vite/src/node/config.ts +++ b/packages/vite/src/node/config.ts @@ -152,6 +152,14 @@ export interface UserConfig { * @alpha */ ssr?: SSROptions + /** + * Experimental features + * + * Features under this field are addressed to be changed that might NOT follow semver. + * Please be careful and always pin Vite's version when using them. + * @experimental + */ + experimental?: ExperimentalOptions /** * Log level. * Default: 'info' @@ -199,6 +207,16 @@ export interface UserConfig { } } +export interface ExperimentalOptions { + /** + * Append fake `&lang.(ext)` when queries are specified, to preseve the file extension for following plugins to process. + * + * @experimental + * @default false + */ + importGlobRestoreExtension?: boolean +} + export type SSRTarget = 'node' | 'webworker' export interface SSROptions { diff --git a/packages/vite/src/node/importGlob.ts b/packages/vite/src/node/importGlob.ts deleted file mode 100644 index ab425bb596c68a..00000000000000 --- a/packages/vite/src/node/importGlob.ts +++ /dev/null @@ -1,246 +0,0 @@ -import path from 'path' -import { promises as fsp } from 'fs' -import glob from 'fast-glob' -import JSON5 from 'json5' -import { - isModernFlag, - preloadMethod, - preloadMarker -} from './plugins/importAnalysisBuild' -import { isCSSRequest } from './plugins/css' -import { - cleanUrl, - singlelineCommentsRE, - multilineCommentsRE, - blankReplacer, - normalizePath -} from './utils' -import type { RollupError } from 'rollup' -import type { Logger } from '.' - -interface GlobParams { - base: string - pattern: string - parentDepth: number - isAbsolute: boolean -} - -interface GlobOptions { - as?: string -} - -function formatGlobRelativePattern(base: string, pattern: string): GlobParams { - let parentDepth = 0 - while (pattern.startsWith('../')) { - pattern = pattern.slice(3) - base = path.resolve(base, '../') - parentDepth++ - } - if (pattern.startsWith('./')) { - pattern = pattern.slice(2) - } - - return { base, pattern, parentDepth, isAbsolute: false } -} - -export async function transformImportGlob( - source: string, - pos: number, - importer: string, - importIndex: number, - root: string, - logger: Logger, - normalizeUrl?: (url: string, pos: number) => Promise<[string, string]>, - resolve?: (url: string, importer?: string) => Promise, - preload = true -): Promise<{ - importsString: string - imports: string[] - exp: string - endIndex: number - isEager: boolean - pattern: string - base: string -}> { - const isEager = source.slice(pos, pos + 21) === 'import.meta.globEager' - const isEagerDefault = - isEager && source.slice(pos + 21, pos + 28) === 'Default' - - const err = (msg: string) => { - const e = new Error(`Invalid glob import syntax: ${msg}`) - ;(e as any).pos = pos - return e - } - - importer = cleanUrl(importer) - const importerBasename = path.basename(importer) - - const [userPattern, options, endIndex] = lexGlobPattern(source, pos) - - let globParams: GlobParams | null = null - if (userPattern.startsWith('/')) { - globParams = { - isAbsolute: true, - base: path.resolve(root), - pattern: userPattern.slice(1), - parentDepth: 0 - } - } else if (userPattern.startsWith('.')) { - globParams = formatGlobRelativePattern(path.dirname(importer), userPattern) - } else if (resolve) { - const resolvedId = await resolve(userPattern, importer) - if (resolvedId) { - const importerDirname = path.dirname(importer) - globParams = formatGlobRelativePattern( - importerDirname, - normalizePath(path.relative(importerDirname, resolvedId)) - ) - } - } - - if (!globParams) { - throw err( - `pattern must start with "." or "/" (relative to project root) or alias path` - ) - } - const { base, parentDepth, isAbsolute, pattern } = globParams - - const files = glob.sync(pattern, { - cwd: base, - // Ignore node_modules by default unless explicitly indicated in the pattern - ignore: /(^|\/)node_modules\//.test(pattern) ? [] : ['**/node_modules/**'] - }) - const imports: string[] = [] - let importsString = `` - let entries = `` - for (let i = 0; i < files.length; i++) { - // skip importer itself - if (files[i] === importerBasename) continue - const file = isAbsolute - ? `/${files[i]}` - : parentDepth - ? `${'../'.repeat(parentDepth)}${files[i]}` - : `./${files[i]}` - let importee = file - if (normalizeUrl) { - ;[importee] = await normalizeUrl(file, pos) - } - imports.push(importee) - - const isRawType = options?.as === 'raw' - if (isRawType) { - entries += ` ${JSON.stringify(file)}: ${JSON.stringify( - await fsp.readFile(path.join(base, files[i]), 'utf-8') - )},` - } else { - const importeeUrl = isCSSRequest(importee) ? `${importee}?used` : importee - if (isEager) { - const identifier = `__glob_${importIndex}_${i}` - // css imports injecting a ?used query to export the css string - importsString += `import ${ - isEagerDefault ? `` : `* as ` - }${identifier} from ${JSON.stringify(importeeUrl)};` - entries += ` ${JSON.stringify(file)}: ${identifier},` - } else { - let imp = `import(${JSON.stringify(importeeUrl)})` - if (!normalizeUrl && preload) { - imp = - `(${isModernFlag}` + - `? ${preloadMethod}(()=>${imp},"${preloadMarker}")` + - `: ${imp})` - } - entries += ` ${JSON.stringify(file)}: () => ${imp},` - } - } - } - - return { - imports, - importsString, - exp: `{${entries}}`, - endIndex, - isEager, - pattern, - base - } -} - -const enum LexerState { - inCall, - inSingleQuoteString, - inDoubleQuoteString, - inTemplateString -} - -function lexGlobPattern( - code: string, - pos: number -): [string, GlobOptions, number] { - let state = LexerState.inCall - let pattern = '' - - let i = code.indexOf(`(`, pos) + 1 - outer: for (; i < code.length; i++) { - const char = code.charAt(i) - switch (state) { - case LexerState.inCall: - if (char === `'`) { - state = LexerState.inSingleQuoteString - } else if (char === `"`) { - state = LexerState.inDoubleQuoteString - } else if (char === '`') { - state = LexerState.inTemplateString - } else if (/\s/.test(char)) { - continue - } else { - error(i) - } - break - case LexerState.inSingleQuoteString: - if (char === `'`) { - break outer - } else { - pattern += char - } - break - case LexerState.inDoubleQuoteString: - if (char === `"`) { - break outer - } else { - pattern += char - } - break - case LexerState.inTemplateString: - if (char === '`') { - break outer - } else { - pattern += char - } - break - default: - throw new Error('unknown import.meta.glob lexer state') - } - } - const noCommentCode = code - .slice(i + 1) - .replace(singlelineCommentsRE, blankReplacer) - .replace(multilineCommentsRE, blankReplacer) - - const endIndex = noCommentCode.indexOf(')') - const optionString = noCommentCode.substring(0, endIndex) - const commaIndex = optionString.indexOf(',') - - let options = {} - if (commaIndex > -1) { - options = JSON5.parse(optionString.substring(commaIndex + 1)) - } - return [pattern, options, endIndex + i + 2] -} - -function error(pos: number) { - const err = new Error( - `import.meta.glob() can only accept string literals.` - ) as RollupError - err.pos = pos - throw err -} diff --git a/packages/vite/src/node/index.ts b/packages/vite/src/node/index.ts index e56f4c6e765756..0d401363b8a3b6 100644 --- a/packages/vite/src/node/index.ts +++ b/packages/vite/src/node/index.ts @@ -74,6 +74,9 @@ export type { TransformOptions as EsbuildTransformOptions } from 'esbuild' export type { ESBuildOptions, ESBuildTransformResult } from './plugins/esbuild' export type { Manifest, ManifestChunk } from './plugins/manifest' export type { ResolveOptions, InternalResolveOptions } from './plugins/resolve' +export type { SplitVendorChunkCache } from './plugins/splitVendorChunk' +import type { ChunkMetadata } from './plugins/metadata' + export type { WebSocketServer, WebSocketClient, @@ -88,6 +91,7 @@ export type { TransformResult } from './server/transformRequest' export type { HmrOptions, HmrContext } from './server/hmr' + export type { HMRPayload, ConnectedPayload, @@ -111,9 +115,12 @@ export type { RollupCommonJSOptions } from 'types/commonjs' export type { RollupDynamicImportVarsOptions } from 'types/dynamicImportVars' export type { CustomEventMap, InferCustomEventPayload } from 'types/customEvent' export type { Matcher, AnymatchPattern, AnymatchFn } from 'types/anymatch' -export type { SplitVendorChunkCache } from './plugins/splitVendorChunk' - -import type { ChunkMetadata } from './plugins/metadata' +export type { + ImportGlobFunction, + ImportGlobEagerFunction, + ImportGlobOptions, + KnownAsTypeMap +} from 'types/importGlob' declare module 'rollup' { export interface RenderedChunk { diff --git a/packages/vite/src/node/optimizer/scan.ts b/packages/vite/src/node/optimizer/scan.ts index ef59a35b1d22d3..111aefc40dea15 100644 --- a/packages/vite/src/node/optimizer/scan.ts +++ b/packages/vite/src/node/optimizer/scan.ts @@ -1,9 +1,9 @@ import fs from 'fs' import path from 'path' import glob from 'fast-glob' -import type { ResolvedConfig, Logger } from '..' +import type { ResolvedConfig } from '..' import type { Loader, Plugin, OnLoadResult } from 'esbuild' -import { build, transform } from 'esbuild' +import { build } from 'esbuild' import { KNOWN_ASSET_TYPES, JS_TYPES_RE, @@ -25,11 +25,9 @@ import { } from '../utils' import type { PluginContainer } from '../server/pluginContainer' import { createPluginContainer } from '../server/pluginContainer' -import { init, parse } from 'es-module-lexer' -import MagicString from 'magic-string' -import { transformImportGlob } from '../importGlob' import { performance } from 'perf_hooks' import colors from 'picocolors' +import { transformGlobImport } from '../plugins/importMetaGlob' const debug = createDebugger('vite:deps') @@ -300,19 +298,18 @@ function esbuildScanPlugin( (loader.startsWith('ts') ? extractImportPaths(content) : '') const key = `${path}?id=${scriptId++}` - if (contents.includes('import.meta.glob')) { scripts[key] = { - // transformGlob already transforms to js loader: 'js', - contents: await transformGlob( - contents, - path, - config.root, - loader, - resolve, - config.logger - ) + contents: + ( + await transformGlobImport( + contents, + path, + config.root, + resolve + ) + )?.s.toString() || contents } } else { scripts[key] = { @@ -467,20 +464,6 @@ function esbuildScanPlugin( config.optimizeDeps?.esbuildOptions?.loader?.[`.${ext}`] || (ext as Loader) - if (contents.includes('import.meta.glob')) { - return transformGlob( - contents, - id, - config.root, - loader, - resolve, - config.logger - ).then((contents) => ({ - loader, - contents - })) - } - return { loader, contents @@ -490,43 +473,6 @@ function esbuildScanPlugin( } } -async function transformGlob( - source: string, - importer: string, - root: string, - loader: Loader, - resolve: (url: string, importer?: string) => Promise, - logger: Logger -) { - // transform the content first since es-module-lexer can't handle non-js - if (loader !== 'js') { - source = (await transform(source, { loader })).code - } - - await init - const imports = parse(source)[0] - const s = new MagicString(source) - for (let index = 0; index < imports.length; index++) { - const { s: start, e: end, ss: expStart } = imports[index] - const url = source.slice(start, end) - if (url !== 'import.meta') continue - if (source.slice(end, end + 5) !== '.glob') continue - const { importsString, exp, endIndex } = await transformImportGlob( - source, - start, - normalizePath(importer), - index, - root, - logger, - undefined, - resolve - ) - s.prepend(importsString) - s.overwrite(expStart, endIndex, exp, { contentOnly: true }) - } - return s.toString() -} - /** * when using TS + (Vue + `
diff --git a/playground/css-codesplit/inline.css b/playground/css-codesplit/inline.css new file mode 100644 index 00000000000000..b2a2b5f1ead51f --- /dev/null +++ b/playground/css-codesplit/inline.css @@ -0,0 +1,3 @@ +.inline { + color: yellow; +} diff --git a/playground/css-codesplit/main.js b/playground/css-codesplit/main.js index 8c80df2c181511..eb6e703f79e718 100644 --- a/playground/css-codesplit/main.js +++ b/playground/css-codesplit/main.js @@ -1,6 +1,15 @@ import './style.css' import './main.css' -document.getElementById( - 'app' -).innerHTML = `

This should be red

This should be blue

` +import('./async.css') + +import('./inline.css?inline').then((css) => { + document.querySelector('.dynamic-inline').textContent = css.default +}) + +import('./mod.module.css').then((css) => { + document.querySelector('.dynamic-module').textContent = JSON.stringify( + css.default + ) + document.querySelector('.mod').classList.add(css.default.mod) +}) diff --git a/playground/css-codesplit/mod.module.css b/playground/css-codesplit/mod.module.css new file mode 100644 index 00000000000000..7f84410485a32c --- /dev/null +++ b/playground/css-codesplit/mod.module.css @@ -0,0 +1,3 @@ +.mod { + color: yellow; +} From 2d978f7b10fe626ad77cd07b9d1a434af89f8c9a Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Tue, 10 May 2022 02:22:50 +0800 Subject: [PATCH 161/175] chore(plugin-react): add vite peer dep (#8083) --- packages/plugin-react/package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/plugin-react/package.json b/packages/plugin-react/package.json index 813db5ecf23aed..ca8b1d78752b69 100644 --- a/packages/plugin-react/package.json +++ b/packages/plugin-react/package.json @@ -41,5 +41,8 @@ "@rollup/pluginutils": "^4.2.1", "react-refresh": "^0.13.0", "resolve": "^1.22.0" + }, + "peerDependencies": { + "vite": "^2.0.0" } } From f895f94b49fcab278d303ef9ecf7b6a28e7fc24a Mon Sep 17 00:00:00 2001 From: David Jackson <1735971+davidwallacejackson@users.noreply.github.com> Date: Mon, 9 May 2022 11:48:57 -0700 Subject: [PATCH 162/175] fix: increase default HTTPS dev server session memory limit (#6207) --- packages/vite/src/node/http.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/vite/src/node/http.ts b/packages/vite/src/node/http.ts index bfc2ddbe32a302..18140b031937a9 100644 --- a/packages/vite/src/node/http.ts +++ b/packages/vite/src/node/http.ts @@ -104,6 +104,9 @@ export async function resolveHttpServer( } else { return require('http2').createSecureServer( { + // Manually increase the session memory to prevent 502 ENHANCE_YOUR_CALM + // errors on large numbers of requests + maxSessionMemory: 1000, ...httpsOptions, allowHTTP1: true }, From e56d79e17d64abf383bc2c30a5a2f1da6494f1fa Mon Sep 17 00:00:00 2001 From: patak Date: Mon, 9 May 2022 20:49:38 +0200 Subject: [PATCH 163/175] chore: bump Vitest timeout (#8084) --- vitest.config.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vitest.config.ts b/vitest.config.ts index 4026b98c30d640..0a8f8c2ff22648 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -7,7 +7,8 @@ export default defineConfig({ '**/dist/**', './playground/**/*.*', './playground-temp/**/*.*' - ] + ], + testTimeout: 20000 }, esbuild: { target: 'node14' From d7c04e8a0106de857b4e13d35631699d1393f804 Mon Sep 17 00:00:00 2001 From: Jeudi Prando Araujo Date: Mon, 9 May 2022 15:56:14 -0300 Subject: [PATCH 164/175] docs(config-file): update tip note about string replace (#7846) --- docs/config/index.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/config/index.md b/docs/config/index.md index 5862419405aa89..6e74e7d3b01d5e 100644 --- a/docs/config/index.md +++ b/docs/config/index.md @@ -28,12 +28,14 @@ vite --config my-config.js ``` ::: tip NOTE -Vite will replace `__filename`, `__dirname`, and `import.meta.url` in config files and its deps. Using these as variable names will result in an error: +Vite will replace `__filename`, `__dirname`, and `import.meta.url` in config files and its deps. Using these as variable names or passing as a parameter to a function with string double quote (example `console.log`) will result in an error: ```js const __filename = "value" // will be transformed to const "path/vite.config.js" = "value" + +console.log("import.meta.url") // break error on build ``` ::: From 8167db32ec44047b006a93a7969028101f5d9276 Mon Sep 17 00:00:00 2001 From: Olyno Date: Mon, 9 May 2022 23:03:35 +0200 Subject: [PATCH 165/175] fix(create-vite): allow slash at the end of project path (#6897) --- packages/create-vite/index.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/create-vite/index.js b/packages/create-vite/index.js index fceef9d9885a05..8310b8c0bddba2 100755 --- a/packages/create-vite/index.js +++ b/packages/create-vite/index.js @@ -132,7 +132,9 @@ async function init() { let targetDir = argv._[0] let template = argv.template || argv.t - const defaultProjectName = !targetDir ? 'vite-project' : targetDir + const defaultProjectName = !targetDir + ? 'vite-project' + : targetDir.trim().replace(/\/+$/g, '') let result = {} @@ -145,7 +147,8 @@ async function init() { message: reset('Project name:'), initial: defaultProjectName, onState: (state) => - (targetDir = state.value.trim() || defaultProjectName) + (targetDir = + state.value.trim().replace(/\/+$/g, '') || defaultProjectName) }, { type: () => From 2b2858c27e58f995494f7a132dfe64cbb0d1f518 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Tue, 10 May 2022 10:48:45 +0900 Subject: [PATCH 166/175] test: suppress @vue/reactivity-transform warning (#8087) --- scripts/jestEnv.cjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/jestEnv.cjs b/scripts/jestEnv.cjs index b576155644a27f..a053faef1a69a5 100644 --- a/scripts/jestEnv.cjs +++ b/scripts/jestEnv.cjs @@ -32,8 +32,8 @@ module.exports = class PlaywrightEnvironment extends NodeEnvironment { const console = this.global.console const warn = console.warn console.warn = (msg, ...args) => { - // suppress @vue/ref-transform warning - if (msg.includes('@vue/ref-transform')) return + // suppress @vue/reactivity-transform warning + if (msg.includes('@vue/reactivity-transform')) return if (msg.includes('Generated an empty chunk')) return warn.call(console, msg, ...args) } From 095543fcc5fd978e8b56fd68a7bc1785db339ee7 Mon Sep 17 00:00:00 2001 From: ygj6 <7699524+ygj6@users.noreply.github.com> Date: Tue, 10 May 2022 13:19:12 +0800 Subject: [PATCH 167/175] docs: note for inconsistency between dev and build (#6674) --- docs/config/index.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/config/index.md b/docs/config/index.md index 6e74e7d3b01d5e..666f5f39a5511c 100644 --- a/docs/config/index.md +++ b/docs/config/index.md @@ -186,6 +186,20 @@ export default defineConfig(({ command, mode }) => { ::: + ::: tip NOTE + Since dev and build implement `define` differently, we should avoid some use cases to avoid inconsistency. + + Example: + + ```js + const obj = { + __NAME__, // Don't define object shorthand property names + __KEY__: value // Don't define object key + } + ``` + + ::: + ### plugins - **Type:** `(Plugin | Plugin[])[]` From 7b48e2292e6ae833726a18b16961c9ed3173e33f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Tue, 10 May 2022 14:21:24 +0900 Subject: [PATCH 168/175] chore(plugin-vue-jsx): add peer deps (#8086) --- packages/plugin-vue-jsx/package.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/plugin-vue-jsx/package.json b/packages/plugin-vue-jsx/package.json index 91ef19c2049850..11e83bac3321b6 100644 --- a/packages/plugin-vue-jsx/package.json +++ b/packages/plugin-vue-jsx/package.json @@ -28,5 +28,9 @@ "@rollup/pluginutils": "^4.2.1", "@vue/babel-plugin-jsx": "^1.1.1", "hash-sum": "^2.0.0" + }, + "peerDependencies": { + "vite": "^2.0.0", + "vue": "^3.0.0" } } From e10c0c1e28d944a425b954aa71cbf1c8698125b7 Mon Sep 17 00:00:00 2001 From: patak Date: Tue, 10 May 2022 08:00:21 +0200 Subject: [PATCH 169/175] fix: image-set with base64 images (fix #8028) (#8035) --- packages/vite/src/node/plugins/css.ts | 14 +++++++++++--- packages/vite/src/node/utils.ts | 22 ++++++++++++++++++++-- playground/assets/__tests__/assets.spec.ts | 17 ++++++++++++++++- playground/assets/css/css-url.css | 19 +++++++++++++++++++ playground/assets/index.html | 10 ++++++++++ 5 files changed, 76 insertions(+), 6 deletions(-) diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index 3ffd93bb9f9910..c13a4c83052639 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -1045,18 +1045,26 @@ function rewriteImportCss( }) } -function rewriteCssImageSet( +// TODO: image and cross-fade could contain a "url" that needs to be processed +// https://drafts.csswg.org/css-images-4/#image-notation +// https://drafts.csswg.org/css-images-4/#cross-fade-function +const cssNotProcessedRE = /(gradient|element|cross-fade|image)\(/ + +async function rewriteCssImageSet( css: string, replacer: CssUrlReplacer ): Promise { - return asyncReplace(css, cssImageSetRE, async (match) => { + return await asyncReplace(css, cssImageSetRE, async (match) => { const [, rawUrl] = match const url = await processSrcSet(rawUrl, async ({ url }) => { // the url maybe url(...) if (cssUrlRE.test(url)) { return await rewriteCssUrls(url, replacer) } - return await doUrlReplace(url, url, replacer) + if (!cssNotProcessedRE.test(url)) { + return await doUrlReplace(url, url, replacer) + } + return url }) return url }) diff --git a/packages/vite/src/node/utils.ts b/packages/vite/src/node/utils.ts index ddcaced9832bc1..0c25b4592adf6d 100644 --- a/packages/vite/src/node/utils.ts +++ b/packages/vite/src/node/utils.ts @@ -560,8 +560,7 @@ export async function processSrcSet( srcs: string, replacer: (arg: ImageCandidate) => Promise ): Promise { - const imageCandidates: ImageCandidate[] = srcs - .split(',') + const imageCandidates: ImageCandidate[] = splitSrcSet(srcs) .map((s) => { const src = s.replace(escapedSpaceCharacters, ' ').trim() const [url] = imageSetUrlRE.exec(src) || [] @@ -589,6 +588,25 @@ export async function processSrcSet( }, '') } +function splitSrcSet(srcs: string) { + const parts: string[] = [] + // There could be a ',' inside of url(data:...), linear-gradient(...) or "data:..." + const cleanedSrcs = srcs.replace( + /(?:url|image|gradient|cross-fade)\([^\)]*\)|"([^"]|(?<=\\)")*"|'([^']|(?<=\\)')*'/g, + blankReplacer + ) + let startIndex = 0 + let splitIndex: number + do { + splitIndex = cleanedSrcs.indexOf(',', startIndex) + parts.push( + srcs.slice(startIndex, splitIndex !== -1 ? splitIndex : undefined) + ) + startIndex = splitIndex + 1 + } while (splitIndex !== -1) + return parts +} + function escapeToLinuxLikePath(path: string) { if (/^[A-Z]:/.test(path)) { return path.replace(/^([A-Z]):\//, '/windows/$1/') diff --git a/playground/assets/__tests__/assets.spec.ts b/playground/assets/__tests__/assets.spec.ts index c63ffc7cc1c0c2..d9f1c8ed761773 100644 --- a/playground/assets/__tests__/assets.spec.ts +++ b/playground/assets/__tests__/assets.spec.ts @@ -118,8 +118,23 @@ describe('css url() references', () => { }) }) - // not supported in browser now + test('image-set with base64', async () => { + const imageSet = await getBg('.css-image-set-base64') + expect(imageSet).toMatch( + `-webkit-image-set(url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA0AgMAAACrwbOMAAADI2lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS42LWMxMzggNzkuMTU5ODI0LCAyMDE2LzA5LzE0LTAxOjA5OjAxICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtbG5zOnhtcD0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLyIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDo1MDI2QjVGQTg3RUIxMUVBQUFDMkQ3NTM0MUZGNzU3RSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDo1MDI2QjVGOTg3RUIxMUVBQUFDMkQ3NTM0MUZGNzU3RSIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgQ0MgKE1hY2ludG9zaCkiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDpBNzc3MDZDRjg3QUIxMUUzQjcwREVFMDM3NzA2QzEyMyIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDpBNzc3MDZEMDg3QUIxMUUzQjcwREVFMDM3NzA2QzEyMyIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PqfCcbEAAAAZdEVYdFNvZnR3YXJlAEFkb2JlIEltYWdlUmVhZHlxyWU8AAAADFBMVEVBuoQ0R10/qn8/qX7FyuqbAAAABHRSTlP9/QGEiU0+GwAAAPtJREFUGBkFwbFNXEEUBdDD/QSWmE7YYAogWNeAaMfaEuiD5HfAk9yIAwqYwIGRRvt8zkNdvckrzzcfjqDccdPIYnH1AJ4ywLs7m53Fhkcw0+DLDxZn0PCHQrrg2xWOCpS7m6bFAj/ZDLFY/AJbDDZ/WUzR4B84BRoURBeAo4Si0CBMFvBEGMBmExYbi0loACcBjQKhC3AUQVGaRjBhMxAsFlwQDLYFBA04EaAVEHSBoxAoPmkITBYDAovNhsAAEwINTggAINCFoyCg0CBgYoCAjQsIACCgcYKABhCgHAUClAYCTAMIsF2AAAACtBMIQAEB+jcggE9AAC+A/zyyZDSXstCbAAAAAElFTkSuQmCC") 1x, url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA0CAYAAADWr1sfAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyNpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTM4IDc5LjE1OTgyNCwgMjAxNi8wOS8xNC0wMTowOTowMSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6NTAyNkI1RkE4N0VCMTFFQUFBQzJENzUzNDFGRjc1N0UiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6NTAyNkI1Rjk4N0VCMTFFQUFBQzJENzUzNDFGRjc1N0UiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIChNYWNpbnRvc2gpIj4gPHhtcE1NOkRlcml2ZWRGcm9tIHN0UmVmOmluc3RhbmNlSUQ9InhtcC5paWQ6QTc3NzA2Q0Y4N0FCMTFFM0I3MERFRTAzNzcwNkMxMjMiIHN0UmVmOmRvY3VtZW50SUQ9InhtcC5kaWQ6QTc3NzA2RDA4N0FCMTFFM0I3MERFRTAzNzcwNkMxMjMiLz4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz6nwnGxAAAJtklEQVR42txZ6W9c1RU/970373nsJHgZ27FThahSV8BCqGQTlIQ2EiUBReqHVpT8Af0r+NA/ogpqqWiDKrZuKYQPLGEpAlEFiqOgICSUBOKQhDjxeGY885bb37n3TGKPZ+4bx0uWK53Ec+cu53fPfkbtfu13B4noF6AQVAEpah0ak3cUSBU8qh46RfWj50ltKJDXXyBKdMtibI+TXlLqm2C87y/+eO/vlVIVnWbUcShFyld8T19ypvLbZKpyALOjVPCqrUcT1mWXYtIzMUV7Rqn315tJJyk+J51OZwb7QA3QkQD/fAL6JWiIXKMOhkOPwp1DFE/OkJ6NAQxn+fhuPhaFOc8DE9loern+hD9SfJVCdaLdOy5gif9rpHfyHp3pCX5cs6X1PfnORkr+SA9FO4bsgkZm1ykngm8ZK06ll0EvgWY6SwDn1fGKcykVfriewh2D5oKskhhw5KmFzLO0MJdO1yfS87UD2Uxc0tXErM+qLYQ5XUspK8el9JvagXSmPmH2W4lfG3wHNMHciXnmIfj+OvCVga8sD+yMYHyZAZ8H/Qk06dySaiNljf/DB0vklWAB1RQqnS0WA18eQE0Dz0++rjyRluOJDHuzWkwZNAPgLPHfPIeHTK/EEzHWKt/zDdh2asBmUUnJg3TDB0rQIuYptby5x6RgPO/JxIes304p44V1DMAzKQUbe4xqa62h2vbFyWuxeUie1RKqvVmXG/sxOaYKPqliQKp3HmEOB43pWaxJaTPvUV6rdK3Z6FloGUt35yD54EGXEwvaU3nSPSIYF7D5T/mio1rzS7Jaa1we4YWDzb1GUpptqJ1OGUl7BJX+jS7HP/OKEPlgRH5/SP5AZMjrCTz+jtdQQckxauEZ/IZ4bKyhYEsv7h6GpmGuhnsznafORwQbtQKGY6F/gy64pMxPnF2JSQ33UM/ecWNX/PJG3RbYsn15qCiYTQdhr49j9m4jQd8zXlkFZv3d/B087SBM4OodC+5kJYIX5r09+8ZIDYYAn4gqOdFeEEwn2gFmMb0BesEpZeOxARAOJ4SXjLbDlljKcbaQ0ebwrRNLy409oH1Xz1H2xrRc3wfaYx1dm/sgQTyYMZ1wZ4nC+4es76gnC3lqP14QTFk7wDymQH8DnXKCZibKiQHY89gY+aUeGwcT66xaw40JMUnWn52t7NWVeKt5GNaUarw1naruxXn9Rrrz9jRjLsd5PtsfZY3aaBZo9tT5qnxKsExRizto59EOccRzJQomHAC0DzsOHxwy3lvXk8VxU1u1VJFPaSW5B177SRtfNaVnq08izNyjQl9UefFe4zNwdoTI4I8XTfznu3NUORYMiyKP10HvD4neZy7VzqBaHEOjnw5TsKnXfgaDRjKqxWuzzRKtTy/Wt2W1ZAukuyX9tr4Ns+vZpheAVfKoOCuDKrNzDB8Ysp9Znd2qnAnvh9r5I8+hDs86HRhfCIlyQqGgbuHDI0Sz9gHaZj0sQXhhpJhbktOVp5Kvak/x31Sg9rarRXVxXvjwKJxk0Z7N/sOjPEf1bCez7LS1Ji/0iduBAUAD6JDpRFsHqfDjDZRdTqyU26gn2ykkXUovzf2KCV66ZGxXL9YeVtsMMb9w1x0U/WTAADWqnGO4wvMhwdA14PmqfbLjClZdTkaqCFPrAor2byIvUsZrd5Syp4BaFYW8RUmDeG8+wwsVRY+Pk7c+MJpkChXfCfhkJ1XuBjCPV0Bvt0nhFwoPiQfbVjixgaKHho3qGSlbgIu9ti/VEdHifJkdVc2aRoizwnv7kT+nNuy5hxZeX3EtygM8DfoX6FPnCcxL1Yap6NGNCCFFk5x0ETra2i7v9TcWqbh3zIbASmzvcHP7qfA6vRzAJIH7JWeYktRPz2a2bHuoZKpEdjgWdBeoWboMTpwea4o3GiF1lXzZPWLh8Y3ca7oAPAd6E/RubjLCkgBz4fYhCu6cl2d73UmX13KSUcDecNugqX2Np9a5mvKu8Di3EoB5HAP9WboGnZMRFiiXb0MhhYjNOrbeVsc5DPPexEqXz+C9HufLHHPT3PyxIbwd6wZIt4DnxCG81lG1JT9miZiaGeVj8L0+m3I2UrdaezY/z65Auj9ab0vPNLOlp+fEGwtPb3cj3aUA5nEWdDA3GTGMpqT6AupFmLLpYWaL9Hag2XZZdVHqcR1cfGzchDhdyWwFpnKTjIPCG600YFad96S+rHeOzZ5tB7Et3jeItLNk8+Fa2j6jYnU2YSyhaNcwFe4dMHv5DD7L1WUTXt5zmtoyADe7Bwfn15cdHZix3cxIzB+ObC+q2Z1Q6pq0E6gynF0A715ErasbqQWbH9JOCC8zSwGwVMA8Phb3X3a2g5BnZ5cRT78Dj7trxMRR7liY+lhdu5ntVnFDFLm4N1a0nr2e5rVtysLDx0tl/noAc9X7TLNH5KxZuC1Tg6puH0SYKtoaumFrYWPbsS0xg+/2UbjVVkNXW67u8aHwkKwFYB6fgQ47nYXXBBSbEBPtGjUtnWy6YcEm/F1q5sLdkO5AQTonuap8Vu7+7HoYv17APF4Fve6KrabEkzhcuH+AAuTFGmmjkeScbdsU7hswxGtMkqJzM7PX5W5aa8BfSDdwyt30I9Nw44qn+MgYef1IKC42SLN9D4TU8+iYCWGmKSfdEceYkju/uBGAebwvDW53KcOeFxlYcBeqqd3DBiznyCHCUPCDdUTsweM0765M7np/OQwvF/A5aYOedDcKmo23zP5qsalovTfny9wL4xQyP18+KXedu5GAmx0G9pizrsrAJCOQsuovUPTIKIU/HzG/SPKczks97dnPODswXY5gBQDXxK72g3a0fURT5yoTY7nw5w6ksVcAzZq/C7mbcv+TO2rLZXYlJMzjtNjXBedN7IlBXuibtq3ph8W5vw1dkLNPrwSjKwWY89oXQf9xNgqaXruaWLulXK8cy5kvOvP3GwC4mWc/50wImj+xaLrmpFRugvPcUvPltQJMUr0cXcHzjpLrF82bAHBN1O+dFTjrHTmrdjMD5vER6B/LZLQmZ3y00sytBuC65LtvLeOMt+SM+q0AmMekNNbK17G3LHsnV4Ox1QLM4wNRy3gJe2LZ88FqMbWagL8CPe2sptpXQ0/L3lsOMGcW3Cv+O+hyF+svy9pjsveWA9z0tn8Afd7F2s9lbW01GVptwJxTHZfE3/Uj17SsOU7ddLRuYsDN8decDOyorFn1sVaAvyT7k8iZNt+dke++vJ0A8+CfMw+3mT8s39HtBviSgDs+b+64zF26HQHz+C/o+Xmfn5c5ul0BXyT7w/U5oTdlbs1GQGs/vgb9cd7fazr+L8AAD0zRYMSYHQAAAAAASUVORK5CYII=") 2x)` + ) + }) + + // TODO: not supported in chrome // https://drafts.csswg.org/css-images-4/#image-set-notation + // + // test('image-set with multiple descriptor', async () => { + // const imageSet = await getBg('.css-image-set-gradient') + // expect(imageSet).toMatch( + // `-webkit-image-set(url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA0AgMAAACrwbOMAAADI2lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS42LWMxMzggNzkuMTU5ODI0LCAyMDE2LzA5LzE0LTAxOjA5OjAxICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtbG5zOnhtcD0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLyIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDo1MDI2QjVGQTg3RUIxMUVBQUFDMkQ3NTM0MUZGNzU3RSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDo1MDI2QjVGOTg3RUIxMUVBQUFDMkQ3NTM0MUZGNzU3RSIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgQ0MgKE1hY2ludG9zaCkiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDpBNzc3MDZDRjg3QUIxMUUzQjcwREVFMDM3NzA2QzEyMyIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDpBNzc3MDZEMDg3QUIxMUUzQjcwREVFMDM3NzA2QzEyMyIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PqfCcbEAAAAZdEVYdFNvZnR3YXJlAEFkb2JlIEltYWdlUmVhZHlxyWU8AAAADFBMVEVBuoQ0R10/qn8/qX7FyuqbAAAABHRSTlP9/QGEiU0+GwAAAPtJREFUGBkFwbFNXEEUBdDD/QSWmE7YYAogWNeAaMfaEuiD5HfAk9yIAwqYwIGRRvt8zkNdvckrzzcfjqDccdPIYnH1AJ4ywLs7m53Fhkcw0+DLDxZn0PCHQrrg2xWOCpS7m6bFAj/ZDLFY/AJbDDZ/WUzR4B84BRoURBeAo4Si0CBMFvBEGMBmExYbi0loACcBjQKhC3AUQVGaRjBhMxAsFlwQDLYFBA04EaAVEHSBoxAoPmkITBYDAovNhsAAEwINTggAINCFoyCg0CBgYoCAjQsIACCgcYKABhCgHAUClAYCTAMIsF2AAAACtBMIQAEB+jcggE9AAC+A/zyyZDSXstCbAAAAAElFTkSuQmCC") 1x, linear-gradient(#e66465, #9198e5) 2x)` + // ) + // }) + // // test('image-set with multiple descriptor', async () => { // const imageSet = await getBg('.css-image-set-multiple-descriptor') // imageSet.split(', ').forEach((s) => { diff --git a/playground/assets/css/css-url.css b/playground/assets/css/css-url.css index 9047cd384e7d38..1446f19afa662e 100644 --- a/playground/assets/css/css-url.css +++ b/playground/assets/css/css-url.css @@ -41,6 +41,25 @@ background-size: 10px; } +.css-image-set-base64 { + background-image: -webkit-image-set( + url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA0AgMAAACrwbOMAAADI2lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS42LWMxMzggNzkuMTU5ODI0LCAyMDE2LzA5LzE0LTAxOjA5OjAxICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtbG5zOnhtcD0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLyIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDo1MDI2QjVGQTg3RUIxMUVBQUFDMkQ3NTM0MUZGNzU3RSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDo1MDI2QjVGOTg3RUIxMUVBQUFDMkQ3NTM0MUZGNzU3RSIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgQ0MgKE1hY2ludG9zaCkiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDpBNzc3MDZDRjg3QUIxMUUzQjcwREVFMDM3NzA2QzEyMyIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDpBNzc3MDZEMDg3QUIxMUUzQjcwREVFMDM3NzA2QzEyMyIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PqfCcbEAAAAZdEVYdFNvZnR3YXJlAEFkb2JlIEltYWdlUmVhZHlxyWU8AAAADFBMVEVBuoQ0R10/qn8/qX7FyuqbAAAABHRSTlP9/QGEiU0+GwAAAPtJREFUGBkFwbFNXEEUBdDD/QSWmE7YYAogWNeAaMfaEuiD5HfAk9yIAwqYwIGRRvt8zkNdvckrzzcfjqDccdPIYnH1AJ4ywLs7m53Fhkcw0+DLDxZn0PCHQrrg2xWOCpS7m6bFAj/ZDLFY/AJbDDZ/WUzR4B84BRoURBeAo4Si0CBMFvBEGMBmExYbi0loACcBjQKhC3AUQVGaRjBhMxAsFlwQDLYFBA04EaAVEHSBoxAoPmkITBYDAovNhsAAEwINTggAINCFoyCg0CBgYoCAjQsIACCgcYKABhCgHAUClAYCTAMIsF2AAAACtBMIQAEB+jcggE9AAC+A/zyyZDSXstCbAAAAAElFTkSuQmCC) + 1x, + url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA0CAYAAADWr1sfAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyNpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTM4IDc5LjE1OTgyNCwgMjAxNi8wOS8xNC0wMTowOTowMSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6NTAyNkI1RkE4N0VCMTFFQUFBQzJENzUzNDFGRjc1N0UiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6NTAyNkI1Rjk4N0VCMTFFQUFBQzJENzUzNDFGRjc1N0UiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIChNYWNpbnRvc2gpIj4gPHhtcE1NOkRlcml2ZWRGcm9tIHN0UmVmOmluc3RhbmNlSUQ9InhtcC5paWQ6QTc3NzA2Q0Y4N0FCMTFFM0I3MERFRTAzNzcwNkMxMjMiIHN0UmVmOmRvY3VtZW50SUQ9InhtcC5kaWQ6QTc3NzA2RDA4N0FCMTFFM0I3MERFRTAzNzcwNkMxMjMiLz4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz6nwnGxAAAJtklEQVR42txZ6W9c1RU/970373nsJHgZ27FThahSV8BCqGQTlIQ2EiUBReqHVpT8Af0r+NA/ogpqqWiDKrZuKYQPLGEpAlEFiqOgICSUBOKQhDjxeGY885bb37n3TGKPZ+4bx0uWK53Ec+cu53fPfkbtfu13B4noF6AQVAEpah0ak3cUSBU8qh46RfWj50ltKJDXXyBKdMtibI+TXlLqm2C87y/+eO/vlVIVnWbUcShFyld8T19ypvLbZKpyALOjVPCqrUcT1mWXYtIzMUV7Rqn315tJJyk+J51OZwb7QA3QkQD/fAL6JWiIXKMOhkOPwp1DFE/OkJ6NAQxn+fhuPhaFOc8DE9loern+hD9SfJVCdaLdOy5gif9rpHfyHp3pCX5cs6X1PfnORkr+SA9FO4bsgkZm1ykngm8ZK06ll0EvgWY6SwDn1fGKcykVfriewh2D5oKskhhw5KmFzLO0MJdO1yfS87UD2Uxc0tXErM+qLYQ5XUspK8el9JvagXSmPmH2W4lfG3wHNMHciXnmIfj+OvCVga8sD+yMYHyZAZ8H/Qk06dySaiNljf/DB0vklWAB1RQqnS0WA18eQE0Dz0++rjyRluOJDHuzWkwZNAPgLPHfPIeHTK/EEzHWKt/zDdh2asBmUUnJg3TDB0rQIuYptby5x6RgPO/JxIes304p44V1DMAzKQUbe4xqa62h2vbFyWuxeUie1RKqvVmXG/sxOaYKPqliQKp3HmEOB43pWaxJaTPvUV6rdK3Z6FloGUt35yD54EGXEwvaU3nSPSIYF7D5T/mio1rzS7Jaa1we4YWDzb1GUpptqJ1OGUl7BJX+jS7HP/OKEPlgRH5/SP5AZMjrCTz+jtdQQckxauEZ/IZ4bKyhYEsv7h6GpmGuhnsznafORwQbtQKGY6F/gy64pMxPnF2JSQ33UM/ecWNX/PJG3RbYsn15qCiYTQdhr49j9m4jQd8zXlkFZv3d/B087SBM4OodC+5kJYIX5r09+8ZIDYYAn4gqOdFeEEwn2gFmMb0BesEpZeOxARAOJ4SXjLbDlljKcbaQ0ebwrRNLy409oH1Xz1H2xrRc3wfaYx1dm/sgQTyYMZ1wZ4nC+4es76gnC3lqP14QTFk7wDymQH8DnXKCZibKiQHY89gY+aUeGwcT66xaw40JMUnWn52t7NWVeKt5GNaUarw1naruxXn9Rrrz9jRjLsd5PtsfZY3aaBZo9tT5qnxKsExRizto59EOccRzJQomHAC0DzsOHxwy3lvXk8VxU1u1VJFPaSW5B177SRtfNaVnq08izNyjQl9UefFe4zNwdoTI4I8XTfznu3NUORYMiyKP10HvD4neZy7VzqBaHEOjnw5TsKnXfgaDRjKqxWuzzRKtTy/Wt2W1ZAukuyX9tr4Ns+vZpheAVfKoOCuDKrNzDB8Ysp9Znd2qnAnvh9r5I8+hDs86HRhfCIlyQqGgbuHDI0Sz9gHaZj0sQXhhpJhbktOVp5Kvak/x31Sg9rarRXVxXvjwKJxk0Z7N/sOjPEf1bCez7LS1Ji/0iduBAUAD6JDpRFsHqfDjDZRdTqyU26gn2ykkXUovzf2KCV66ZGxXL9YeVtsMMb9w1x0U/WTAADWqnGO4wvMhwdA14PmqfbLjClZdTkaqCFPrAor2byIvUsZrd5Syp4BaFYW8RUmDeG8+wwsVRY+Pk7c+MJpkChXfCfhkJ1XuBjCPV0Bvt0nhFwoPiQfbVjixgaKHho3qGSlbgIu9ti/VEdHifJkdVc2aRoizwnv7kT+nNuy5hxZeX3EtygM8DfoX6FPnCcxL1Yap6NGNCCFFk5x0ETra2i7v9TcWqbh3zIbASmzvcHP7qfA6vRzAJIH7JWeYktRPz2a2bHuoZKpEdjgWdBeoWboMTpwea4o3GiF1lXzZPWLh8Y3ca7oAPAd6E/RubjLCkgBz4fYhCu6cl2d73UmX13KSUcDecNugqX2Np9a5mvKu8Di3EoB5HAP9WboGnZMRFiiXb0MhhYjNOrbeVsc5DPPexEqXz+C9HufLHHPT3PyxIbwd6wZIt4DnxCG81lG1JT9miZiaGeVj8L0+m3I2UrdaezY/z65Auj9ab0vPNLOlp+fEGwtPb3cj3aUA5nEWdDA3GTGMpqT6AupFmLLpYWaL9Hag2XZZdVHqcR1cfGzchDhdyWwFpnKTjIPCG600YFad96S+rHeOzZ5tB7Et3jeItLNk8+Fa2j6jYnU2YSyhaNcwFe4dMHv5DD7L1WUTXt5zmtoyADe7Bwfn15cdHZix3cxIzB+ObC+q2Z1Q6pq0E6gynF0A715ErasbqQWbH9JOCC8zSwGwVMA8Phb3X3a2g5BnZ5cRT78Dj7trxMRR7liY+lhdu5ntVnFDFLm4N1a0nr2e5rVtysLDx0tl/noAc9X7TLNH5KxZuC1Tg6puH0SYKtoaumFrYWPbsS0xg+/2UbjVVkNXW67u8aHwkKwFYB6fgQ47nYXXBBSbEBPtGjUtnWy6YcEm/F1q5sLdkO5AQTonuap8Vu7+7HoYv17APF4Fve6KrabEkzhcuH+AAuTFGmmjkeScbdsU7hswxGtMkqJzM7PX5W5aa8BfSDdwyt30I9Nw44qn+MgYef1IKC42SLN9D4TU8+iYCWGmKSfdEceYkju/uBGAebwvDW53KcOeFxlYcBeqqd3DBiznyCHCUPCDdUTsweM0765M7np/OQwvF/A5aYOedDcKmo23zP5qsalovTfny9wL4xQyP18+KXedu5GAmx0G9pizrsrAJCOQsuovUPTIKIU/HzG/SPKczks97dnPODswXY5gBQDXxK72g3a0fURT5yoTY7nw5w6ksVcAzZq/C7mbcv+TO2rLZXYlJMzjtNjXBedN7IlBXuibtq3ph8W5vw1dkLNPrwSjKwWY89oXQf9xNgqaXruaWLulXK8cy5kvOvP3GwC4mWc/50wImj+xaLrmpFRugvPcUvPltQJMUr0cXcHzjpLrF82bAHBN1O+dFTjrHTmrdjMD5vER6B/LZLQmZ3y00sytBuC65LtvLeOMt+SM+q0AmMekNNbK17G3LHsnV4Ox1QLM4wNRy3gJe2LZ88FqMbWagL8CPe2sptpXQ0/L3lsOMGcW3Cv+O+hyF+svy9pjsveWA9z0tn8Afd7F2s9lbW01GVptwJxTHZfE3/Uj17SsOU7ddLRuYsDN8decDOyorFn1sVaAvyT7k8iZNt+dke++vJ0A8+CfMw+3mT8s39HtBviSgDs+b+64zF26HQHz+C/o+Xmfn5c5ul0BXyT7w/U5oTdlbs1GQGs/vgb9cd7fazr+L8AAD0zRYMSYHQAAAAAASUVORK5CYII=) + 2x + ); + background-size: 10px; +} + +.css-image-set-gradient { + background-image: -webkit-image-set( + 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA0AgMAAACrwbOMAAADI2lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS42LWMxMzggNzkuMTU5ODI0LCAyMDE2LzA5LzE0LTAxOjA5OjAxICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtbG5zOnhtcD0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLyIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDo1MDI2QjVGQTg3RUIxMUVBQUFDMkQ3NTM0MUZGNzU3RSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDo1MDI2QjVGOTg3RUIxMUVBQUFDMkQ3NTM0MUZGNzU3RSIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgQ0MgKE1hY2ludG9zaCkiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDpBNzc3MDZDRjg3QUIxMUUzQjcwREVFMDM3NzA2QzEyMyIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDpBNzc3MDZEMDg3QUIxMUUzQjcwREVFMDM3NzA2QzEyMyIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PqfCcbEAAAAZdEVYdFNvZnR3YXJlAEFkb2JlIEltYWdlUmVhZHlxyWU8AAAADFBMVEVBuoQ0R10/qn8/qX7FyuqbAAAABHRSTlP9/QGEiU0+GwAAAPtJREFUGBkFwbFNXEEUBdDD/QSWmE7YYAogWNeAaMfaEuiD5HfAk9yIAwqYwIGRRvt8zkNdvckrzzcfjqDccdPIYnH1AJ4ywLs7m53Fhkcw0+DLDxZn0PCHQrrg2xWOCpS7m6bFAj/ZDLFY/AJbDDZ/WUzR4B84BRoURBeAo4Si0CBMFvBEGMBmExYbi0loACcBjQKhC3AUQVGaRjBhMxAsFlwQDLYFBA04EaAVEHSBoxAoPmkITBYDAovNhsAAEwINTggAINCFoyCg0CBgYoCAjQsIACCgcYKABhCgHAUClAYCTAMIsF2AAAACtBMIQAEB+jcggE9AAC+A/zyyZDSXstCbAAAAAElFTkSuQmCC' + 1x, + linear-gradient(#e66465, #9198e5) 2x + ); + background-size: 10px; +} + .css-image-set-multiple-descriptor { background-image: -webkit-image-set( '../nested/asset.png' type('image/png') 1x, diff --git a/playground/assets/index.html b/playground/assets/index.html index 43eed55236abd3..fcf0e4ce1e81d7 100644 --- a/playground/assets/index.html +++ b/playground/assets/index.html @@ -56,6 +56,16 @@

CSS url references

CSS background image-set() (mix var and url) +
+ + CSS background image-set() (with base64) + +
+
+ + CSS background image-set() (with gradient) + +
CSS background image-set() (with multiple descriptor) From 85cab7054f5b7774fb796d86329226870fd23cdc Mon Sep 17 00:00:00 2001 From: TMQ <5112895@qq.com> Date: Tue, 10 May 2022 14:11:50 +0800 Subject: [PATCH 170/175] fix(build): use crossorigin for module preloaded --- packages/vite/src/node/plugins/html.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/vite/src/node/plugins/html.ts b/packages/vite/src/node/plugins/html.ts index 40883a86c9af2a..2f1e3af34babb4 100644 --- a/packages/vite/src/node/plugins/html.ts +++ b/packages/vite/src/node/plugins/html.ts @@ -546,6 +546,7 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin { tag: 'link', attrs: { rel: 'modulepreload', + crossorigin: true, href: toPublicPath(chunk.fileName, config) } }) From 80d113b1d6df6c97ad2a3dcd27be8a7e27103141 Mon Sep 17 00:00:00 2001 From: yoho Date: Tue, 10 May 2022 17:42:29 +0800 Subject: [PATCH 171/175] feat: rework `dynamic-import-vars` (#7756) Co-authored-by: Anthony Fu Co-authored-by: Bjorn Lu --- .../__snapshots__/parse.test.ts.snap | 13 ++ .../plugins/dynamicImportVar/mods/hello.js | 3 + .../plugins/dynamicImportVar/mods/hi.js | 3 + .../plugins/dynamicImportVar/parse.test.ts | 38 +++ packages/vite/src/node/build.ts | 2 - .../src/node/plugins/dynamicImportVars.ts | 217 ++++++++++++++++++ .../vite/src/node/plugins/importAnalysis.ts | 23 +- .../vite/src/node/plugins/importMetaGlob.ts | 22 +- packages/vite/src/node/plugins/index.ts | 2 + packages/vite/src/node/utils.ts | 7 +- packages/vite/types/shims.d.ts | 5 + .../__tests__/dynamic-import.spec.ts | 24 ++ playground/dynamic-import/alias/hello.js | 3 + playground/dynamic-import/alias/hi.js | 3 + playground/dynamic-import/index.html | 14 ++ playground/dynamic-import/nested/hello.js | 3 + playground/dynamic-import/nested/index.js | 14 ++ playground/dynamic-import/vite.config.js | 12 +- 18 files changed, 372 insertions(+), 36 deletions(-) create mode 100644 packages/vite/src/node/__tests__/plugins/dynamicImportVar/__snapshots__/parse.test.ts.snap create mode 100644 packages/vite/src/node/__tests__/plugins/dynamicImportVar/mods/hello.js create mode 100644 packages/vite/src/node/__tests__/plugins/dynamicImportVar/mods/hi.js create mode 100644 packages/vite/src/node/__tests__/plugins/dynamicImportVar/parse.test.ts create mode 100644 packages/vite/src/node/plugins/dynamicImportVars.ts create mode 100644 playground/dynamic-import/alias/hello.js create mode 100644 playground/dynamic-import/alias/hi.js create mode 100644 playground/dynamic-import/nested/hello.js diff --git a/packages/vite/src/node/__tests__/plugins/dynamicImportVar/__snapshots__/parse.test.ts.snap b/packages/vite/src/node/__tests__/plugins/dynamicImportVar/__snapshots__/parse.test.ts.snap new file mode 100644 index 00000000000000..be73ec998bc834 --- /dev/null +++ b/packages/vite/src/node/__tests__/plugins/dynamicImportVar/__snapshots__/parse.test.ts.snap @@ -0,0 +1,13 @@ +// Vitest Snapshot v1 + +exports[`parse positives > ? in url 1`] = `"__variableDynamicImportRuntimeHelper((import.meta.glob(\\"./mo?ds/*.js\\", {\\"as\\":\\"raw\\",\\"import\\":\\"*\\"})), \`./mo?ds/\${base ?? foo}.js\`)"`; + +exports[`parse positives > ? in variables 1`] = `"__variableDynamicImportRuntimeHelper((import.meta.glob(\\"./mods/*.js\\", {\\"as\\":\\"raw\\",\\"import\\":\\"*\\"})), \`./mods/\${base ?? foo}.js\`)"`; + +exports[`parse positives > alias path 1`] = `"__variableDynamicImportRuntimeHelper((import.meta.glob(\\"./mods/*.js\\")), \`./mods/\${base}.js\`)"`; + +exports[`parse positives > basic 1`] = `"__variableDynamicImportRuntimeHelper((import.meta.glob(\\"./mods/*.js\\")), \`./mods/\${base}.js\`)"`; + +exports[`parse positives > with query raw 1`] = `"__variableDynamicImportRuntimeHelper((import.meta.glob(\\"./mods/*.js\\", {\\"as\\":\\"raw\\",\\"import\\":\\"*\\"})), \`./mods/\${base}.js\`)"`; + +exports[`parse positives > with query url 1`] = `"__variableDynamicImportRuntimeHelper((import.meta.glob(\\"./mods/*.js\\")), \`./mods/\${base}.js\`)"`; diff --git a/packages/vite/src/node/__tests__/plugins/dynamicImportVar/mods/hello.js b/packages/vite/src/node/__tests__/plugins/dynamicImportVar/mods/hello.js new file mode 100644 index 00000000000000..67900ef0999962 --- /dev/null +++ b/packages/vite/src/node/__tests__/plugins/dynamicImportVar/mods/hello.js @@ -0,0 +1,3 @@ +export function hello() { + return 'hello' +} diff --git a/packages/vite/src/node/__tests__/plugins/dynamicImportVar/mods/hi.js b/packages/vite/src/node/__tests__/plugins/dynamicImportVar/mods/hi.js new file mode 100644 index 00000000000000..45d3506803b2b6 --- /dev/null +++ b/packages/vite/src/node/__tests__/plugins/dynamicImportVar/mods/hi.js @@ -0,0 +1,3 @@ +export function hi() { + return 'hi' +} diff --git a/packages/vite/src/node/__tests__/plugins/dynamicImportVar/parse.test.ts b/packages/vite/src/node/__tests__/plugins/dynamicImportVar/parse.test.ts new file mode 100644 index 00000000000000..ef1dcb2238a5b0 --- /dev/null +++ b/packages/vite/src/node/__tests__/plugins/dynamicImportVar/parse.test.ts @@ -0,0 +1,38 @@ +import { describe, expect, it } from 'vitest' +import { transformDynamicImport } from '../../../plugins/dynamicImportVars' +import { resolve } from 'path' + +async function run(input: string) { + const { glob, rawPattern } = await transformDynamicImport( + input, + resolve(__dirname, 'index.js'), + (id) => id.replace('@', resolve(__dirname, './mods/')) + ) + return `__variableDynamicImportRuntimeHelper(${glob}, \`${rawPattern}\`)` +} + +describe('parse positives', () => { + it('basic', async () => { + expect(await run('`./mods/${base}.js`')).toMatchSnapshot() + }) + + it('alias path', async () => { + expect(await run('`@/${base}.js`')).toMatchSnapshot() + }) + + it('with query raw', async () => { + expect(await run('`./mods/${base}.js?raw`')).toMatchSnapshot() + }) + + it('with query url', async () => { + expect(await run('`./mods/${base}.js?url`')).toMatchSnapshot() + }) + + it('? in variables', async () => { + expect(await run('`./mods/${base ?? foo}.js?raw`')).toMatchSnapshot() + }) + + it('? in url', async () => { + expect(await run('`./mo?ds/${base ?? foo}.js?raw`')).toMatchSnapshot() + }) +}) diff --git a/packages/vite/src/node/build.ts b/packages/vite/src/node/build.ts index d4d4085bb829ed..1bdfa5a35077e6 100644 --- a/packages/vite/src/node/build.ts +++ b/packages/vite/src/node/build.ts @@ -26,7 +26,6 @@ import { copyDir, emptyDir, lookupFile, normalizePath } from './utils' import { manifestPlugin } from './plugins/manifest' import commonjsPlugin from '@rollup/plugin-commonjs' import type { RollupCommonJSOptions } from 'types/commonjs' -import dynamicImportVars from '@rollup/plugin-dynamic-import-vars' import type { RollupDynamicImportVarsOptions } from 'types/dynamicImportVars' import type { Logger } from './logger' import type { TransformOptions } from 'esbuild' @@ -285,7 +284,6 @@ export function resolveBuildPlugins(config: ResolvedConfig): { watchPackageDataPlugin(config), commonjsPlugin(options.commonjsOptions), dataURIPlugin(), - dynamicImportVars(options.dynamicImportVarsOptions), assetImportMetaUrlPlugin(config), ...(options.rollupOptions.plugins ? (options.rollupOptions.plugins.filter(Boolean) as Plugin[]) diff --git a/packages/vite/src/node/plugins/dynamicImportVars.ts b/packages/vite/src/node/plugins/dynamicImportVars.ts new file mode 100644 index 00000000000000..c33590cf0343f4 --- /dev/null +++ b/packages/vite/src/node/plugins/dynamicImportVars.ts @@ -0,0 +1,217 @@ +import { posix } from 'path' +import MagicString from 'magic-string' +import { init, parse as parseImports } from 'es-module-lexer' +import type { ImportSpecifier } from 'es-module-lexer' +import type { Plugin } from '../plugin' +import type { ResolvedConfig } from '../config' +import { normalizePath, parseRequest, requestQuerySplitRE } from '../utils' +import { parse as parseJS } from 'acorn' +import { createFilter } from '@rollup/pluginutils' +import { dynamicImportToGlob } from '@rollup/plugin-dynamic-import-vars' + +export const dynamicImportHelperId = '/@vite/dynamic-import-helper' + +interface DynamicImportRequest { + as?: 'raw' +} + +interface DynamicImportPattern { + globParams: DynamicImportRequest | null + userPattern: string + rawPattern: string +} + +const dynamicImportHelper = (glob: Record, path: string) => { + const v = glob[path] + if (v) { + return typeof v === 'function' ? v() : Promise.resolve(v) + } + return new Promise((_, reject) => { + ;(typeof queueMicrotask === 'function' ? queueMicrotask : setTimeout)( + reject.bind(null, new Error('Unknown variable dynamic import: ' + path)) + ) + }) +} + +function parseDynamicImportPattern( + strings: string +): DynamicImportPattern | null { + const filename = strings.slice(1, -1) + const rawQuery = parseRequest(filename) + let globParams: DynamicImportRequest | null = null + const ast = ( + parseJS(strings, { + ecmaVersion: 'latest', + sourceType: 'module' + }) as any + ).body[0].expression + + const userPatternQuery = dynamicImportToGlob(ast, filename) + if (!userPatternQuery) { + return null + } + + const [userPattern] = userPatternQuery.split(requestQuerySplitRE, 2) + const [rawPattern] = filename.split(requestQuerySplitRE, 2) + + if (rawQuery?.raw !== undefined) { + globParams = { as: 'raw' } + } + + return { + globParams, + userPattern, + rawPattern + } +} + +export async function transformDynamicImport( + importSource: string, + importer: string, + resolve: ( + url: string, + importer?: string + ) => Promise | string | undefined +): Promise<{ + glob: string + pattern: string + rawPattern: string +} | null> { + if (importSource[1] !== '.' && importSource[1] !== '/') { + const resolvedFileName = await resolve(importSource.slice(1, -1), importer) + if (!resolvedFileName) { + return null + } + const relativeFileName = posix.relative( + posix.dirname(normalizePath(importer)), + normalizePath(resolvedFileName) + ) + importSource = normalizePath( + '`' + (relativeFileName[0] === '.' ? '' : './') + relativeFileName + '`' + ) + } + + const dynamicImportPattern = parseDynamicImportPattern(importSource) + if (!dynamicImportPattern) { + return null + } + const { globParams, rawPattern, userPattern } = dynamicImportPattern + const params = globParams + ? `, ${JSON.stringify({ ...globParams, import: '*' })}` + : '' + const exp = `(import.meta.glob(${JSON.stringify(userPattern)}${params}))` + + return { + rawPattern, + pattern: userPattern, + glob: exp + } +} + +export function dynamicImportVarsPlugin(config: ResolvedConfig): Plugin { + const resolve = config.createResolver({ + preferRelative: true, + tryIndex: false, + extensions: [] + }) + const { include, exclude, warnOnError } = + config.build.dynamicImportVarsOptions + const filter = createFilter(include, exclude) + const isBuild = config.command === 'build' + return { + name: 'vite:dynamic-import-vars', + + resolveId(id) { + if (id === dynamicImportHelperId) { + return id + } + }, + + load(id) { + if (id === dynamicImportHelperId) { + return 'export default ' + dynamicImportHelper.toString() + } + }, + + async transform(source, importer) { + if (!filter(importer)) { + return + } + + await init + + let imports: readonly ImportSpecifier[] = [] + try { + imports = parseImports(source)[0] + } catch (e: any) { + // ignore as it might not be a JS file, the subsequent plugins will catch the error + return null + } + + if (!imports.length) { + return null + } + + let s: MagicString | undefined + let needDynamicImportHelper = false + + for (let index = 0; index < imports.length; index++) { + const { + s: start, + e: end, + ss: expStart, + se: expEnd, + d: dynamicIndex + } = imports[index] + + if (dynamicIndex === -1 || source[start] !== '`') { + continue + } + + s ||= new MagicString(source) + let result + try { + result = await transformDynamicImport( + source.slice(start, end), + importer, + resolve + ) + } catch (error) { + if (warnOnError) { + this.warn(error) + } else { + this.error(error) + } + } + + if (!result) { + continue + } + + const { rawPattern, glob } = result + + needDynamicImportHelper = true + s.overwrite( + expStart, + expEnd, + `__variableDynamicImportRuntimeHelper(${glob}, \`${rawPattern}\`)` + ) + } + + if (s) { + if (needDynamicImportHelper) { + s.prepend( + `import __variableDynamicImportRuntimeHelper from "${dynamicImportHelperId}";` + ) + } + return { + code: s.toString(), + map: + !isBuild || config.build.sourcemap + ? s.generateMap({ hires: true }) + : null + } + } + } + } +} diff --git a/packages/vite/src/node/plugins/importAnalysis.ts b/packages/vite/src/node/plugins/importAnalysis.ts index ed4a2bc934ab5a..f12426aa923cfe 100644 --- a/packages/vite/src/node/plugins/importAnalysis.ts +++ b/packages/vite/src/node/plugins/importAnalysis.ts @@ -490,7 +490,7 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin { const url = rawUrl .replace(/\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$/gm, '') .trim() - if (!hasViteIgnore && !isSupportedDynamicImport(url)) { + if (!hasViteIgnore) { this.warn( `\n` + colors.cyan(importerModule.file) + @@ -651,27 +651,6 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin { } } -/** - * https://github.com/rollup/plugins/tree/master/packages/dynamic-import-vars#limitations - * This is probably less accurate but is much cheaper than a full AST parse. - */ -function isSupportedDynamicImport(url: string) { - url = url.trim().slice(1, -1) - // must be relative - if (!url.startsWith('./') && !url.startsWith('../')) { - return false - } - // must have extension - if (!path.extname(url)) { - return false - } - // must be more specific if importing from same dir - if (url.startsWith('./${') && url.indexOf('/') === url.lastIndexOf('/')) { - return false - } - return true -} - type ImportNameSpecifier = { importedName: string; localName: string } /** diff --git a/packages/vite/src/node/plugins/importMetaGlob.ts b/packages/vite/src/node/plugins/importMetaGlob.ts index 5bf4d14a4dc9f0..ed46e35bea8ecf 100644 --- a/packages/vite/src/node/plugins/importMetaGlob.ts +++ b/packages/vite/src/node/plugins/importMetaGlob.ts @@ -11,7 +11,7 @@ import type { ViteDevServer } from '../server' import type { ModuleNode } from '../server/moduleGraph' import type { ResolvedConfig } from '../config' import { isCSSRequest } from './css' -import type { GeneralImportGlobOptions } from '../../../types/importGlob' +import type { GeneralImportGlobOptions } from 'types/importGlob' import { normalizePath, slash } from '../utils' export interface ParsedImportGlob { @@ -168,12 +168,13 @@ export async function parseImportGlob( for (const property of arg2.properties) { if ( property.type === 'SpreadElement' || - property.key.type !== 'Identifier' + (property.key.type !== 'Identifier' && + property.key.type !== 'Literal') ) throw err('Could only use literals') - const name = property.key.name as keyof GeneralImportGlobOptions - + const name = ((property.key as any).name || + (property.key as any).value) as keyof GeneralImportGlobOptions if (name === 'query') { if (property.value.type === 'ObjectExpression') { const data: Record = {} @@ -260,13 +261,22 @@ const importPrefix = '__vite_glob_' const { basename, dirname, relative, join } = posix +export interface TransformGlobImportResult { + s: MagicString + matches: ParsedImportGlob[] + files: Set +} + +/** + * @param optimizeExport for dynamicImportVar plugin don't need to optimize export. + */ export async function transformGlobImport( code: string, id: string, root: string, resolveId: IdResolver, restoreQueryExtension = false -) { +): Promise { id = slash(id) root = slash(root) const isVirtual = isVirtualModule(id) @@ -288,7 +298,7 @@ export async function transformGlobImport( } }) - if (!matches.length) return + if (!matches.length) return null const s = new MagicString(code) diff --git a/packages/vite/src/node/plugins/index.ts b/packages/vite/src/node/plugins/index.ts index 26d777cf919292..3fd283b07b4e47 100644 --- a/packages/vite/src/node/plugins/index.ts +++ b/packages/vite/src/node/plugins/index.ts @@ -19,6 +19,7 @@ import { ssrRequireHookPlugin } from './ssrRequireHook' import { workerImportMetaUrlPlugin } from './workerImportMetaUrl' import { ensureWatchPlugin } from './ensureWatch' import { metadataPlugin } from './metadata' +import { dynamicImportVarsPlugin } from './dynamicImportVars' import { importGlobPlugin } from './importMetaGlob' export async function resolvePlugins( @@ -73,6 +74,7 @@ export async function resolvePlugins( isBuild && buildHtmlPlugin(config), workerImportMetaUrlPlugin(config), ...buildPlugins.pre, + dynamicImportVarsPlugin(config), importGlobPlugin(config), ...postPlugins, ...buildPlugins.post, diff --git a/packages/vite/src/node/utils.ts b/packages/vite/src/node/utils.ts index 0c25b4592adf6d..d84b474b87c33f 100644 --- a/packages/vite/src/node/utils.ts +++ b/packages/vite/src/node/utils.ts @@ -19,7 +19,7 @@ import type { FSWatcher } from 'chokidar' import remapping from '@ampproject/remapping' import type { DecodedSourceMap, RawSourceMap } from '@ampproject/remapping' import { performance } from 'perf_hooks' -import { parse as parseUrl, URLSearchParams } from 'url' +import { URLSearchParams } from 'url' export function slash(p: string): string { return p.replace(/\\/g, '/') @@ -741,6 +741,7 @@ export function toUpperCaseDriveLetter(pathName: string): string { export const multilineCommentsRE = /\/\*(.|[\r\n])*?\*\//gm export const singlelineCommentsRE = /\/\/.*/g +export const requestQuerySplitRE = /\?(?!.*[\/|\}])/ export const usingDynamicImport = typeof jest === 'undefined' /** @@ -757,11 +758,11 @@ export const dynamicImport = usingDynamicImport : require export function parseRequest(id: string): Record | null { - const { search } = parseUrl(id) + const [_, search] = id.split(requestQuerySplitRE, 2) if (!search) { return null } - return Object.fromEntries(new URLSearchParams(search.slice(1))) + return Object.fromEntries(new URLSearchParams(search)) } export const blankReplacer = (match: string) => ' '.repeat(match.length) diff --git a/packages/vite/types/shims.d.ts b/packages/vite/types/shims.d.ts index 0f49e9c2181e98..587b3344e6ce39 100644 --- a/packages/vite/types/shims.d.ts +++ b/packages/vite/types/shims.d.ts @@ -59,6 +59,7 @@ declare module 'postcss-modules' { declare module '@rollup/plugin-dynamic-import-vars' { import type { Plugin } from 'rollup' + import type { BaseNode } from 'estree' interface Options { include?: string | RegExp | (string | RegExp)[] @@ -68,6 +69,10 @@ declare module '@rollup/plugin-dynamic-import-vars' { const p: (o?: Options) => Plugin export default p + export function dynamicImportToGlob( + ast: BaseNode, + source: string + ): null | string } declare module 'rollup-plugin-web-worker-loader' { diff --git a/playground/dynamic-import/__tests__/dynamic-import.spec.ts b/playground/dynamic-import/__tests__/dynamic-import.spec.ts index 4730b5e990a1c3..95101a039e50f8 100644 --- a/playground/dynamic-import/__tests__/dynamic-import.spec.ts +++ b/playground/dynamic-import/__tests__/dynamic-import.spec.ts @@ -60,6 +60,30 @@ test('should load dynamic import with css', async () => { ) }) +test('should load dynamic import with vars', async () => { + await untilUpdated( + () => page.textContent('.dynamic-import-with-vars'), + 'hello', + true + ) +}) + +test('should load dynamic import with vars alias', async () => { + await untilUpdated( + () => page.textContent('.dynamic-import-with-vars-alias'), + 'hello', + true + ) +}) + +test('should load dynamic import with vars raw', async () => { + await untilUpdated( + () => page.textContent('.dynamic-import-with-vars-raw'), + 'export function hello()', + true + ) +}) + test('should load dynamic import with css in package', async () => { await page.click('.pkg-css') await untilUpdated(() => getColor('.pkg-css'), 'blue', true) diff --git a/playground/dynamic-import/alias/hello.js b/playground/dynamic-import/alias/hello.js new file mode 100644 index 00000000000000..67900ef0999962 --- /dev/null +++ b/playground/dynamic-import/alias/hello.js @@ -0,0 +1,3 @@ +export function hello() { + return 'hello' +} diff --git a/playground/dynamic-import/alias/hi.js b/playground/dynamic-import/alias/hi.js new file mode 100644 index 00000000000000..45d3506803b2b6 --- /dev/null +++ b/playground/dynamic-import/alias/hi.js @@ -0,0 +1,3 @@ +export function hi() { + return 'hi' +} diff --git a/playground/dynamic-import/index.html b/playground/dynamic-import/index.html index 8e18204a7e4296..997ad059ad6821 100644 --- a/playground/dynamic-import/index.html +++ b/playground/dynamic-import/index.html @@ -10,6 +10,20 @@ +

dynamic-import-with-vars

+
todo
+ +

dynamic-import-with-vars-alias

+
todo
+ +

dynamic-import-with-vars-raw

+
todo
+
+ diff --git a/playground/dynamic-import/nested/hello.js b/playground/dynamic-import/nested/hello.js new file mode 100644 index 00000000000000..67900ef0999962 --- /dev/null +++ b/playground/dynamic-import/nested/hello.js @@ -0,0 +1,3 @@ +export function hello() { + return 'hello' +} diff --git a/playground/dynamic-import/nested/index.js b/playground/dynamic-import/nested/index.js index f84ec00380d604..61f817ce7dd7bc 100644 --- a/playground/dynamic-import/nested/index.js +++ b/playground/dynamic-import/nested/index.js @@ -78,3 +78,17 @@ document.querySelector('.pkg-css').addEventListener('click', async () => { function text(el, text) { document.querySelector(el).textContent = text } + +const base = 'hello' + +import(`../alias/${base}.js`).then((mod) => { + text('.dynamic-import-with-vars', mod.hello()) +}) + +import(`@/${base}.js`).then((mod) => { + text('.dynamic-import-with-vars-alias', mod.hello()) +}) + +import(`../alias/${base}.js?raw`).then((mod) => { + text('.dynamic-import-with-vars-raw', JSON.stringify(mod)) +}) diff --git a/playground/dynamic-import/vite.config.js b/playground/dynamic-import/vite.config.js index 010e47d6308d30..50b90639fddd7f 100644 --- a/playground/dynamic-import/vite.config.js +++ b/playground/dynamic-import/vite.config.js @@ -1,7 +1,8 @@ const fs = require('fs') const path = require('path') +const vite = require('vite') -module.exports = { +module.exports = vite.defineConfig({ plugins: [ { name: 'copy', @@ -20,5 +21,10 @@ module.exports = { ) } } - ] -} + ], + resolve: { + alias: { + '@': path.resolve(__dirname, 'alias') + } + } +}) From 780b4f5cdf02adb4ce42c283b60a4d4bb06b8440 Mon Sep 17 00:00:00 2001 From: shir0u <85612853+shir0u@users.noreply.github.com> Date: Tue, 10 May 2022 20:06:29 +1000 Subject: [PATCH 172/175] fix: allow css to be written for systemjs output (#5902) Co-authored-by: patak-dev --- packages/vite/src/node/plugins/css.ts | 8 +++- playground/legacy/__tests__/legacy.spec.ts | 11 ++++++ playground/legacy/dynamic.css | 3 ++ playground/legacy/index.html | 2 + playground/legacy/main.js | 8 ++++ playground/legacy/package.json | 1 + playground/legacy/vite.config-dynamic-css.js | 39 ++++++++++++++++++++ 7 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 playground/legacy/dynamic.css create mode 100644 playground/legacy/vite.config-dynamic-css.js diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index c13a4c83052639..1e1bcef686ea42 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -452,7 +452,11 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin { // this is a shared CSS-only chunk that is empty. pureCssChunks.add(chunk.fileName) } - if (opts.format === 'es' || opts.format === 'cjs') { + if ( + opts.format === 'es' || + opts.format === 'cjs' || + opts.format === 'system' + ) { chunkCSS = await processChunkCSS(chunkCSS, { inlined: false, minify: true @@ -513,7 +517,7 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin { .join('|') .replace(/\./g, '\\.') const emptyChunkRE = new RegExp( - opts.format === 'es' + opts.format === 'es' || opts.format === 'system' ? `\\bimport\\s*"[^"]*(?:${emptyChunkFiles})";\n?` : `\\brequire\\(\\s*"[^"]*(?:${emptyChunkFiles})"\\);\n?`, 'g' diff --git a/playground/legacy/__tests__/legacy.spec.ts b/playground/legacy/__tests__/legacy.spec.ts index 89cbadcacb2fd8..9fd3419337568d 100644 --- a/playground/legacy/__tests__/legacy.spec.ts +++ b/playground/legacy/__tests__/legacy.spec.ts @@ -56,6 +56,17 @@ test('correctly emits styles', async () => { expect(await getColor('#app')).toBe('red') }) +// dynamic import css +test('should load dynamic import with css', async () => { + await page.click('#dynamic-css-button') + await untilUpdated( + () => + page.$eval('#dynamic-css', (node) => window.getComputedStyle(node).color), + 'rgb(255, 0, 0)', + true + ) +}) + if (isBuild) { test('should generate correct manifest', async () => { const manifest = readManifest() diff --git a/playground/legacy/dynamic.css b/playground/legacy/dynamic.css new file mode 100644 index 00000000000000..160ee45a8a850a --- /dev/null +++ b/playground/legacy/dynamic.css @@ -0,0 +1,3 @@ +#dynamic-css { + color: red; +} diff --git a/playground/legacy/index.html b/playground/legacy/index.html index d481766463cd4f..cbf6242fad756b 100644 --- a/playground/legacy/index.html +++ b/playground/legacy/index.html @@ -4,4 +4,6 @@

+ +
diff --git a/playground/legacy/main.js b/playground/legacy/main.js index 31579b4717810d..157b6c8448e9c3 100644 --- a/playground/legacy/main.js +++ b/playground/legacy/main.js @@ -42,6 +42,14 @@ import('./immutable-chunk.js') text('#assets', assets.join('\n')) }) +// dynamic css +document + .querySelector('#dynamic-css-button') + .addEventListener('click', async () => { + await import('./dynamic.css') + text('#dynamic-css', 'dynamic import css') + }) + function text(el, text) { document.querySelector(el).textContent = text } diff --git a/playground/legacy/package.json b/playground/legacy/package.json index f8803564f93f12..4f11c234573f40 100644 --- a/playground/legacy/package.json +++ b/playground/legacy/package.json @@ -6,6 +6,7 @@ "dev": "vite", "build": "vite build --debug legacy", "build:custom-filename": "vite --config ./vite.config-custom-filename.js build --debug legacy", + "build:dynamic-css": "vite --config ./vite.config-dynamic-css.js build --debug legacy", "debug": "node --inspect-brk ../../packages/vite/bin/vite", "preview": "vite preview" }, diff --git a/playground/legacy/vite.config-dynamic-css.js b/playground/legacy/vite.config-dynamic-css.js new file mode 100644 index 00000000000000..10565768ac4d49 --- /dev/null +++ b/playground/legacy/vite.config-dynamic-css.js @@ -0,0 +1,39 @@ +const fs = require('fs') +const path = require('path') +const legacy = require('@vitejs/plugin-legacy').default + +module.exports = { + plugins: [ + legacy({ + targets: 'IE 11' + }) + ], + + build: { + cssCodeSplit: true, + manifest: true, + rollupOptions: { + output: { + chunkFileNames(chunkInfo) { + if (chunkInfo.name === 'immutable-chunk') { + return `assets/${chunkInfo.name}.js` + } + + return `assets/chunk-[name].[hash].js` + } + } + } + }, + + // special test only hook + // for tests, remove `