From 92934d4c18329cc51879aca5016a408b467c1fa0 Mon Sep 17 00:00:00 2001 From: Evan You Date: Mon, 8 Feb 2021 11:05:24 -0500 Subject: [PATCH 01/48] fix(ssr): ssr external should take scannd imports into account fix #1916 --- packages/vite/src/node/build.ts | 27 ++++++++++++++++--- .../src/node/optimizer/registerMissing.ts | 8 ++++++ packages/vite/src/node/server/index.ts | 7 ++++- packages/vite/src/node/ssr/ssrExternal.ts | 4 ++- 4 files changed, 41 insertions(+), 5 deletions(-) diff --git a/packages/vite/src/node/build.ts b/packages/vite/src/node/build.ts index d76b919646546e..9f1a7a58c51d3f 100644 --- a/packages/vite/src/node/build.ts +++ b/packages/vite/src/node/build.ts @@ -32,6 +32,8 @@ import { buildImportAnalysisPlugin } from './plugins/importAnaysisBuild' import { resolveSSRExternal, shouldExternalizeForSSR } from './ssr/ssrExternal' import { ssrManifestPlugin } from './ssr/ssrManifestPlugin' import { isCSSRequest } from './plugins/css' +import { DepOptimizationMetadata } from './optimizer' +import { scanImports } from './optimizer/scan' export interface BuildOptions { /** @@ -323,9 +325,28 @@ async function doBuild( // inject ssrExternal if present const userExternal = options.rollupOptions?.external - const external = ssr - ? resolveExternal(resolveSSRExternal(config), userExternal) - : userExternal + let external = userExternal + if (ssr) { + // see if we have cached deps data available + let knownImports: string[] | undefined + if (config.optimizeCacheDir) { + const dataPath = path.join(config.optimizeCacheDir, '_metadata.json') + try { + const data = JSON.parse( + fs.readFileSync(dataPath, 'utf-8') + ) as DepOptimizationMetadata + knownImports = Object.keys(data.optimized) + } catch (e) {} + } + if (!knownImports) { + // no dev deps optimization data, do a fresh scan + knownImports = Object.keys((await scanImports(config)).deps) + } + external = resolveExternal( + resolveSSRExternal(config, knownImports), + userExternal + ) + } const rollup = require('rollup') as typeof Rollup diff --git a/packages/vite/src/node/optimizer/registerMissing.ts b/packages/vite/src/node/optimizer/registerMissing.ts index 23746a95f9d193..033f05c7a784c5 100644 --- a/packages/vite/src/node/optimizer/registerMissing.ts +++ b/packages/vite/src/node/optimizer/registerMissing.ts @@ -1,6 +1,7 @@ import chalk from 'chalk' import { optimizeDeps } from '.' import { ViteDevServer } from '..' +import { resolveSSRExternal } from '../ssr/ssrExternal' /** * The amount to wait for requests to register newfound deps before triggering @@ -48,6 +49,13 @@ export function createMissingImpoterRegisterFn(server: ViteDevServer) { newDeps )) knownOptimized = newData!.optimized + + // update ssr externals + server._ssrExternals = resolveSSRExternal( + server.config, + Object.keys(knownOptimized) + ) + logger.info( chalk.greenBright(`✨ dependencies updated, reloading page...`), { timestamp: true } diff --git a/packages/vite/src/node/server/index.ts b/packages/vite/src/node/server/index.ts index 6c40c933b05588..db6dd587d65adb 100644 --- a/packages/vite/src/node/server/index.ts +++ b/packages/vite/src/node/server/index.ts @@ -307,7 +307,12 @@ export async function createServer( transformIndexHtml: null as any, ssrLoadModule(url, options) { if (!server._ssrExternals) { - server._ssrExternals = resolveSSRExternal(config) + server._ssrExternals = resolveSSRExternal( + config, + server._optimizeDepsMetadata + ? Object.keys(server._optimizeDepsMetadata.optimized) + : [] + ) } return ssrLoadModule(url, server, !!options?.isolated) }, diff --git a/packages/vite/src/node/ssr/ssrExternal.ts b/packages/vite/src/node/ssr/ssrExternal.ts index b65bf7fce520c2..5cf41c7961b9fc 100644 --- a/packages/vite/src/node/ssr/ssrExternal.ts +++ b/packages/vite/src/node/ssr/ssrExternal.ts @@ -13,6 +13,7 @@ import { ResolvedConfig } from '..' */ export function resolveSSRExternal( config: ResolvedConfig, + knownImports: string[], ssrExternals: Set = new Set() ): string[] { const { root } = config @@ -22,7 +23,7 @@ export function resolveSSRExternal( } const pkg = JSON.parse(pkgContent) const devDeps = Object.keys(pkg.devDependencies || {}) - const deps = Object.keys(pkg.dependencies || {}) + const deps = [...knownImports, ...Object.keys(pkg.dependencies || {})] for (const id of devDeps) { ssrExternals.add(id) @@ -63,6 +64,7 @@ export function resolveSSRExternal( ...config, root: depRoot }, + knownImports, ssrExternals ) continue From 6a6508edb9b31a4ea8bbc54b841f5227ba2b562a Mon Sep 17 00:00:00 2001 From: Evan You Date: Mon, 8 Feb 2021 11:23:29 -0500 Subject: [PATCH 02/48] fix(import-analysis): fix literal dynamic id false positive fix #1902 --- packages/vite/src/node/plugins/importAnalysis.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vite/src/node/plugins/importAnalysis.ts b/packages/vite/src/node/plugins/importAnalysis.ts index f7987d06d9a10d..085bcd6ed13e1a 100644 --- a/packages/vite/src/node/plugins/importAnalysis.ts +++ b/packages/vite/src/node/plugins/importAnalysis.ts @@ -309,7 +309,7 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin { hasViteIgnore = /\/\*\s*@vite-ignore\s*\*\//.test(url) // #998 remove comment url = url.replace(/\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$/gm, '').trim() - const literalIdMatch = url.match(/^'([^']+)'|"([^"]+)"$/) + const literalIdMatch = url.match(/^(?:'([^']+)'|"([^"]+)")$/) if (literalIdMatch) { isLiteralDynamicId = true url = literalIdMatch[1] || literalIdMatch[2] From b433607aca0986c6e1592c3f64adb2ef30689c5e Mon Sep 17 00:00:00 2001 From: Evan You Date: Mon, 8 Feb 2021 11:31:32 -0500 Subject: [PATCH 03/48] fix: use dedicated endpoint for hmr reconnect ping fix #1904 --- packages/vite/src/client/client.ts | 2 +- packages/vite/src/node/server/index.ts | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/vite/src/client/client.ts b/packages/vite/src/client/client.ts index cf392ee762d753..1a6ac2baac6ec9 100644 --- a/packages/vite/src/client/client.ts +++ b/packages/vite/src/client/client.ts @@ -173,7 +173,7 @@ socket.addEventListener('close', ({ wasClean }) => { if (wasClean) return console.log(`[vite] server connection lost. polling for restart...`) setInterval(() => { - fetch('/') + fetch(`${base}__vite_ping`) .then(() => { location.reload() }) diff --git a/packages/vite/src/node/server/index.ts b/packages/vite/src/node/server/index.ts index db6dd587d65adb..b2e2d5709e52ca 100644 --- a/packages/vite/src/node/server/index.ts +++ b/packages/vite/src/node/server/index.ts @@ -415,6 +415,9 @@ export async function createServer( // open in editor support middlewares.use('/__open-in-editor', launchEditorMiddleware()) + // hmr reconnect ping + middlewares.use('/__vite_ping', (_, res) => res.end('pong')) + // serve static files under /public // this applies before the transform middleware so that these files are served // as-is without transforms. From 89e0e33b66ecf199fedce18628f0c382e45f93a6 Mon Sep 17 00:00:00 2001 From: Ilya Artamonov Date: Mon, 8 Feb 2021 19:47:01 +0300 Subject: [PATCH 04/48] docs: fix performance optimizations link (#1943) --- docs/guide/introduction.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guide/introduction.md b/docs/guide/introduction.md index 7bf067a7952d0f..f91128234fd307 100644 --- a/docs/guide/introduction.md +++ b/docs/guide/introduction.md @@ -52,7 +52,7 @@ Once you experience how fast Vite is, we highly doubt you'd be willing to put up Even though native ESM is now widely supported, shipping unbundled ESM in production is still inefficient (even with HTTP/2) due to the additional network round trips caused by nested imports. To get the optimal loading performance in production, it is still better to bundle your code with tree-shaking, lazy-loading and common chunk splitting (for better caching). -Ensuring optimal output and behavioral consistency between the dev server and the production build isn't easy. This is why Vite ships with a pre-configured [build command](./build) that bakes in many [performance optimizations](.features#build-optimizations) out of the box. +Ensuring optimal output and behavioral consistency between the dev server and the production build isn't easy. This is why Vite ships with a pre-configured [build command](./build) that bakes in many [performance optimizations](./features#build-optimizations) out of the box. ## Browser Support From 0cdf62acc59aab702297a2f799883d67eeb01760 Mon Sep 17 00:00:00 2001 From: Evan You Date: Mon, 8 Feb 2021 13:47:08 -0500 Subject: [PATCH 05/48] chore: update lockfile --- yarn.lock | 431 +++++++++++++++++++++++++++--------------------------- 1 file changed, 215 insertions(+), 216 deletions(-) diff --git a/yarn.lock b/yarn.lock index a0dc18282dc89b..a189b484546e6f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,109 +2,109 @@ # yarn lockfile v1 -"@algolia/cache-browser-local-storage@4.8.4": - version "4.8.4" - resolved "https://registry.yarnpkg.com/@algolia/cache-browser-local-storage/-/cache-browser-local-storage-4.8.4.tgz#6a03ffc6b0b5b5aa7f74732bf8091a0f3d2b0986" - integrity sha512-qSS3VMP3oMhcLrYIFveRyt3F5XB6MqWogF4Vooj8KvOvqv6jBmYwkAueSXCF5pkJEaA72VL9+9NbBpfC8ez2ww== - dependencies: - "@algolia/cache-common" "4.8.4" - -"@algolia/cache-common@4.8.4": - version "4.8.4" - resolved "https://registry.yarnpkg.com/@algolia/cache-common/-/cache-common-4.8.4.tgz#b105bdfe3fa0ba15db936177c4db420befed2ab7" - integrity sha512-5+dLmj6qFy4WOtnNQuFRfWTIIDdpUigv+dXaKMFplNPBvZHGFy3hcRjWqYzGcqaeLqcXbN8cU5r75mvrlJIxcw== - -"@algolia/cache-in-memory@4.8.4": - version "4.8.4" - resolved "https://registry.yarnpkg.com/@algolia/cache-in-memory/-/cache-in-memory-4.8.4.tgz#e978935dd8c4bbd555820e9b9fc863a24f3d38dd" - integrity sha512-PBN4YKxn/L+HjVKqUE5rtLiFKqzm4qnUoF7QvCFFmFAViCdYwZSMFVmDobstqWY3KULfsEqaeD4eU4jxZbKhEA== - dependencies: - "@algolia/cache-common" "4.8.4" - -"@algolia/client-account@4.8.4": - version "4.8.4" - resolved "https://registry.yarnpkg.com/@algolia/client-account/-/client-account-4.8.4.tgz#a0af429e3587b33a988fec98ce0c739fd16143aa" - integrity sha512-mrsOnGV4O2b+t1CumUH72+Psw9d9qwngBEp2le7IMSceJQywQvNCyJ4B4qyoozHsIGapXfcVAOhRxqUsNQ6U6g== - dependencies: - "@algolia/client-common" "4.8.4" - "@algolia/client-search" "4.8.4" - "@algolia/transporter" "4.8.4" - -"@algolia/client-analytics@4.8.4": - version "4.8.4" - resolved "https://registry.yarnpkg.com/@algolia/client-analytics/-/client-analytics-4.8.4.tgz#77c81b699909b50ecd9bf97997f014cfeb358fc3" - integrity sha512-Xy70njSUgG/QTv5+rPjsTIzBF/bjxseS5h9SawrQGzovTosbJbu9JBlg4YwVJnYvjovzpr7S39+gPIPc8M7+Rg== - dependencies: - "@algolia/client-common" "4.8.4" - "@algolia/client-search" "4.8.4" - "@algolia/requester-common" "4.8.4" - "@algolia/transporter" "4.8.4" - -"@algolia/client-common@4.8.4": - version "4.8.4" - resolved "https://registry.yarnpkg.com/@algolia/client-common/-/client-common-4.8.4.tgz#a1b35645253c7f96925bfe91bac486e755329b77" - integrity sha512-sQlRa+KWFn+D8AOEZb4kj6RE/i6DnPwVOF4AnNf9IjNB0mUUhLWw96cQN6GDx0KE4lhW67t+qR39ZuuDBgR9ww== - dependencies: - "@algolia/requester-common" "4.8.4" - "@algolia/transporter" "4.8.4" - -"@algolia/client-recommendation@4.8.4": - version "4.8.4" - resolved "https://registry.yarnpkg.com/@algolia/client-recommendation/-/client-recommendation-4.8.4.tgz#1aaa9735e96865ff06321a8bc850829445c945d1" - integrity sha512-CE0CVqLGWotVOaUXyU33FVD9FZ/7rqcbwFPH5MgSjVdE0B1YWVedhR0s2BNKodXLcIGVLVYfXR05CLdvOlTw+A== - dependencies: - "@algolia/client-common" "4.8.4" - "@algolia/requester-common" "4.8.4" - "@algolia/transporter" "4.8.4" - -"@algolia/client-search@4.8.4": - version "4.8.4" - resolved "https://registry.yarnpkg.com/@algolia/client-search/-/client-search-4.8.4.tgz#0320c4a109d2cc220a9d1002f9ec64655a4494dc" - integrity sha512-eH2tRPnDU3tqpp0BSqP6coRRQe8fceqsupuf/1ho+Mcs5DM13mEuFmNOyPywHRlYLVPmbbCPRhDr5rB8QoN7XQ== - dependencies: - "@algolia/client-common" "4.8.4" - "@algolia/requester-common" "4.8.4" - "@algolia/transporter" "4.8.4" - -"@algolia/logger-common@4.8.4": - version "4.8.4" - resolved "https://registry.yarnpkg.com/@algolia/logger-common/-/logger-common-4.8.4.tgz#42ecab3c92388a0d81b8532cefb47670da46cdd3" - integrity sha512-6hOaFG75Onmant9adcaeCZgvPYfnif7n0H1ycbixm6/WH3SmxqPMG+CMiW8mTNTRrrAEceQVrq6tDHD8jdnOOw== - -"@algolia/logger-console@4.8.4": - version "4.8.4" - resolved "https://registry.yarnpkg.com/@algolia/logger-console/-/logger-console-4.8.4.tgz#adfac58df84848443bff1326986a0ca98db866b9" - integrity sha512-+9T3t/eB9vseANFz9YbFHG0cHjzVP/DVfGqzTAkeSlvMHP69JzJga9Wb0Ai6J3xXE3d4k9K+k6t+kkjCQjzEqg== - dependencies: - "@algolia/logger-common" "4.8.4" - -"@algolia/requester-browser-xhr@4.8.4": - version "4.8.4" - resolved "https://registry.yarnpkg.com/@algolia/requester-browser-xhr/-/requester-browser-xhr-4.8.4.tgz#30c5c9d129fafd863b7c9c7a988c36ec5754b973" - integrity sha512-BYa8O/pht0UL2bcm0ZkLZiyC+5dHrbc6gvKIo+OgqxmDb/K4KrVo6RIof3BVpR8fgcfxQJohjNVHKXHxEUhBCQ== - dependencies: - "@algolia/requester-common" "4.8.4" - -"@algolia/requester-common@4.8.4": - version "4.8.4" - resolved "https://registry.yarnpkg.com/@algolia/requester-common/-/requester-common-4.8.4.tgz#670f5e43e4d09ff9a3b9bfda7ac0c03476a9e4b1" - integrity sha512-br3LXb6srfAy7F04axwExmrkPOlXCDckgTFoLFv/RT9Oo28SpoyvHqktyBovQLdzdTs+Laglf+LtOHr0iUrZJg== - -"@algolia/requester-node-http@4.8.4": - version "4.8.4" - resolved "https://registry.yarnpkg.com/@algolia/requester-node-http/-/requester-node-http-4.8.4.tgz#8af2cceb45e5bb2b9e7ed3b7daa34f3c2580912a" - integrity sha512-o5Cc4UxYPn3IBHQSDBNFFhq1LQLv40eYvCvK0FPJ8xZkrnNXhjPvaLCu/lQTHpk/HX7DaE6fQ/KboU0OSPKevQ== - dependencies: - "@algolia/requester-common" "4.8.4" - -"@algolia/transporter@4.8.4": - version "4.8.4" - resolved "https://registry.yarnpkg.com/@algolia/transporter/-/transporter-4.8.4.tgz#09452334e380ff0706676303e6642e76b72ae0bf" - integrity sha512-EvXFYICxrr9QEO6m6awUeNOBstOxePQ2Fy0jtYlS1v9TY2P5HqKRzkxmaZjeYRBsXOImpVjgQIzTzj1Au4br2w== - dependencies: - "@algolia/cache-common" "4.8.4" - "@algolia/logger-common" "4.8.4" - "@algolia/requester-common" "4.8.4" +"@algolia/cache-browser-local-storage@4.8.5": + version "4.8.5" + resolved "https://registry.yarnpkg.com/@algolia/cache-browser-local-storage/-/cache-browser-local-storage-4.8.5.tgz#3eb10758c794d3cc8fc4e9f09e339d5b9589dc9c" + integrity sha512-9rs/Yi82ilgifweJamOy4DlJ4xPGsCN/zg+RKy4vjytNhOrkEHLRQC8vPZ3OhD8KVlw9lRQIZTlgjgFl8iMeeA== + dependencies: + "@algolia/cache-common" "4.8.5" + +"@algolia/cache-common@4.8.5": + version "4.8.5" + resolved "https://registry.yarnpkg.com/@algolia/cache-common/-/cache-common-4.8.5.tgz#86f8a6878bd2fc5c8d889e48d18d3033faa0bcd8" + integrity sha512-4SvRWnagKtwBFAy8Rsfmv0/Uk53fZL+6dy2idwdx6SjMGKSs0y1Qv+thb4h/k/H5MONisAoT9C2rgZ/mqwh5yw== + +"@algolia/cache-in-memory@4.8.5": + version "4.8.5" + resolved "https://registry.yarnpkg.com/@algolia/cache-in-memory/-/cache-in-memory-4.8.5.tgz#13055d54775f99aa4e1ce051e73079d0f207a3e6" + integrity sha512-XBBfqs28FbjwLboY3sxvuzBgYsuXdFsj2mUvkgxfb0GVEzwW4I0NM7KzSPwT+iht55WS1PgIOnynjmhPsrubCw== + dependencies: + "@algolia/cache-common" "4.8.5" + +"@algolia/client-account@4.8.5": + version "4.8.5" + resolved "https://registry.yarnpkg.com/@algolia/client-account/-/client-account-4.8.5.tgz#92df1dd0a7bea06e329873c7098c72cc4dd8e9d6" + integrity sha512-DjXMpeCdY4J4IDBfowiG6Xl9ec/FhG1NpPQM0Uv4xXsc/TeeZ1JgbgNDhWe9jW0jBEALy+a/RmPrZ0vsxcadsg== + dependencies: + "@algolia/client-common" "4.8.5" + "@algolia/client-search" "4.8.5" + "@algolia/transporter" "4.8.5" + +"@algolia/client-analytics@4.8.5": + version "4.8.5" + resolved "https://registry.yarnpkg.com/@algolia/client-analytics/-/client-analytics-4.8.5.tgz#1aa731a146b347022a0a9e0eb009f2b2f8d9825f" + integrity sha512-PQEY+chbHmZnRJdaWsvUYzDpEPr60az0EPUexdouvXGZId15/SnDaXjnf89F7tYmCzkHdUtG4bSvPzAupQ4AFA== + dependencies: + "@algolia/client-common" "4.8.5" + "@algolia/client-search" "4.8.5" + "@algolia/requester-common" "4.8.5" + "@algolia/transporter" "4.8.5" + +"@algolia/client-common@4.8.5": + version "4.8.5" + resolved "https://registry.yarnpkg.com/@algolia/client-common/-/client-common-4.8.5.tgz#77e5d9bbfcb421fa8812cdd91943961c64793148" + integrity sha512-Dn8vog2VrGsJeOcBMcSAEIjBtPyogzUBGlh1DtVd0m8GN6q+cImCESl6DY846M2PTYWsLBKBksq37eUfSe9FxQ== + dependencies: + "@algolia/requester-common" "4.8.5" + "@algolia/transporter" "4.8.5" + +"@algolia/client-recommendation@4.8.5": + version "4.8.5" + resolved "https://registry.yarnpkg.com/@algolia/client-recommendation/-/client-recommendation-4.8.5.tgz#f02f8f8ff3983597cae677ec0bc3eb01ae26121a" + integrity sha512-ffawCC1C25rCa8/JU2niRZgwr8aV9b2qsLVMo73GXFzi2lceXPAe9K68mt/BGHU+w7PFUwVHsV2VmB+G/HQRVw== + dependencies: + "@algolia/client-common" "4.8.5" + "@algolia/requester-common" "4.8.5" + "@algolia/transporter" "4.8.5" + +"@algolia/client-search@4.8.5": + version "4.8.5" + resolved "https://registry.yarnpkg.com/@algolia/client-search/-/client-search-4.8.5.tgz#970a5c91847822dbd82565f97bd2a0c37a5d56e6" + integrity sha512-Ru2MljGZWrSQ0CVsDla11oGEPL/RinmVkLJfBtQ+/pk1868VfpAQFGKtOS/b8/xLrMA0Vm4EfC3Mgclk/p3KJA== + dependencies: + "@algolia/client-common" "4.8.5" + "@algolia/requester-common" "4.8.5" + "@algolia/transporter" "4.8.5" + +"@algolia/logger-common@4.8.5": + version "4.8.5" + resolved "https://registry.yarnpkg.com/@algolia/logger-common/-/logger-common-4.8.5.tgz#ef275c532c21424f4b29b26ec2e27de2c973ad95" + integrity sha512-PS6NS6bpED0rAxgCPGhjZJg9why0PnoVEE7ZoCbPq6lsAOc6FPlQLri4OiLyU7wx8RWDoVtOadyzulqAAsfPSQ== + +"@algolia/logger-console@4.8.5": + version "4.8.5" + resolved "https://registry.yarnpkg.com/@algolia/logger-console/-/logger-console-4.8.5.tgz#8fe547fdcf76574963503f7c4ff2673e792ae886" + integrity sha512-3+4gLSbwzuGmrb5go3IZNcFIYVMSbB4c8UMtWEJ/gDBtgGZIvT6f/KlvVSOHIhthSxaM3Y13V6Qile/SpGqc6A== + dependencies: + "@algolia/logger-common" "4.8.5" + +"@algolia/requester-browser-xhr@4.8.5": + version "4.8.5" + resolved "https://registry.yarnpkg.com/@algolia/requester-browser-xhr/-/requester-browser-xhr-4.8.5.tgz#95e01e2dca38358055f08440f46d4f0b9f735280" + integrity sha512-M/Gf2vv/fU4+CqDW+wok7HPpEcLym3NtDzU9zaPzGYI/9X7o36581oyfnzt2pNfsXSQVj5a2pZVUWC3Z4SO27w== + dependencies: + "@algolia/requester-common" "4.8.5" + +"@algolia/requester-common@4.8.5": + version "4.8.5" + resolved "https://registry.yarnpkg.com/@algolia/requester-common/-/requester-common-4.8.5.tgz#952dec3b36c14495af158914cd6c0e2c9ce72b5e" + integrity sha512-OIhsdwIrJVAlVlP7cwlt+RoR5AmxAoTGrFokOY9imVmgqXUUljdKO/DjhRL8vwYGFEidZ9efIjAIQ2B3XOhT9A== + +"@algolia/requester-node-http@4.8.5": + version "4.8.5" + resolved "https://registry.yarnpkg.com/@algolia/requester-node-http/-/requester-node-http-4.8.5.tgz#a1e5a6d23a9a4e78abd5a2416f1a6c232b0a7e14" + integrity sha512-viHAjfo53A3VSE7Bb/nzgpSMZ3prPp2qti7Wg8w7qxhntppKp3Fln6t4Vp+BoPOqruLsj139xXhheAKeRcYa0w== + dependencies: + "@algolia/requester-common" "4.8.5" + +"@algolia/transporter@4.8.5": + version "4.8.5" + resolved "https://registry.yarnpkg.com/@algolia/transporter/-/transporter-4.8.5.tgz#86f4e286cb4eba6e62f1c0393c33cc17ff262fa9" + integrity sha512-Rb3cMlh/GoJK0+g+49GNA3IvR/EXsDEBwpyM+FOotSwxgiGt1wGBHM0K2v0GHwIEcuww02pl6KMDVlilA+qh0g== + dependencies: + "@algolia/cache-common" "4.8.5" + "@algolia/logger-common" "4.8.5" + "@algolia/requester-common" "4.8.5" "@arr/every@^1.0.0": version "1.0.1" @@ -140,9 +140,9 @@ source-map "^0.5.0" "@babel/generator@^7.12.13": - version "7.12.13" - resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.12.13.tgz#5f6ebe6c85db99886db2d7b044409196f872a503" - integrity sha512-9qQ8Fgo8HaSvHEt6A5+BATP7XktD/AdAnObUeTRz5/e2y3kbrxZgz32qUJJsdmwUvBJzF4AeV21nGTNwv05Mpw== + version "7.12.15" + resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.12.15.tgz#4617b5d0b25cc572474cc1aafee1edeaf9b5368f" + integrity sha512-6F2xHxBiFXWNSGb7vyCUTBF8RCLY66rS0zEPcP8t/nQyXjha5EuK4z7H5o7fWG8B4M7y6mqVWq1J+1PuwRhecQ== dependencies: "@babel/types" "^7.12.13" jsesc "^2.5.1" @@ -264,9 +264,9 @@ js-tokens "^4.0.0" "@babel/parser@^7.1.0", "@babel/parser@^7.12.0", "@babel/parser@^7.12.13", "@babel/parser@^7.6.0", "@babel/parser@^7.9.6": - version "7.12.13" - resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.12.13.tgz#3ee7be4131fe657ba9143d5c5b3a9f253fdb75e9" - integrity sha512-z7n7ybOUzaRc3wwqLpAX8UFIXsrVXUJhtNGBwAnLz6d1KUapqyq7ad2La8gZ6CXhHmGAIL32cop8Tst4/PNWLw== + version "7.12.15" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.12.15.tgz#2b20de7f0b4b332d9b119dd9c33409c538b8aacf" + integrity sha512-AQBOU2Z9kWwSZMd6lNjCX0GUgFonL1wAM1db8L8PMk9UDaGsRCArBkU4Sc+UCM3AE4hjbXx+h58Lb3QT4oRmrA== "@babel/plugin-syntax-async-generators@^7.8.4": version "7.8.4" @@ -397,9 +397,9 @@ regenerator-runtime "^0.13.4" "@babel/standalone@^7.12.12": - version "7.12.13" - resolved "https://registry.yarnpkg.com/@babel/standalone/-/standalone-7.12.13.tgz#99650a35132de1a13e377d4a63b7286fd95c7e1b" - integrity sha512-GCI57RGfODuEv69t3HRv0ZGsZYHZf9Wb2dwne8BXod0UOcTN3HWAunSrSTR42fHTIQD1yj1r8Zx0AINSYz97Ew== + version "7.12.15" + resolved "https://registry.yarnpkg.com/@babel/standalone/-/standalone-7.12.15.tgz#fade4ccb2af79c53300b8e71f4c1f0ecf59123e2" + integrity sha512-H4TLICPkno/jBZWW4SC3kVzK3ByrwtyANZ1gCgl4+01DuXDyUFTWqigYvd5vjuixzXfdkDodTvXhv5p249pQNw== "@babel/template@^7.0.0", "@babel/template@^7.12.13", "@babel/template@^7.3.3": version "7.12.13" @@ -683,22 +683,22 @@ "@types/yargs" "^15.0.0" chalk "^4.0.0" -"@microsoft/api-extractor-model@7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@microsoft/api-extractor-model/-/api-extractor-model-7.12.1.tgz#1f10915c434048da34e1c07845ba2623d5f23f66" - integrity sha512-Hw+kYfUb1gt6xPWGFW8APtLVWeNEWz4JE6PbLkSHw/j+G1hAaStzgxhBx3GOAWM/G0SCDGVJOpd5YheVOyu/KQ== +"@microsoft/api-extractor-model@7.12.2": + version "7.12.2" + resolved "https://registry.yarnpkg.com/@microsoft/api-extractor-model/-/api-extractor-model-7.12.2.tgz#d48b35e8ed20643b1c19d7a4f80c90c42dc7d1d8" + integrity sha512-EU+U09Mj65zUH0qwPF4PFJiL6Y+PQQE/RRGEHEDGJJzab/mRQDpKOyrzSdb00xvcd/URehIHJqC55cY2Y4jGOA== dependencies: "@microsoft/tsdoc" "0.12.24" - "@rushstack/node-core-library" "3.35.2" + "@rushstack/node-core-library" "3.36.0" "@microsoft/api-extractor@^7.12.1": - version "7.13.0" - resolved "https://registry.yarnpkg.com/@microsoft/api-extractor/-/api-extractor-7.13.0.tgz#13900fc7596c29daeecd3f33ed8960cfc5250107" - integrity sha512-T+14VIhB91oJIett5AZ02VWYmz/01VHFWkcAOWiErIQ8AiFhJZoGqTjGxoi8ZpEEBuAj2EGVYojORwLc/+aiDQ== + version "7.13.1" + resolved "https://registry.yarnpkg.com/@microsoft/api-extractor/-/api-extractor-7.13.1.tgz#0ed26ac18ccda075553e9fbe26dce4104d8d042f" + integrity sha512-mnWb5Vuyn/JnjC359HfsRmLDM4/vzyKcJuxQr5Cg/apbkMHuTB1hQrqA8zBda4N+MJZ5ET2BPsrKaUX1qhz8jw== dependencies: - "@microsoft/api-extractor-model" "7.12.1" + "@microsoft/api-extractor-model" "7.12.2" "@microsoft/tsdoc" "0.12.24" - "@rushstack/node-core-library" "3.35.2" + "@rushstack/node-core-library" "3.36.0" "@rushstack/rig-package" "0.2.9" "@rushstack/ts-command-line" "4.7.8" colors "~1.2.1" @@ -818,10 +818,10 @@ estree-walker "^2.0.1" picomatch "^2.2.2" -"@rushstack/node-core-library@3.35.2": - version "3.35.2" - resolved "https://registry.yarnpkg.com/@rushstack/node-core-library/-/node-core-library-3.35.2.tgz#21ca879b5051a5ebafa952fafcd648a07a142bcb" - integrity sha512-SPd0uG7mwsf3E30np9afCUhtaM1SBpibrbxOXPz82KWV6SQiPUtXeQfhXq9mSnGxOb3WLWoSDe7AFxQNex3+kQ== +"@rushstack/node-core-library@3.36.0": + version "3.36.0" + resolved "https://registry.yarnpkg.com/@rushstack/node-core-library/-/node-core-library-3.36.0.tgz#95dace39d763c8695d6607c421f95c6ac65b0ed4" + integrity sha512-bID2vzXpg8zweXdXgQkKToEdZwVrVCN9vE9viTRk58gqzYaTlz4fMId6V3ZfpXN6H0d319uGi2KDlm+lUEeqCg== dependencies: "@types/node" "10.17.13" colors "~1.2.1" @@ -1011,9 +1011,9 @@ integrity sha512-fZQQafSREFyuZcdWFAExYjBiCL7AUCdgsk80iO0q4yihYYdcIiH28CcuPTGFgLOCC8RlW49GSQxdHwZP+I7CNg== "@types/node@*", "@types/node@^14.14.10": - version "14.14.22" - resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.22.tgz#0d29f382472c4ccf3bd96ff0ce47daf5b7b84b18" - integrity sha512-g+f/qj/cNcqKkc3tFqlXOYjrmZA+jNBiDzbP3kH+B+otKFqAdPgVTGP1IeKRdMml/aE69as5S4FqtxAbl+LaMw== + version "14.14.25" + resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.25.tgz#15967a7b577ff81383f9b888aa6705d43fbbae93" + integrity sha512-EPpXLOVqDvisVxtlbvzfyqSsFeQxltFbluZNRndIb8tr9KiBnYNLzrc1N3pyKUCww2RNrfHDViqDWWE1LCJQtQ== "@types/node@10.17.13": version "10.17.13" @@ -1031,9 +1031,9 @@ integrity sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA== "@types/prettier@^2.0.0": - version "2.1.6" - resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.1.6.tgz#f4b1efa784e8db479cdb8b14403e2144b1e9ff03" - integrity sha512-6gOkRe7OIioWAXfnO/2lFiv+SJichKVSys1mSsgyrYHSEjk8Ctv4tSR/Odvnu+HWlH2C8j53dahU03XmQdd5fA== + version "2.2.0" + resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.2.0.tgz#a4e8205a4955690eef712a6d0394a1d2e121e721" + integrity sha512-O3SQC6+6AySHwrspYn2UvC6tjo6jCTMMmylxZUFhE1CulVu5l3AxU6ca9lrJDTQDVllF62LIxVSx5fuYL6LiZg== "@types/resolve@1.17.1": version "1.17.1" @@ -1093,48 +1093,47 @@ "@types/node" "*" "@typescript-eslint/parser@^4.9.1": - version "4.14.2" - resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-4.14.2.tgz#31e216e4baab678a56e539f9db9862e2542c98d0" - integrity sha512-ipqSP6EuUsMu3E10EZIApOJgWSpcNXeKZaFeNKQyzqxnQl8eQCbV+TSNsl+s2GViX2d18m1rq3CWgnpOxDPgHg== + version "4.15.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-4.15.0.tgz#8df94365b4b7161f9e8514fe28aef19954810b6b" + integrity sha512-L6Dtbq8Bc7g2aZwnIBETpmUa9XDKCMzKVwAArnGp5Mn7PRNFjf3mUzq8UeBjL3K8t311hvevnyqXAMSmxO8Gpg== dependencies: - "@typescript-eslint/scope-manager" "4.14.2" - "@typescript-eslint/types" "4.14.2" - "@typescript-eslint/typescript-estree" "4.14.2" + "@typescript-eslint/scope-manager" "4.15.0" + "@typescript-eslint/types" "4.15.0" + "@typescript-eslint/typescript-estree" "4.15.0" debug "^4.1.1" -"@typescript-eslint/scope-manager@4.14.2": - version "4.14.2" - resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.14.2.tgz#64cbc9ca64b60069aae0c060b2bf81163243b266" - integrity sha512-cuV9wMrzKm6yIuV48aTPfIeqErt5xceTheAgk70N1V4/2Ecj+fhl34iro/vIssJlb7XtzcaD07hWk7Jk0nKghg== +"@typescript-eslint/scope-manager@4.15.0": + version "4.15.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.15.0.tgz#c42703558ea6daaaba51a9c3a86f2902dbab9432" + integrity sha512-CSNBZnCC2jEA/a+pR9Ljh8Y+5TY5qgbPz7ICEk9WCpSEgT6Pi7H2RIjxfrrbUXvotd6ta+i27sssKEH8Azm75g== dependencies: - "@typescript-eslint/types" "4.14.2" - "@typescript-eslint/visitor-keys" "4.14.2" + "@typescript-eslint/types" "4.15.0" + "@typescript-eslint/visitor-keys" "4.15.0" -"@typescript-eslint/types@4.14.2": - version "4.14.2" - resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.14.2.tgz#d96da62be22dc9dc6a06647f3633815350fb3174" - integrity sha512-LltxawRW6wXy4Gck6ZKlBD05tCHQUj4KLn4iR69IyRiDHX3d3NCAhO+ix5OR2Q+q9bjCrHE/HKt+riZkd1At8Q== +"@typescript-eslint/types@4.15.0": + version "4.15.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.15.0.tgz#3011ae1ac3299bb9a5ac56bdd297cccf679d3662" + integrity sha512-su4RHkJhS+iFwyqyXHcS8EGPlUVoC+XREfy5daivjLur9JP8GhvTmDipuRpcujtGC4M+GYhUOJCPDE3rC5NJrg== -"@typescript-eslint/typescript-estree@4.14.2": - version "4.14.2" - resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.14.2.tgz#9c5ebd8cae4d7b014f890acd81e8e17f309c9df9" - integrity sha512-ESiFl8afXxt1dNj8ENEZT12p+jl9PqRur+Y19m0Z/SPikGL6rqq4e7Me60SU9a2M28uz48/8yct97VQYaGl0Vg== +"@typescript-eslint/typescript-estree@4.15.0": + version "4.15.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.15.0.tgz#402c86a7d2111c1f7a2513022f22a38a395b7f93" + integrity sha512-jG6xTmcNbi6xzZq0SdWh7wQ9cMb2pqXaUp6bUZOMsIlu5aOlxGxgE/t6L/gPybybQGvdguajXGkZKSndZJpksA== dependencies: - "@typescript-eslint/types" "4.14.2" - "@typescript-eslint/visitor-keys" "4.14.2" + "@typescript-eslint/types" "4.15.0" + "@typescript-eslint/visitor-keys" "4.15.0" debug "^4.1.1" globby "^11.0.1" is-glob "^4.0.1" - lodash "^4.17.15" semver "^7.3.2" tsutils "^3.17.1" -"@typescript-eslint/visitor-keys@4.14.2": - version "4.14.2" - resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.14.2.tgz#997cbe2cb0690e1f384a833f64794e98727c70c6" - integrity sha512-KBB+xLBxnBdTENs/rUgeUKO0UkPBRs2vD09oMRRIkj5BEN8PX1ToXV532desXfpQnZsYTyLLviS7JrPhdL154w== +"@typescript-eslint/visitor-keys@4.15.0": + version "4.15.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.15.0.tgz#2a07768df30c8a5673f1bce406338a07fdec38ca" + integrity sha512-RnDtJwOwFucWFAMjG3ghCG/ikImFJFEg20DI7mn4pHEx3vC48lIAoyjhffvfHmErRDboUPC7p9Z2il4CLb7qxA== dependencies: - "@typescript-eslint/types" "4.14.2" + "@typescript-eslint/types" "4.15.0" eslint-visitor-keys "^2.0.0" "@vue/babel-helper-vue-transform-on@^1.0.2": @@ -1143,9 +1142,9 @@ integrity sha512-hz4R8tS5jMn8lDq6iD+yWL6XNB699pGIVLk7WSJnn1dbpjaazsjZQkieJoRX6gW5zpYSCFqQ7jUquPNY65tQYA== "@vue/babel-plugin-jsx@^1.0.1": - version "1.0.2" - resolved "https://registry.yarnpkg.com/@vue/babel-plugin-jsx/-/babel-plugin-jsx-1.0.2.tgz#6bfd8e39c48e53391a56705649f81a35fe20b6a1" - integrity sha512-1uZlQCLCeuqJgDYLCmg3qfsvTVtOQiXh278ES4bvPTYYbv2Bi/rElLETK6AdjI9xxzyTUf5n1QEiH8Xxz0eZrg== + version "1.0.3" + resolved "https://registry.yarnpkg.com/@vue/babel-plugin-jsx/-/babel-plugin-jsx-1.0.3.tgz#ad5ee86ebc9fc40900add9914534e223c719eace" + integrity sha512-+52ZQFmrM0yh61dQlgwQlfHZXmYbswbQEL25SOSt9QkjegAdfIGu87oELw0l8H6cuJYazZCiNjPR9eU++ZIbxg== dependencies: "@babel/helper-module-imports" "^7.0.0" "@babel/plugin-syntax-jsx" "^7.0.0" @@ -1357,24 +1356,24 @@ ajv@^7.0.2: uri-js "^4.2.2" algoliasearch@^4.0.0: - version "4.8.4" - resolved "https://registry.yarnpkg.com/algoliasearch/-/algoliasearch-4.8.4.tgz#ac2fc9335dfe06f55b9bd4faf6050ea0c8e0feea" - integrity sha512-QbXpFvBKj/QhKWE7xBoqaWOWyw7ni6W6THSuFJHOcADRrInhjFCBYjrv+YsIhv9huCepKXWpfV4UJup9BslVhQ== - dependencies: - "@algolia/cache-browser-local-storage" "4.8.4" - "@algolia/cache-common" "4.8.4" - "@algolia/cache-in-memory" "4.8.4" - "@algolia/client-account" "4.8.4" - "@algolia/client-analytics" "4.8.4" - "@algolia/client-common" "4.8.4" - "@algolia/client-recommendation" "4.8.4" - "@algolia/client-search" "4.8.4" - "@algolia/logger-common" "4.8.4" - "@algolia/logger-console" "4.8.4" - "@algolia/requester-browser-xhr" "4.8.4" - "@algolia/requester-common" "4.8.4" - "@algolia/requester-node-http" "4.8.4" - "@algolia/transporter" "4.8.4" + version "4.8.5" + resolved "https://registry.yarnpkg.com/algoliasearch/-/algoliasearch-4.8.5.tgz#17a97b01c46c1ac5c1cd99d950d65e7064c8b8a9" + integrity sha512-GjKjpeevpePEJYinGokASNtIkl1t5EseNMlqDNAc+sXE8+iyyeqTyiJsN7bwlRG2BIremuslE/NlwdEfUuBLJw== + dependencies: + "@algolia/cache-browser-local-storage" "4.8.5" + "@algolia/cache-common" "4.8.5" + "@algolia/cache-in-memory" "4.8.5" + "@algolia/client-account" "4.8.5" + "@algolia/client-analytics" "4.8.5" + "@algolia/client-common" "4.8.5" + "@algolia/client-recommendation" "4.8.5" + "@algolia/client-search" "4.8.5" + "@algolia/logger-common" "4.8.5" + "@algolia/logger-console" "4.8.5" + "@algolia/requester-browser-xhr" "4.8.5" + "@algolia/requester-common" "4.8.5" + "@algolia/requester-node-http" "4.8.5" + "@algolia/transporter" "4.8.5" ansi-colors@^4.1.1: version "4.1.1" @@ -1658,9 +1657,9 @@ binary-extensions@^2.0.0: integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA== bl@^4.0.3: - version "4.0.3" - resolved "https://registry.yarnpkg.com/bl/-/bl-4.0.3.tgz#12d6287adc29080e22a705e5764b2a9522cdc489" - integrity sha512-fs4G6/Hu4/EE+F75J8DuN/0IpQqNjAdC7aEQv7Qt8MHGUH7Ckv2MwTEEeN9QehD0pfIDkMI1bkHYkKy7xHyKIg== + version "4.0.4" + resolved "https://registry.yarnpkg.com/bl/-/bl-4.0.4.tgz#f4fda39f81a811d0df6368c1ed91dae499d1c900" + integrity sha512-7tdr4EpSd7jJ6tuQ21vu2ke8w7pNEstzj1O8wwq6sNNzO3UDi5MA8Gny/gquCj7r2C6fHudg8tKRGyjRgmvNxQ== dependencies: buffer "^5.5.0" inherits "^2.0.4" @@ -2331,11 +2330,11 @@ cookie@0.4.0: integrity sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg== copy-anything@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/copy-anything/-/copy-anything-2.0.1.tgz#2afbce6da684bdfcbec93752fa762819cb480d9a" - integrity sha512-lA57e7viQHOdPQcrytv5jFeudZZOXuyk47lZym279FiDQ8jeZomXiGuVf6ffMKkJ+3TIai3J1J3yi6M+/4U35g== + version "2.0.3" + resolved "https://registry.yarnpkg.com/copy-anything/-/copy-anything-2.0.3.tgz#842407ba02466b0df844819bbe3baebbe5d45d87" + integrity sha512-GK6QUtisv4fNS+XcI7shX0Gx9ORg7QqIznyfho79JTnX1XhLiyZHfftvGiziqzRiEi/Bjhgpi+D2o7HxJFPnDQ== dependencies: - is-what "^3.7.1" + is-what "^3.12.0" copy-descriptor@^0.1.0: version "0.1.1" @@ -2767,9 +2766,9 @@ es-to-primitive@^1.2.1: is-symbol "^1.0.2" esbuild@^0.8.34: - version "0.8.39" - resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.8.39.tgz#18b84a3d56173c55ee8f45bc6c7b5374b0a98ecb" - integrity sha512-/do5H74a5ChyeKRWfkDh3EpICXpsz6dWTtFFbotb7BlIHvWqnRrZYDb8IBubOHdEtKzuiksilRO19aBtp3/HHQ== + version "0.8.43" + resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.8.43.tgz#19d79f8c6d1cc6dadd50942057a5aff906a1ecf2" + integrity sha512-ZVE2CpootS4jtnfV0bbtJdgRsHEXcMP0P7ZXGfTmNzzhBr2e5ag7Vp3ry0jmw8zduJz4iHzxg4m5jtPxWERz1w== escape-html@^1.0.3, escape-html@~1.0.3: version "1.0.3" @@ -2901,9 +2900,9 @@ esprima@^4.0.0, esprima@^4.0.1: integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== esquery@^1.2.0: - version "1.3.1" - resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.3.1.tgz#b78b5828aa8e214e29fb74c4d5b752e1c033da57" - integrity sha512-olpvt9QG0vniUBZspVRN6lwB7hOZoTRtT+jzR+tS4ffYx2mzbw+z0XCOk44aaLYKApNX5nMm+E+P6o25ip/DHQ== + version "1.4.0" + resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.4.0.tgz#2148ffc38b82e8c7057dfed48425b3e61f0f24a5" + integrity sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w== dependencies: estraverse "^5.1.0" @@ -3325,9 +3324,9 @@ fs.realpath@^1.0.0: integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8= fsevents@^2.1.2, fsevents@~2.3.1: - version "2.3.1" - resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.1.tgz#b209ab14c61012636c8863507edf7fb68cc54e9f" - integrity sha512-YR47Eg4hChJGAB1O3yEAOkGO+rlzutoICGqGo9EZ4lKWokzZRSyIW1QmTzqjtw8MJdj9srP869CuWw/hyzSiBw== + version "2.3.2" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a" + integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== function-bind@^1.1.1: version "1.1.1" @@ -3357,9 +3356,9 @@ get-caller-file@^2.0.1: integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== get-intrinsic@^1.0.2: - version "1.1.0" - resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.1.0.tgz#892e62931e6938c8a23ea5aaebcfb67bd97da97e" - integrity sha512-M11rgtQp5GZMZzDL7jLTNxbDfurpzuau5uqRWDPvlHjfvg3TdScAZo96GLvhMjImrmR8uAt0FS2RLoMrfWGKlg== + version "1.1.1" + resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.1.1.tgz#15f59f376f855c446963948f0d24cd3637b4abc6" + integrity sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q== dependencies: function-bind "^1.1.1" has "^1.0.3" @@ -3512,9 +3511,9 @@ good-listener@^1.2.2: delegate "^3.1.2" graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.2.0, graceful-fs@^4.2.4: - version "4.2.4" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.4.tgz#2256bde14d3632958c465ebc96dc467ca07a29fb" - integrity sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw== + version "4.2.5" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.5.tgz#bc18864a6c9fc7b303f2e2abdb9155ad178fbe29" + integrity sha512-kBBSQbz2K0Nyn+31j/w36fUfxkBW9/gfwRWdUY1ULReH3iokVJgddZAFcD1D0xlgTmFxJCbUkUclAlc6/IDJkw== gray-matter@^4.0.2: version "4.0.2" @@ -4130,7 +4129,7 @@ is-utf8@^0.2.0: resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72" integrity sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI= -is-what@^3.7.1: +is-what@^3.12.0: version "3.12.0" resolved "https://registry.yarnpkg.com/is-what/-/is-what-3.12.0.tgz#f4405ce4bd6dd420d3ced51a026fb90e03705e55" integrity sha512-2ilQz5/f/o9V7WRWJQmpFYNmQFZ9iM+OXRonZKcYgTkCzjb949Vi4h282PD1UfmgHk666rcWonbRJ++KI41VGw== @@ -4867,9 +4866,9 @@ linkify-it@^2.0.0: uc.micro "^1.0.1" lint-staged@^10.5.3: - version "10.5.3" - resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-10.5.3.tgz#c682838b3eadd4c864d1022da05daa0912fb1da5" - integrity sha512-TanwFfuqUBLufxCc3RUtFEkFraSPNR3WzWcGF39R3f2J7S9+iF9W0KTVLfSy09lYGmZS5NDCxjNvhGMSJyFCWg== + version "10.5.4" + resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-10.5.4.tgz#cd153b5f0987d2371fc1d2847a409a2fe705b665" + integrity sha512-EechC3DdFic/TdOPgj/RB3FicqE6932LTHCUm0Y2fsD9KGlLB+RwJl2q1IYBIvEsKzDOgn0D4gll+YxG5RsrKg== dependencies: chalk "^4.1.0" cli-truncate "^2.1.0" @@ -5962,9 +5961,9 @@ postcss-import@^13.0.0: resolve "^1.1.7" postcss-load-config@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/postcss-load-config/-/postcss-load-config-3.0.0.tgz#850bb066edd65b734329eacf83af0c0764226c87" - integrity sha512-lErrN8imuEF1cSiHBV8MiR7HeuzlDpCGNtaMyYHlOBuJHHOGw6S4xOMZp8BbXPr7AGQp14L6PZDlIOpfFJ6f7w== + version "3.0.1" + resolved "https://registry.yarnpkg.com/postcss-load-config/-/postcss-load-config-3.0.1.tgz#d214bf9cfec1608ffaf0f4161b3ba20664ab64b9" + integrity sha512-/pDHe30UYZUD11IeG8GWx9lNtu1ToyTsZHnyy45B4Mrwr/Kb6NgYl7k753+05CJNKnjbwh4975amoPJ+TEjHNQ== dependencies: cosmiconfig "^7.0.0" import-cwd "^3.0.0" @@ -6091,9 +6090,9 @@ postcss@^7.0.14, postcss@^7.0.32, postcss@^7.0.5, postcss@^7.0.6: supports-color "^6.1.0" postcss@^8.2.1: - version "8.2.4" - resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.2.4.tgz#20a98a39cf303d15129c2865a9ec37eda0031d04" - integrity sha512-kRFftRoExRVXZlwUuay9iC824qmXPcQQVzAjbCCgjpXnkdMCJYBu2gTwAaFBzv8ewND6O8xFb3aELmEkh9zTzg== + version "8.2.5" + resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.2.5.tgz#3c75149ada4e93db9521913654c0144517f77c9a" + integrity sha512-wMcb7BpDcm3gxQOQx46NDNT36Kk0Ao6PJLLI2ed5vehbbbxCEuslSQzbQ2sfSKy+gkYxhWcGWSeaK+gwm4KIZg== dependencies: colorette "^1.2.1" nanoid "^3.1.20" @@ -7738,9 +7737,9 @@ uc.micro@^1.0.1, uc.micro@^1.0.5: integrity sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA== uglify-js@^3.1.4: - version "3.12.6" - resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.12.6.tgz#f884584fcc42e10bca70db5cb32e8625c2c42535" - integrity sha512-aqWHe3DfQmZUDGWBbabZ2eQnJlQd1fKlMUu7gV+MiTuDzdgDw31bI3wA2jLLsV/hNcDP26IfyEgSVoft5+0SVw== + version "3.12.7" + resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.12.7.tgz#be4f06142a67bd91ef868b4e111dc241e151bff3" + integrity sha512-SIZhkoh+U/wjW+BHGhVwE9nt8tWJspncloBcFapkpGRwNPqcH8pzX36BXe3TPBjzHWPMUZotpCigak/udWNr1Q== union-value@^1.0.0: version "1.0.1" From 85f1e7bdcb9d454bd17b96ef98e2dc0cad58776b Mon Sep 17 00:00:00 2001 From: Evan You Date: Mon, 8 Feb 2021 14:14:14 -0500 Subject: [PATCH 06/48] fix(resolve): avoid race condition in resolve skip check fix #1937 --- .../vite/src/node/server/pluginContainer.ts | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/packages/vite/src/node/server/pluginContainer.ts b/packages/vite/src/node/server/pluginContainer.ts index d17450f47b3479..e40d9d59e438e9 100644 --- a/packages/vite/src/node/server/pluginContainer.ts +++ b/packages/vite/src/node/server/pluginContainer.ts @@ -403,6 +403,7 @@ export async function createPluginContainer( async resolveId(rawId, importer = join(root, 'index.html'), _skip, ssr) { const ctx = new Context() + const resolveSkips = _skip ? new ResolveSkip() : null ctx.ssr = !!ssr const key = `${rawId}\n${importer}` + @@ -418,8 +419,8 @@ export async function createPluginContainer( if (_skip) { if (_skip.includes(plugin)) continue - if (resolveSkips.has(plugin, key)) continue - resolveSkips.add(plugin, key) + if (resolveSkips!.has(plugin, key)) continue + resolveSkips!.add(plugin, key) } ctx._activePlugin = plugin @@ -435,7 +436,7 @@ export async function createPluginContainer( ssr ) } finally { - if (_skip) resolveSkips.delete(plugin, key) + if (_skip) resolveSkips!.delete(plugin, key) } if (!result) continue @@ -555,33 +556,32 @@ export async function createPluginContainer( } } - function popIndex(array: any[], index: number) { - const tail = array.pop() - if (index !== array.length) array[index] = tail - } + return container +} - // Tracks recursive resolveId calls - const resolveSkips = { - skip: new Map(), +class ResolveSkip { + skip: Map = new Map() - has(plugin: Plugin, key: string) { - const skips = this.skip.get(plugin) - return skips ? skips.includes(key) : false - }, + has(plugin: Plugin, key: string) { + const skips = this.skip.get(plugin) + return skips ? skips.includes(key) : false + } - add(plugin: Plugin, key: string) { - const skips = this.skip.get(plugin) - if (skips) skips.push(key) - else this.skip.set(plugin, [key]) - }, + add(plugin: Plugin, key: string) { + const skips = this.skip.get(plugin) + if (skips) skips.push(key) + else this.skip.set(plugin, [key]) + } - delete(plugin: Plugin, key: string) { - const skips = this.skip.get(plugin) - if (!skips) return - const i = skips.indexOf(key) - if (i !== -1) popIndex(skips, i) - } + delete(plugin: Plugin, key: string) { + const skips = this.skip.get(plugin) + if (!skips) return + const i = skips.indexOf(key) + if (i !== -1) popIndex(skips, i) } +} - return container +function popIndex(array: any[], index: number) { + const tail = array.pop() + if (index !== array.length) array[index] = tail } From f11bf11717aa2e7146a4df98605968ab844cbacc Mon Sep 17 00:00:00 2001 From: Evan You Date: Mon, 8 Feb 2021 14:19:05 -0500 Subject: [PATCH 07/48] chore: ignore postcss load config type issue --- packages/vite/src/node/plugins/css.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index 481b2a69a59114..efa47d25cd2105 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -647,6 +647,7 @@ async function resolvePostcssConfig( try { const searchPath = typeof inlineOptions === 'string' ? inlineOptions : config.root + // @ts-ignore return (cachedPostcssConfig = await postcssrc({}, searchPath)) } catch (e) { if (!/No PostCSS Config found/.test(e.message)) { From a93e61d02405728278ac905a9539450927dc7364 Mon Sep 17 00:00:00 2001 From: Evan You Date: Mon, 8 Feb 2021 14:24:05 -0500 Subject: [PATCH 08/48] fix(scan): only scan supported entry file types --- packages/vite/src/node/optimizer/scan.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/vite/src/node/optimizer/scan.ts b/packages/vite/src/node/optimizer/scan.ts index dc2e6882292f09..c478532027ef99 100644 --- a/packages/vite/src/node/optimizer/scan.ts +++ b/packages/vite/src/node/optimizer/scan.ts @@ -20,7 +20,6 @@ import { import { init, parse } from 'es-module-lexer' import MagicString from 'magic-string' import { transformImportGlob } from '../importGlob' -import { isCSSRequest } from '../plugins/css' import { ensureService } from '../plugins/esbuild' const debug = createDebugger('vite:deps') @@ -57,9 +56,9 @@ export async function scanImports( entries = await globEntries('**/*.html', config) } - // CSS/Asset entrypoints should not be scanned for dependencies. + // Non-supported entry file types should not be scanned for dependencies. entries = entries.filter( - (entry) => !(isCSSRequest(entry) || config.assetsInclude(entry)) + (entry) => JS_TYPES_RE.test(entry) || htmlTypesRE.test(entry) ) if (!entries.length) { From 9066f27c591b356107239e9cef36c1cad73864c0 Mon Sep 17 00:00:00 2001 From: Evan You Date: Mon, 8 Feb 2021 15:14:00 -0500 Subject: [PATCH 09/48] fix(resolve): pass down resolve skip via context fix #1937 --- .../vite/src/node/server/pluginContainer.ts | 83 +++++-------------- 1 file changed, 19 insertions(+), 64 deletions(-) diff --git a/packages/vite/src/node/server/pluginContainer.ts b/packages/vite/src/node/server/pluginContainer.ts index e40d9d59e438e9..f19ba3193f92bc 100644 --- a/packages/vite/src/node/server/pluginContainer.ts +++ b/packages/vite/src/node/server/pluginContainer.ts @@ -83,7 +83,7 @@ export interface PluginContainer { resolveId( id: string, importer?: string, - skip?: Plugin[], + skip?: Set, ssr?: boolean ): Promise transform( @@ -166,6 +166,7 @@ export async function createPluginContainer( _activePlugin: Plugin | null _activeId: string | null = null _activeCode: string | null = null + _resolveSkips?: Set constructor(initialPlugin?: Plugin) { this._activePlugin = initialPlugin || null @@ -185,9 +186,12 @@ export async function createPluginContainer( importer?: string, options?: { skipSelf?: boolean } ) { - const skip = [] - if (options?.skipSelf && this._activePlugin) skip.push(this._activePlugin) - let out = await container.resolveId(id, importer, skip, this.ssr) + let skips: Set | undefined + if (options?.skipSelf && this._activePlugin) { + skips = new Set(this._resolveSkips) + skips.add(this._activePlugin) + } + let out = await container.resolveId(id, importer, skips, this.ssr) if (typeof out === 'string') out = { id: out } return out as ResolvedId | null } @@ -361,7 +365,6 @@ export async function createPluginContainer( } } - let nestedResolveCall = 0 let closed = false const container: PluginContainer = { @@ -401,43 +404,28 @@ export async function createPluginContainer( ) }, - async resolveId(rawId, importer = join(root, 'index.html'), _skip, ssr) { + async resolveId(rawId, importer = join(root, 'index.html'), skips, ssr) { const ctx = new Context() - const resolveSkips = _skip ? new ResolveSkip() : null ctx.ssr = !!ssr - const key = - `${rawId}\n${importer}` + - (_skip ? _skip.map((p) => p.name).join('\n') : ``) - - nestedResolveCall++ + ctx._resolveSkips = skips const resolveStart = isDebug ? Date.now() : 0 let id: string | null = null const partial: Partial = {} for (const plugin of plugins) { if (!plugin.resolveId) continue - - if (_skip) { - if (_skip.includes(plugin)) continue - if (resolveSkips!.has(plugin, key)) continue - resolveSkips!.add(plugin, key) - } + if (skips?.has(plugin)) continue ctx._activePlugin = plugin - let result const pluginResolveStart = isDebug ? Date.now() : 0 - try { - result = await plugin.resolveId.call( - ctx as any, - rawId, - importer, - {}, - ssr - ) - } finally { - if (_skip) resolveSkips!.delete(plugin, key) - } + const result = await plugin.resolveId.call( + ctx as any, + rawId, + importer, + {}, + ssr + ) if (!result) continue if (typeof result === 'string') { @@ -458,13 +446,7 @@ export async function createPluginContainer( break } - nestedResolveCall-- - if ( - isDebug && - !nestedResolveCall && - rawId !== id && - !rawId.startsWith('/@fs/') - ) { + if (isDebug && rawId !== id && !rawId.startsWith('/@fs/')) { const key = rawId + id // avoid spamming if (!seenResolves[key]) { @@ -558,30 +540,3 @@ export async function createPluginContainer( return container } - -class ResolveSkip { - skip: Map = new Map() - - has(plugin: Plugin, key: string) { - const skips = this.skip.get(plugin) - return skips ? skips.includes(key) : false - } - - add(plugin: Plugin, key: string) { - const skips = this.skip.get(plugin) - if (skips) skips.push(key) - else this.skip.set(plugin, [key]) - } - - delete(plugin: Plugin, key: string) { - const skips = this.skip.get(plugin) - if (!skips) return - const i = skips.indexOf(key) - if (i !== -1) popIndex(skips, i) - } -} - -function popIndex(array: any[], index: number) { - const tail = array.pop() - if (index !== array.length) array[index] = tail -} From 30e92a150e060e8bedcb6f0c477dcaa87e7996d6 Mon Sep 17 00:00:00 2001 From: Evan You Date: Mon, 8 Feb 2021 15:44:39 -0500 Subject: [PATCH 10/48] fix(plugin-vue-jsx): support ssr close #1939 --- packages/playground/ssr-vue/__tests__/ssr-vue.spec.ts | 4 ++++ packages/playground/ssr-vue/src/components/Foo.jsx | 9 +++++++++ packages/playground/ssr-vue/src/pages/Home.vue | 4 +++- packages/playground/ssr-vue/vite.config.js | 3 ++- packages/plugin-vue-jsx/index.js | 6 +++--- 5 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 packages/playground/ssr-vue/src/components/Foo.jsx diff --git a/packages/playground/ssr-vue/__tests__/ssr-vue.spec.ts b/packages/playground/ssr-vue/__tests__/ssr-vue.spec.ts index d4a0167c0ee83e..f4a490582f2cd1 100644 --- a/packages/playground/ssr-vue/__tests__/ssr-vue.spec.ts +++ b/packages/playground/ssr-vue/__tests__/ssr-vue.spec.ts @@ -80,6 +80,10 @@ test('asset', async () => { ) }) +test('jsx', async () => { + expect(await page.textContent('.jsx')).toMatch('from JSX') +}) + test('hydration', async () => { expect(await page.textContent('button')).toMatch('0') await page.click('button') diff --git a/packages/playground/ssr-vue/src/components/Foo.jsx b/packages/playground/ssr-vue/src/components/Foo.jsx new file mode 100644 index 00000000000000..d810b40886c596 --- /dev/null +++ b/packages/playground/ssr-vue/src/components/Foo.jsx @@ -0,0 +1,9 @@ +import { defineComponent } from 'vue' + +// named exports w/ variable declaration: ok +export const Foo = defineComponent({ + name: 'foo', + setup() { + return () =>
from JSX
+ } +}) \ No newline at end of file diff --git a/packages/playground/ssr-vue/src/pages/Home.vue b/packages/playground/ssr-vue/src/pages/Home.vue index f1b3c4742b721a..bec719062d6805 100644 --- a/packages/playground/ssr-vue/src/pages/Home.vue +++ b/packages/playground/ssr-vue/src/pages/Home.vue @@ -1,13 +1,15 @@ diff --git a/packages/playground/ssr-vue/vite.config.js b/packages/playground/ssr-vue/vite.config.js index d20f4dd734e760..3c3ba42947a538 100644 --- a/packages/playground/ssr-vue/vite.config.js +++ b/packages/playground/ssr-vue/vite.config.js @@ -1,10 +1,11 @@ const vuePlugin = require('@vitejs/plugin-vue') +const vueJsx = require('@vitejs/plugin-vue-jsx') /** * @type {import('vite').UserConfig} */ module.exports = { - plugins: [vuePlugin()], + plugins: [vuePlugin(), vueJsx()], build: { minify: false } diff --git a/packages/plugin-vue-jsx/index.js b/packages/plugin-vue-jsx/index.js index 86d27be65008b2..cdacfe1ae542d2 100644 --- a/packages/plugin-vue-jsx/index.js +++ b/packages/plugin-vue-jsx/index.js @@ -5,7 +5,7 @@ const importMeta = require('@babel/plugin-syntax-import-meta') const hash = require('hash-sum') /** - * @param {import('.').Options} options + * @param {import('@vue/babel-plugin-jsx').VueJSXPluginOptions} options * @returns {import('vite').Plugin} */ function vueJsxPlugin(options = {}) { @@ -35,7 +35,7 @@ function vueJsxPlugin(options = {}) { needSourceMap = config.command === 'serve' || !!config.build.sourcemap }, - transform(code, id) { + transform(code, id, ssr) { if (/\.[jt]sx$/.test(id)) { const plugins = [importMeta, [jsx, options]] if (id.endsWith('.tsx')) { @@ -53,7 +53,7 @@ function vueJsxPlugin(options = {}) { sourceFileName: id }) - if (!needHmr) { + if (ssr || !needHmr) { return { code: result.code, map: result.map From bec94e1baeddfafc08f5980ef6bf274216806370 Mon Sep 17 00:00:00 2001 From: Evan You Date: Mon, 8 Feb 2021 15:46:35 -0500 Subject: [PATCH 11/48] release: plugin-vue-jsx@1.0.3 --- packages/plugin-vue-jsx/CHANGELOG.md | 9 +++++++++ packages/plugin-vue-jsx/package.json | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/plugin-vue-jsx/CHANGELOG.md b/packages/plugin-vue-jsx/CHANGELOG.md index f8824dd2e240a9..6eed1d6ea6067d 100644 --- a/packages/plugin-vue-jsx/CHANGELOG.md +++ b/packages/plugin-vue-jsx/CHANGELOG.md @@ -1,3 +1,12 @@ +## [1.0.3](https://github.com/vitejs/vite/compare/plugin-vue-jsx@1.0.2...plugin-vue-jsx@1.0.3) (2021-02-08) + + +### Bug Fixes + +* **plugin-vue-jsx:** support ssr ([30e92a1](https://github.com/vitejs/vite/commit/30e92a150e060e8bedcb6f0c477dcaa87e7996d6)), closes [#1939](https://github.com/vitejs/vite/issues/1939) + + + ## [1.0.2](https://github.com/vitejs/vite/compare/plugin-vue-jsx@1.0.1...plugin-vue-jsx@1.0.2) (2021-01-12) diff --git a/packages/plugin-vue-jsx/package.json b/packages/plugin-vue-jsx/package.json index a7a90fef1009a7..b2597a6257ef69 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.0.2", + "version": "1.0.3", "license": "MIT", "author": "Evan You", "files": [ From c7fef5118d4c6896f53298c298dd7a22d3c3c20f Mon Sep 17 00:00:00 2001 From: Evan You Date: Mon, 8 Feb 2021 16:00:04 -0500 Subject: [PATCH 12/48] release: v2.0.0-beta.66 --- packages/vite/CHANGELOG.md | 15 +++++++++++++++ packages/vite/package.json | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/vite/CHANGELOG.md b/packages/vite/CHANGELOG.md index edf28135fa2190..73087b82b98cea 100644 --- a/packages/vite/CHANGELOG.md +++ b/packages/vite/CHANGELOG.md @@ -1,3 +1,18 @@ +# [2.0.0-beta.66](https://github.com/vitejs/vite/compare/v2.0.0-beta.65...v2.0.0-beta.66) (2021-02-08) + + +### Bug Fixes + +* **import-analysis:** fix literal dynamic id false positive ([6a6508e](https://github.com/vitejs/vite/commit/6a6508edb9b31a4ea8bbc54b841f5227ba2b562a)), closes [#1902](https://github.com/vitejs/vite/issues/1902) +* **resolve:** avoid race condition in resolve skip check ([85f1e7b](https://github.com/vitejs/vite/commit/85f1e7bdcb9d454bd17b96ef98e2dc0cad58776b)), closes [#1937](https://github.com/vitejs/vite/issues/1937) +* **resolve:** pass down resolve skip via context ([9066f27](https://github.com/vitejs/vite/commit/9066f27c591b356107239e9cef36c1cad73864c0)), closes [#1937](https://github.com/vitejs/vite/issues/1937) +* **scan:** only scan supported entry file types ([a93e61d](https://github.com/vitejs/vite/commit/a93e61d02405728278ac905a9539450927dc7364)) +* use dedicated endpoint for hmr reconnect ping ([b433607](https://github.com/vitejs/vite/commit/b433607aca0986c6e1592c3f64adb2ef30689c5e)), closes [#1904](https://github.com/vitejs/vite/issues/1904) +* **ssr:** ssr external should take scannd imports into account ([92934d4](https://github.com/vitejs/vite/commit/92934d4c18329cc51879aca5016a408b467c1fa0)), closes [#1916](https://github.com/vitejs/vite/issues/1916) +* brotli skipped is printed when build.brotliSize is false ([#1912](https://github.com/vitejs/vite/issues/1912)) ([db3c324](https://github.com/vitejs/vite/commit/db3c324134db2bf371700cc4d838a49ac6148045)) + + + # [2.0.0-beta.65](https://github.com/vitejs/vite/compare/v2.0.0-beta.64...v2.0.0-beta.65) (2021-02-05) diff --git a/packages/vite/package.json b/packages/vite/package.json index e3a8fc661b1a39..73e60b7db39faa 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -1,6 +1,6 @@ { "name": "vite", - "version": "2.0.0-beta.65", + "version": "2.0.0-beta.66", "license": "MIT", "author": "Evan You", "description": "Native-ESM powered web dev build tool", From 8a1c602b29413b297c811577a9f6690bef88e01c Mon Sep 17 00:00:00 2001 From: Sunil Pai Date: Mon, 8 Feb 2021 21:26:43 +0000 Subject: [PATCH 13/48] fix(create-app): Adds a newline before "Scaffolding project in..." (#1945) --- packages/create-app/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/create-app/index.js b/packages/create-app/index.js index 20476ca51d5755..964d5c18b0654e 100755 --- a/packages/create-app/index.js +++ b/packages/create-app/index.js @@ -48,7 +48,7 @@ async function init() { } const root = path.join(cwd, targetDir) - console.log(`Scaffolding project in ${root}...`) + console.log(`\nScaffolding project in ${root}...`) if (!fs.existsSync(root)) { fs.mkdirSync(root, { recursive: true }) From 0f692ce05838726a896b06f97d73226334589c9b Mon Sep 17 00:00:00 2001 From: Caleb Eby Date: Mon, 8 Feb 2021 19:09:57 -0800 Subject: [PATCH 14/48] docs: fix typo in config docs @type (#1947) --- 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 87a2a30be12c56..2c9c28466051dc 100644 --- a/docs/config/index.md +++ b/docs/config/index.md @@ -29,7 +29,7 @@ Since Vite ships with TypeScript typings, you can leverage your IDE's intellisen ```js /** - * type {import('vite').UserConfig} + * @type {import('vite').UserConfig} */ export default { // ... From 9af1517e47f66bb793447d998cf1a4d2fa3ef758 Mon Sep 17 00:00:00 2001 From: CHOYSEN Date: Tue, 9 Feb 2021 22:10:25 +0800 Subject: [PATCH 15/48] fix: do not open browser when restarting server (#1952) --- packages/vite/src/node/server/hmr.ts | 2 +- packages/vite/src/node/server/index.ts | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/vite/src/node/server/hmr.ts b/packages/vite/src/node/server/hmr.ts index f5ffa9a9fdc82e..5ba27c3c8b68dd 100644 --- a/packages/vite/src/node/server/hmr.ts +++ b/packages/vite/src/node/server/hmr.ts @@ -421,7 +421,7 @@ async function restartServer(server: ViteDevServer) { } } if (!server.config.server.middlewareMode) { - await server.listen() + await server.listen(undefined, true) } else { server.config.logger.info('server restarted.', { timestamp: true }) } diff --git a/packages/vite/src/node/server/index.ts b/packages/vite/src/node/server/index.ts index b2e2d5709e52ca..61d08eac01a58f 100644 --- a/packages/vite/src/node/server/index.ts +++ b/packages/vite/src/node/server/index.ts @@ -220,7 +220,7 @@ export interface ViteDevServer { /** * Start the server. */ - listen(port?: number): Promise + listen(port?: number, isRestart?: boolean): Promise /** * Stop the server. */ @@ -321,8 +321,8 @@ export async function createServer( e.stack = ssrRewriteStacktrace(e.stack, moduleGraph) } }, - listen(port?: number) { - return startServer(server, port) + listen(port?: number, isRestart?: boolean) { + return startServer(server, port, isRestart) }, async close() { await Promise.all([ @@ -510,7 +510,8 @@ export async function createServer( async function startServer( server: ViteDevServer, - inlinePort?: number + inlinePort?: number, + isRestart: boolean = false ): Promise { const httpServer = server.httpServer if (!httpServer) { @@ -595,7 +596,7 @@ async function startServer( }) } - if (options.open) { + if (options.open && !isRestart) { const path = typeof options.open === 'string' ? options.open : base openBrowser( `${protocol}://${hostname}:${port}${path}`, From fa2d7d66c16c2156354b6888a2f0bd4b47262ca2 Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 9 Feb 2021 09:54:19 -0500 Subject: [PATCH 16/48] fix(ssr): fix ssr node require for virtual modules --- packages/vite/src/node/ssr/ssrModuleLoader.ts | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/packages/vite/src/node/ssr/ssrModuleLoader.ts b/packages/vite/src/node/ssr/ssrModuleLoader.ts index 40013e6bd133cc..98cd0d237c7f38 100644 --- a/packages/vite/src/node/ssr/ssrModuleLoader.ts +++ b/packages/vite/src/node/ssr/ssrModuleLoader.ts @@ -1,6 +1,7 @@ +import fs from 'fs' import path from 'path' import { ViteDevServer } from '..' -import { resolveFrom } from '../utils' +import { cleanUrl, resolveFrom } from '../utils' import { ssrRewriteStacktrace } from './ssrStacktrace' import { ssrExportAllKey, @@ -69,7 +70,7 @@ export async function ssrLoadModule( const ssrImport = (dep: string) => { if (isExternal(dep)) { - return nodeRequire(dep, mod.file) + return nodeRequire(dep, mod.file, server.config.root) } else { return moduleGraph.urlToModuleMap.get(dep)?.ssrModule } @@ -77,7 +78,7 @@ export async function ssrLoadModule( const ssrDynamicImport = (dep: string) => { if (isExternal(dep)) { - return Promise.resolve(nodeRequire(dep, mod.file)) + return Promise.resolve(nodeRequire(dep, mod.file, server.config.root)) } else { return ssrLoadModule(dep, server, isolated, context, urlStack.concat(url)) } @@ -127,8 +128,8 @@ export async function ssrLoadModule( return ssrModule } -function nodeRequire(id: string, importer: string | null) { - const mod = importer ? require(resolve(id, importer)) : require(id) +function nodeRequire(id: string, importer: string | null, root: string) { + const mod = require(resolve(id, importer, root)) const defaultExport = mod.__esModule ? mod.default : mod // rollup-style default import interop for cjs return new Proxy(mod, { @@ -141,14 +142,17 @@ function nodeRequire(id: string, importer: string | null) { const resolveCache = new Map() -function resolve(id: string, importer: string) { - const dir = path.dirname(importer) - const key = id + dir +function resolve(id: string, importer: string | null, root: string) { + const key = id + importer + root const cached = resolveCache.get(key) if (cached) { return cached } - const resolved = resolveFrom(id, dir, true) + const resolveDir = + importer && fs.existsSync(cleanUrl(importer)) + ? path.dirname(importer) + : root + const resolved = resolveFrom(id, resolveDir, true) resolveCache.set(key, resolved) return resolved } From 7a6aa2ad2689bf8221389924a608876866db7b0a Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 9 Feb 2021 09:56:13 -0500 Subject: [PATCH 17/48] feat(plugin-vue-jsx): register jsx module during ssr --- .../ssr-vue/__tests__/ssr-vue.spec.ts | 9 ++ .../playground/ssr-vue/src/components/Foo.jsx | 1 + .../playground/ssr-vue/src/components/foo.css | 3 + .../playground/ssr-vue/src/pages/Home.vue | 6 +- packages/plugin-vue-jsx/index.js | 87 ++++++++++++++----- 5 files changed, 83 insertions(+), 23 deletions(-) create mode 100644 packages/playground/ssr-vue/src/components/foo.css diff --git a/packages/playground/ssr-vue/__tests__/ssr-vue.spec.ts b/packages/playground/ssr-vue/__tests__/ssr-vue.spec.ts index f4a490582f2cd1..24223b96c4967d 100644 --- a/packages/playground/ssr-vue/__tests__/ssr-vue.spec.ts +++ b/packages/playground/ssr-vue/__tests__/ssr-vue.spec.ts @@ -50,6 +50,13 @@ test('/', async () => { expect(html).toMatch( /link rel="stylesheet".*?href="\/assets\/Home\.\w{8}\.css"/ ) + // JSX component preload registration + expect(html).toMatch( + /link rel="modulepreload".*?href="\/assets\/Foo\.\w{8}\.js"/ + ) + expect(html).toMatch( + /link rel="stylesheet".*?href="\/assets\/Foo\.\w{8}\.css"/ + ) expect(html).not.toMatch( /link rel="modulepreload".*?href="\/assets\/About\.\w{8}\.js"/ ) @@ -62,10 +69,12 @@ test('/', async () => { test('css', async () => { if (isBuild) { expect(await getColor('h1')).toBe('green') + expect(await getColor('.jsx')).toBe('blue') } else { // During dev, the CSS is loaded from async chunk and we may have to wait // when the test runs concurrently. await untilUpdated(() => getColor('h1'), 'green') + await untilUpdated(() => getColor('.jsx'), 'blue') } }) diff --git a/packages/playground/ssr-vue/src/components/Foo.jsx b/packages/playground/ssr-vue/src/components/Foo.jsx index d810b40886c596..c1670c6a13758f 100644 --- a/packages/playground/ssr-vue/src/components/Foo.jsx +++ b/packages/playground/ssr-vue/src/components/Foo.jsx @@ -1,4 +1,5 @@ import { defineComponent } from 'vue' +import './foo.css' // named exports w/ variable declaration: ok export const Foo = defineComponent({ diff --git a/packages/playground/ssr-vue/src/components/foo.css b/packages/playground/ssr-vue/src/components/foo.css new file mode 100644 index 00000000000000..bfaacd33a2f805 --- /dev/null +++ b/packages/playground/ssr-vue/src/components/foo.css @@ -0,0 +1,3 @@ +.jsx { + color: blue; +} \ No newline at end of file diff --git a/packages/playground/ssr-vue/src/pages/Home.vue b/packages/playground/ssr-vue/src/pages/Home.vue index bec719062d6805..29e93f3e3cde16 100644 --- a/packages/playground/ssr-vue/src/pages/Home.vue +++ b/packages/playground/ssr-vue/src/pages/Home.vue @@ -4,12 +4,12 @@ logo

- + diff --git a/packages/plugin-vue-jsx/index.js b/packages/plugin-vue-jsx/index.js index cdacfe1ae542d2..5a3479a91e5295 100644 --- a/packages/plugin-vue-jsx/index.js +++ b/packages/plugin-vue-jsx/index.js @@ -4,6 +4,29 @@ const jsx = require('@vue/babel-plugin-jsx') const importMeta = require('@babel/plugin-syntax-import-meta') const hash = require('hash-sum') +const ssrRegisterHelperId = '/__vue-jsx-ssr-register-helper' +const ssrRegisterHelperCode = + `import { useSSRContext } from "vue"\n` + + `export ${ssrRegisterHelper.toString()}` + +/** + * This function is serialized with toString() and evaluated as a virtual + * module during SSR + * @param {import('vue').ComponentOptions} comp + * @param {string} filename + */ +function ssrRegisterHelper(comp, filename) { + const setup = comp.setup + comp.setup = (props, ctx) => { + // @ts-ignore + const ssrContext = useSSRContext() + ;(ssrContext.modules || (ssrContext.modules = new Set())).add(filename) + if (setup) { + return setup(props, ctx) + } + } +} + /** * @param {import('@vue/babel-plugin-jsx').VueJSXPluginOptions} options * @returns {import('vite').Plugin} @@ -35,6 +58,18 @@ function vueJsxPlugin(options = {}) { needSourceMap = config.command === 'serve' || !!config.build.sourcemap }, + resolveId(id) { + if (id === ssrRegisterHelperId) { + return id + } + }, + + load(id) { + if (id === ssrRegisterHelperId) { + return ssrRegisterHelperCode + } + }, + transform(code, id, ssr) { if (/\.[jt]sx$/.test(id)) { const plugins = [importMeta, [jsx, options]] @@ -53,7 +88,7 @@ function vueJsxPlugin(options = {}) { sourceFileName: id }) - if (ssr || !needHmr) { + if (!ssr && !needHmr) { return { code: result.code, map: result.map @@ -143,28 +178,40 @@ function vueJsxPlugin(options = {}) { } if (hotComponents.length) { - let code = result.code - if (hasDefault) { - code = - code.replace( - /export default defineComponent/g, - `const __default__ = defineComponent` - ) + `\nexport default __default__` - } + if (needHmr && !ssr) { + let code = result.code + if (hasDefault) { + code = + code.replace( + /export default defineComponent/g, + `const __default__ = defineComponent` + ) + `\nexport default __default__` + } - let callbackCode = `` - for (const { local, exported, id } of hotComponents) { - code += - `\n${local}.__hmrId = "${id}"` + - `\n__VUE_HMR_RUNTIME__.createRecord("${id}", ${local})` - callbackCode += `\n__VUE_HMR_RUNTIME__.reload("${id}", __${exported})` - } + let callbackCode = `` + for (const { local, exported, id } of hotComponents) { + code += + `\n${local}.__hmrId = "${id}"` + + `\n__VUE_HMR_RUNTIME__.createRecord("${id}", ${local})` + callbackCode += `\n__VUE_HMR_RUNTIME__.reload("${id}", __${exported})` + } + + code += `\nimport.meta.hot.accept(({${hotComponents + .map((c) => `${c.exported}: __${c.exported}`) + .join(',')}}) => {${callbackCode}\n})` - code += `\nimport.meta.hot.accept(({${hotComponents - .map((c) => `${c.exported}: __${c.exported}`) - .join(',')}}) => {${callbackCode}\n})` + result.code = code + } - result.code = code + if (ssr) { + let ssrInjectCode = + `\nimport { ssrRegisterHelper } from "${ssrRegisterHelperId}"` + + `\nconst __moduleId = ${JSON.stringify(id)}` + for (const { local } of hotComponents) { + ssrInjectCode += `\nssrRegisterHelper(${local}, __moduleId)` + } + result.code += ssrInjectCode + } } return { From 6d3ff0cf4c1ae4ed8b3f90476748b2a5dbc5665d Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 9 Feb 2021 10:09:57 -0500 Subject: [PATCH 18/48] release: plugin-vue-jsx@1.1.0 --- packages/plugin-vue-jsx/CHANGELOG.md | 9 +++++++++ packages/plugin-vue-jsx/package.json | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/plugin-vue-jsx/CHANGELOG.md b/packages/plugin-vue-jsx/CHANGELOG.md index 6eed1d6ea6067d..1ef5098579a46c 100644 --- a/packages/plugin-vue-jsx/CHANGELOG.md +++ b/packages/plugin-vue-jsx/CHANGELOG.md @@ -1,3 +1,12 @@ +# [1.1.0](https://github.com/vitejs/vite/compare/plugin-vue-jsx@1.0.3...plugin-vue-jsx@1.1.0) (2021-02-09) + + +### Features + +* **plugin-vue-jsx:** register jsx module during ssr ([7a6aa2a](https://github.com/vitejs/vite/commit/7a6aa2ad2689bf8221389924a608876866db7b0a)) + + + ## [1.0.3](https://github.com/vitejs/vite/compare/plugin-vue-jsx@1.0.2...plugin-vue-jsx@1.0.3) (2021-02-08) diff --git a/packages/plugin-vue-jsx/package.json b/packages/plugin-vue-jsx/package.json index b2597a6257ef69..74d31d0df91fda 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.0.3", + "version": "1.1.0", "license": "MIT", "author": "Evan You", "files": [ From ad1024c15b55cc15c78d76202517a3ee29570607 Mon Sep 17 00:00:00 2001 From: CHOYSEN Date: Wed, 10 Feb 2021 00:17:26 +0800 Subject: [PATCH 19/48] docs: sync with code(api-javascript.md) (#1959) --- docs/guide/api-javascript.md | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/docs/guide/api-javascript.md b/docs/guide/api-javascript.md index 2e2406e3296f5d..5673da95c7859f 100644 --- a/docs/guide/api-javascript.md +++ b/docs/guide/api-javascript.md @@ -32,7 +32,6 @@ const { createServer } = require('vite') The `InlineConfig` interface extends `UserConfig` with additional properties: -- `mode`: override default mode (`'development'` for server) - `configFile`: specify config file to use. If not set, Vite will try to automatically resolve one from project root. Set to `false` to disable auto resolving. ## `ViteDevServer` @@ -44,15 +43,19 @@ interface ViteDevServer { */ config: ResolvedConfig /** - * connect app instance - * This can also be used as the handler function of a custom http server + * A connect app instance + * - Can be used to attach custom middlewares to the dev server. + * - Can also be used as the handler function of a custom http server + * or as a middleware in any connect-style Node.js frameworks + * * https://github.com/senchalabs/connect#use-middleware */ - app: Connect.Server + middlewares: Connect.Server /** * native Node http server instance + * will be null in middleware mode */ - httpServer: http.Server + httpServer: http.Server | null /** * chokidar watcher instance * https://github.com/paulmillr/chokidar#api @@ -75,7 +78,10 @@ interface ViteDevServer { * Programmatically resolve, load and transform a URL and get the result * without going through the http request pipeline. */ - transformRequest(url: string): Promise + transformRequest( + url: string, + options?: TransformOptions + ): Promise /** * Apply vite built-in HTML transforms and any plugin HTML transforms. */ @@ -104,7 +110,7 @@ interface ViteDevServer { /** * Start the server. */ - listen(port?: number): Promise + listen(port?: number, isRestart?: boolean): Promise /** * Stop the server. */ @@ -148,6 +154,7 @@ const { build } = require('vite') ```ts async function resolveConfig( inlineConfig: InlineConfig, - command: 'build' | 'serve' + command: 'build' | 'serve', + defaultMode?: string ): Promise ``` From 49f62247f57a4d605d449a4e6af4e33d106d3b74 Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 9 Feb 2021 11:30:17 -0500 Subject: [PATCH 20/48] refactor: more explicit index exports avoid accidentally exporting unwanted methods or types --- packages/vite/src/node/index.ts | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/packages/vite/src/node/index.ts b/packages/vite/src/node/index.ts index cf00ed4d817018..6597b1dccb5e54 100644 --- a/packages/vite/src/node/index.ts +++ b/packages/vite/src/node/index.ts @@ -1,13 +1,30 @@ -export * from './server' -export * from './build' -export * from './optimizer' export * from './config' +export { createServer } from './server' +export { build } from './build' +export { optimizeDeps } from './optimizer' export { send } from './server/send' export { createLogger } from './logger' export { resolvePackageData, resolvePackageEntry } from './plugins/resolve' export { normalizePath } from './utils' // additional types +export type { + ViteDevServer, + ServerOptions, + CorsOptions, + CorsOrigin, + ServerHook +} from './server' +export type { + BuildOptions, + LibraryOptions, + LibraryFormats, + ResolvedBuildOptions +} from './build' +export type { + DepOptimizationMetadata, + DepOptimizationOptions +} from './optimizer' export type { Plugin } from './plugin' export type { Logger, LogOptions, LogLevel, LogType } from './logger' export type { From 6e7159675c55f46bcc030f9c6fd35dee9a92cfca Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 9 Feb 2021 12:02:23 -0500 Subject: [PATCH 21/48] fix(html): avoid duplicate preload link injection fix #1957 --- packages/vite/src/node/plugins/html.ts | 32 ++++++++++++++++---------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/packages/vite/src/node/plugins/html.ts b/packages/vite/src/node/plugins/html.ts index 592805ce38a05a..8ae5e2127bad0a 100644 --- a/packages/vite/src/node/plugins/html.ts +++ b/packages/vite/src/node/plugins/html.ts @@ -253,12 +253,14 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin { async generateBundle(_, bundle) { const getPreloadLinksForChunk = ( - chunk: OutputChunk + chunk: OutputChunk, + seen: Set = new Set() ): HtmlTagDescriptor[] => { const tags: HtmlTagDescriptor[] = [] chunk.imports.forEach((file) => { const importee = bundle[file] - if (importee && importee.type === 'chunk') { + if (importee && importee.type === 'chunk' && !seen.has(file)) { + seen.add(file) tags.push({ tag: 'link', attrs: { @@ -266,30 +268,36 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin { href: toPublicPath(file, config) } }) - tags.push(...getPreloadLinksForChunk(importee)) + tags.push(...getPreloadLinksForChunk(importee, seen)) } }) return tags } - const getCssTagsForChunk = (chunk: OutputChunk): HtmlTagDescriptor[] => { + const getCssTagsForChunk = ( + chunk: OutputChunk, + seen: Set = new Set() + ): HtmlTagDescriptor[] => { const tags: HtmlTagDescriptor[] = [] const cssFiles = chunkToEmittedCssFileMap.get(chunk) if (cssFiles) { cssFiles.forEach((file) => { - tags.push({ - tag: 'link', - attrs: { - rel: 'stylesheet', - href: toPublicPath(file, config) - } - }) + if (!seen.has(file)) { + seen.add(file) + tags.push({ + tag: 'link', + attrs: { + rel: 'stylesheet', + href: toPublicPath(file, config) + } + }) + } }) } chunk.imports.forEach((file) => { const importee = bundle[file] if (importee && importee.type === 'chunk') { - tags.push(...getCssTagsForChunk(importee)) + tags.push(...getCssTagsForChunk(importee, seen)) } }) return tags From ddc6d51cf6e5310cbe7e93e3010631f6c2112b64 Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 9 Feb 2021 12:13:24 -0500 Subject: [PATCH 22/48] release: v2.0.0-beta.67 --- packages/vite/CHANGELOG.md | 11 +++++++++++ packages/vite/LICENSE.md | 2 +- packages/vite/package.json | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/vite/CHANGELOG.md b/packages/vite/CHANGELOG.md index 73087b82b98cea..556eeb25651611 100644 --- a/packages/vite/CHANGELOG.md +++ b/packages/vite/CHANGELOG.md @@ -1,3 +1,14 @@ +# [2.0.0-beta.67](https://github.com/vitejs/vite/compare/v2.0.0-beta.66...v2.0.0-beta.67) (2021-02-09) + + +### Bug Fixes + +* **html:** avoid duplicate preload link injection ([6e71596](https://github.com/vitejs/vite/commit/6e7159675c55f46bcc030f9c6fd35dee9a92cfca)), closes [#1957](https://github.com/vitejs/vite/issues/1957) +* **ssr:** fix ssr node require for virtual modules ([fa2d7d6](https://github.com/vitejs/vite/commit/fa2d7d66c16c2156354b6888a2f0bd4b47262ca2)) +* do not open browser when restarting server ([#1952](https://github.com/vitejs/vite/issues/1952)) ([9af1517](https://github.com/vitejs/vite/commit/9af1517e47f66bb793447d998cf1a4d2fa3ef758)) + + + # [2.0.0-beta.66](https://github.com/vitejs/vite/compare/v2.0.0-beta.65...v2.0.0-beta.66) (2021-02-08) diff --git a/packages/vite/LICENSE.md b/packages/vite/LICENSE.md index 54cfaabc00a787..96804f745abbf5 100644 --- a/packages/vite/LICENSE.md +++ b/packages/vite/LICENSE.md @@ -1243,7 +1243,7 @@ Repository: https://github.com/mathiasbynens/cssesc.git ## debug License: MIT -By: TJ Holowaychuk, Nathan Rajlich, Andrew Rhyne +By: TJ Holowaychuk, Nathan Rajlich, Andrew Rhyne, Josh Junon Repository: git://github.com/visionmedia/debug.git > (The MIT License) diff --git a/packages/vite/package.json b/packages/vite/package.json index 73e60b7db39faa..5fce05f414ba2a 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -1,6 +1,6 @@ { "name": "vite", - "version": "2.0.0-beta.66", + "version": "2.0.0-beta.67", "license": "MIT", "author": "Evan You", "description": "Native-ESM powered web dev build tool", From 1953807c35fc19f2ebdc53181081344d4c777fff Mon Sep 17 00:00:00 2001 From: GaryNg Date: Wed, 10 Feb 2021 03:22:28 +0800 Subject: [PATCH 23/48] docs: fix minor typo (#1961) --- docs/guide/introduction.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guide/introduction.md b/docs/guide/introduction.md index f91128234fd307..44adb2c07df3f6 100644 --- a/docs/guide/introduction.md +++ b/docs/guide/introduction.md @@ -30,7 +30,7 @@ Vite improves the dev server start time by first dividing the modules in an appl Vite [pre-bundles dependencies](./dep-pre-bundling) using [esbuild](https://esbuild.github.io/). Esbuild is written in Go and pre-bundles dependencies 10-100x faster than JavaScript-based bundlers. -- **Source code** often contains non-plain JavaScript that needs transforming (e.g. JSX, CSS or Vue/Svelete components), and will be edited very often. Also, not all source code needs to be loaded at the same time (e.g. with route-based code-splitting). +- **Source code** often contains non-plain JavaScript that needs transforming (e.g. JSX, CSS or Vue/Svelte components), and will be edited very often. Also, not all source code needs to be loaded at the same time (e.g. with route-based code-splitting). Vite serves source code over [native ESM](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules). This is essentially letting the browser taking over part of the job of a bundler: Vite only needs to transform and serve source code on demand, as the browser requests them. Code behind conditional dynamic imports are only processed if actually used on the current screen. From 03b323d39cafe2baabef74e6051a9640add82590 Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 9 Feb 2021 15:13:47 -0500 Subject: [PATCH 24/48] fix: fix path normalization for windows paths w/ non ascii chars fix #1384 --- packages/vite/package.json | 1 - packages/vite/rollup.config.js | 3 +-- packages/vite/src/node/plugins/html.ts | 9 +++++++-- packages/vite/src/node/plugins/resolve.ts | 4 ++-- packages/vite/src/node/server/hmr.ts | 5 ++--- packages/vite/src/node/utils.ts | 5 ++++- 6 files changed, 16 insertions(+), 11 deletions(-) diff --git a/packages/vite/package.json b/packages/vite/package.json index 5fce05f414ba2a..8ca51ff56af751 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -115,7 +115,6 @@ "rollup-plugin-license": "^2.2.0", "selfsigned": "^1.10.8", "sirv": "^1.0.10", - "slash": "^3.0.0", "source-map": "^0.6.1", "source-map-support": "^0.5.19", "strip-ansi": "^6.0.0", diff --git a/packages/vite/rollup.config.js b/packages/vite/rollup.config.js index db1fbae51be237..378242bfb6657e 100644 --- a/packages/vite/rollup.config.js +++ b/packages/vite/rollup.config.js @@ -1,7 +1,6 @@ // @ts-check import fs from 'fs' import path from 'path' -import slash from 'slash' import nodeResolve from '@rollup/plugin-node-resolve' import typescript from '@rollup/plugin-typescript' import commonjs from '@rollup/plugin-commonjs' @@ -188,7 +187,7 @@ function shimDepsPlugin(deps) { name: 'shim-deps', transform(code, id) { for (const file in deps) { - if (slash(id).endsWith(file)) { + if (id.replace(/\\/g, '/').endsWith(file)) { const { src, replacement, pattern } = deps[file] const magicString = new MagicString(code) diff --git a/packages/vite/src/node/plugins/html.ts b/packages/vite/src/node/plugins/html.ts index 8ae5e2127bad0a..62474b09de4cfa 100644 --- a/packages/vite/src/node/plugins/html.ts +++ b/packages/vite/src/node/plugins/html.ts @@ -3,9 +3,14 @@ import path from 'path' import { Plugin } from '../plugin' import { ViteDevServer } from '../server' import { OutputAsset, OutputBundle, OutputChunk } from 'rollup' -import { cleanUrl, isExternalUrl, isDataUrl, generateCodeFrame } from '../utils' +import { + slash, + cleanUrl, + isExternalUrl, + isDataUrl, + generateCodeFrame +} from '../utils' import { ResolvedConfig } from '../config' -import slash from 'slash' import MagicString from 'magic-string' import { checkPublicFile, diff --git a/packages/vite/src/node/plugins/resolve.ts b/packages/vite/src/node/plugins/resolve.ts index a14bdf0cb8941c..aedc391eb2979b 100644 --- a/packages/vite/src/node/plugins/resolve.ts +++ b/packages/vite/src/node/plugins/resolve.ts @@ -21,10 +21,10 @@ import { ensureVolumeInPath, resolveFrom, isDataUrl, - cleanUrl + cleanUrl, + slash } from '../utils' import { ViteDevServer } from '..' -import slash from 'slash' import { createFilter } from '@rollup/pluginutils' import { PartialResolvedId } from 'rollup' import { resolve as _resolveExports } from 'resolve.exports' diff --git a/packages/vite/src/node/server/hmr.ts b/packages/vite/src/node/server/hmr.ts index 5ba27c3c8b68dd..9ed0d85f2f6a83 100644 --- a/packages/vite/src/node/server/hmr.ts +++ b/packages/vite/src/node/server/hmr.ts @@ -1,10 +1,9 @@ import fs from 'fs' import path from 'path' +import chalk from 'chalk' import { createServer, ViteDevServer } from '..' import { createDebugger, normalizePath } from '../utils' import { ModuleNode } from './moduleGraph' -import chalk from 'chalk' -import slash from 'slash' import { Update } from 'types/hmrPayload' import { CLIENT_DIR } from '../constants' import { RollupError } from 'rollup' @@ -96,7 +95,7 @@ export async function handleHMRUpdate( type: 'full-reload', path: config.server.middlewareMode ? '*' - : '/' + slash(path.relative(config.root, file)) + : '/' + normalizePath(path.relative(config.root, file)) }) } else { // loaded but not in the module graph, probably not js diff --git a/packages/vite/src/node/utils.ts b/packages/vite/src/node/utils.ts index 00d8111879215c..06ab55b4700d56 100644 --- a/packages/vite/src/node/utils.ts +++ b/packages/vite/src/node/utils.ts @@ -4,12 +4,15 @@ import fs from 'fs' import os from 'os' import path from 'path' import { parse as parseUrl } from 'url' -import slash from 'slash' import { FS_PREFIX, SUPPORTED_EXTS } from './constants' import resolve from 'resolve' import builtins from 'builtin-modules' import { FSWatcher } from 'chokidar' +export function slash(p: string): string { + return p.replace(/\\/g, '/') +} + export const flattenId = (id: string) => id.replace(/[\/\.]/g, '_') export function isBuiltin(id: string): boolean { From 0318c64cc3efe970a5cd3ef6624fe3625af06012 Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 9 Feb 2021 22:27:26 -0500 Subject: [PATCH 25/48] feat(resolve): expose full resolve options via config - New config options: - `resolve.conditions` - `resolve.mainFields` - `resolve.extensions` - Deprecation: `alias` is now `resolve.alias` - Deprecation: `dedupe` is now `resolve.dedupe` close #1951 --- docs/config/index.md | 109 ++++++++----- packages/playground/alias/vite.config.js | 30 ++-- .../playground/optimize-deps/vite.config.js | 4 +- .../resolve/__tests__/resolve.spec.ts | 12 ++ .../resolve/custom-condition/index.custom.js | 1 + .../resolve/custom-condition/index.js | 1 + .../resolve/custom-condition/package.json | 12 ++ packages/playground/resolve/custom-ext.es | 1 + .../resolve/custom-main-field/index.custom.js | 1 + .../resolve/custom-main-field/index.js | 1 + .../resolve/custom-main-field/package.json | 6 + packages/playground/resolve/index.html | 18 +++ packages/playground/resolve/package.json | 2 + packages/playground/resolve/vite.config.js | 5 + packages/vite/src/node/config.ts | 148 ++++++++++++------ packages/vite/src/node/constants.ts | 15 +- packages/vite/src/node/optimizer/index.ts | 3 +- packages/vite/src/node/optimizer/scan.ts | 4 +- packages/vite/src/node/plugins/css.ts | 6 +- packages/vite/src/node/plugins/index.ts | 4 +- packages/vite/src/node/plugins/resolve.ts | 76 ++++----- .../src/node/server/middlewares/static.ts | 2 +- packages/vite/src/node/ssr/ssrExternal.ts | 4 +- packages/vite/src/node/utils.ts | 4 +- yarn.lock | 8 + 25 files changed, 333 insertions(+), 144 deletions(-) create mode 100644 packages/playground/resolve/custom-condition/index.custom.js create mode 100644 packages/playground/resolve/custom-condition/index.js create mode 100644 packages/playground/resolve/custom-condition/package.json create mode 100644 packages/playground/resolve/custom-ext.es create mode 100644 packages/playground/resolve/custom-main-field/index.custom.js create mode 100644 packages/playground/resolve/custom-main-field/index.js create mode 100644 packages/playground/resolve/custom-main-field/package.json diff --git a/docs/config/index.md b/docs/config/index.md index 2c9c28466051dc..2fe9e86a4a9cb9 100644 --- a/docs/config/index.md +++ b/docs/config/index.md @@ -66,29 +66,6 @@ export default ({ command, mode }) => { ## Shared Options -### alias - -- **Type:** - `Record | Array<{ find: string | RegExp, replacement: string }>` - - Will be passed to `@rollup/plugin-alias` as its [entries option](https://github.com/rollup/plugins/tree/master/packages/alias#entries). Can either be an object, or an array of `{ find, replacement }` pairs. - - When aliasing to file system paths, always use absolute paths. Relative alias values will be used as-is and will not be resolved into file system paths. - - More advanced custom resolution can be achieved through [plugins](/guide/api-plugin). - -### define - -- **Type:** `Record` - - Define global variable replacements. Entries will be defined as globals during dev and statically replaced during build. - -### plugins - -- **Type:** ` (Plugin | Plugin[])[]` - - Array of plugins to use. See [Plugin API](/guide/api-plugin) for more details on Vite plugins. - ### root - **Type:** `string` @@ -111,6 +88,27 @@ export default ({ command, mode }) => { See [Public Base Path](/guide/build#public-base-path) for more details. +### mode + +- **Type:** `string` +- **Default:** `'development'` for serve, `'production'` for build + + Specifying this in config will override the default mode for **both serve and build**. This value can also be overridden via the command line `--mode` option. + + See [Env Variables and Modes](/guide/env-and-mode) for more details. + +### define + +- **Type:** `Record` + + Define global variable replacements. Entries will be defined as globals during dev and statically replaced during build. Replacements are performed only when the match is surrounded by word boundaries (`\b`). + +### plugins + +- **Type:** ` (Plugin | Plugin[])[]` + + Array of plugins to use. See [Plugin API](/guide/api-plugin) for more details on Vite plugins. + ### publicDir - **Type:** `string` @@ -118,14 +116,62 @@ export default ({ command, mode }) => { Directory to serve as plain static assets. Files in this directory are served at `/` during dev and copied to the root of `outDir` during build, and are always served or copied as-is without transform. The value can be either an absolute file system path or a path relative to project root. -### mode + See [The `public` Directory](/guide/assets#the-public-directory) for more details. -- **Type:** `string` -- **Default:** `'development'` for serve, `'production'` for build +### resolve.alias - Specifying this in config will override the default mode for both serve and build. This value can also be overridden via the command line `--mode` option. +- **Type:** + `Record | Array<{ find: string | RegExp, replacement: string }>` - See [Env Variables and Modes](/guide/env-and-mode) for more details. + Will be passed to `@rollup/plugin-alias` as its [entries option](https://github.com/rollup/plugins/tree/master/packages/alias#entries). Can either be an object, or an array of `{ find, replacement }` pairs. + + When aliasing to file system paths, always use absolute paths. Relative alias values will be used as-is and will not be resolved into file system paths. + + More advanced custom resolution can be achieved through [plugins](/guide/api-plugin). + +### resolve.dedupe + +- **Type:** `string[]` + + If you have duplicated copies of the same dependency in your app (likely due to hoisting or linked packages in monorepos), use this option to force Vite to always resolve listed dependencies to the same copy (from + project root). + +### resolve.conditions + +- **Type:** `string[]` + + Additional allowed conditions when resolving [Conditional Exports](https://nodejs.org/api/packages.html#packages_conditional_exports) from a package. + + A package with conditional exports may have the following `exports` field in its `package.json`: + + ```json + { + "exports": { + ".": { + "import": "./index.esm.js", + "require": "./index.cjs.js" + } + } + } + ``` + + Here, `import` and `require` are "conditions". Conditions can be nested and should be specified from most specific to least specific. + + Vite has a list of "allowed conditions" and will match the first condition that is in the allowed list. The default allowed conditions are: `import`, `module`, `browser`, `default`, and `production/development` based on current mode. The `resolve.conditions` config option allows specifying additional allowed conditions. + +### resolve.mainFields + +- **Type:** `string[]` +- **Default:**: `['module', 'jsnext:main', 'jsnext']` + + List of fields in `package.json` to try when resolving a package's entry point. Note this takes lower precedence than conditional exports resolved from the `exports` field: if an entry point is successfully resolved from `exports`, the main field will be ignored. + +### resolve.extensions + +- **Type:** `string[]` +- **Default:**: `['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json']` + + List of file extensions to try for imports that omit extensions. Note it is **NOT** recommended to omit extensions for custom import types (e.g. `.vue`) since it can interfere with IDE and type support. ### css.modules @@ -232,13 +278,6 @@ export default ({ command, mode }) => { The built-in asset type list can be found [here](https://github.com/vitejs/vite/blob/main/packages/vite/src/node/constants.ts). -### dedupe - -- **Type:** `string[]` - - If you have duplicated copies of the same dependency in your app (likely due to hoisting or linked packages in monorepos), use this option to force Vite to always resolve listed dependencies to the same copy (from - project root). - ### logLevel - **Type:** `'info' | 'warn' | 'error' | 'silent'` diff --git a/packages/playground/alias/vite.config.js b/packages/playground/alias/vite.config.js index 43b2b2396f8ae2..911c2cd2d0713c 100644 --- a/packages/playground/alias/vite.config.js +++ b/packages/playground/alias/vite.config.js @@ -4,20 +4,22 @@ const path = require('path') * @type {import('vite').UserConfig} */ module.exports = { - alias: [ - { find: 'fs', replacement: path.resolve(__dirname, 'test.js') }, - { find: 'fs-dir', replacement: path.resolve(__dirname, 'dir') }, - { find: 'dep', replacement: 'resolve-linked' }, - { - find: /^regex\/(.*)/, - replacement: `${path.resolve(__dirname, 'dir')}/$1` - }, - { find: '/@', replacement: path.resolve(__dirname, 'dir') }, - // aliasing an optimized dep - { find: 'vue', replacement: 'vue/dist/vue.esm-bundler.js' }, - // aliasing one unoptimized dep to an optimized dep - { find: 'foo', replacement: 'vue' } - ], + resolve: { + alias: [ + { find: 'fs', replacement: path.resolve(__dirname, 'test.js') }, + { find: 'fs-dir', replacement: path.resolve(__dirname, 'dir') }, + { find: 'dep', replacement: 'resolve-linked' }, + { + find: /^regex\/(.*)/, + replacement: `${path.resolve(__dirname, 'dir')}/$1` + }, + { find: '/@', replacement: path.resolve(__dirname, 'dir') }, + // aliasing an optimized dep + { find: 'vue', replacement: 'vue/dist/vue.esm-bundler.js' }, + // aliasing one unoptimized dep to an optimized dep + { find: 'foo', replacement: 'vue' } + ] + }, build: { minify: false } diff --git a/packages/playground/optimize-deps/vite.config.js b/packages/playground/optimize-deps/vite.config.js index 9e07904ef7ce61..162d9d0fdc0102 100644 --- a/packages/playground/optimize-deps/vite.config.js +++ b/packages/playground/optimize-deps/vite.config.js @@ -4,7 +4,9 @@ const vue = require('@vitejs/plugin-vue') * @type {import('vite').UserConfig} */ module.exports = { - dedupe: ['react'], + resolve: { + dedupe: ['react'] + }, optimizeDeps: { include: ['dep-linked-include'], diff --git a/packages/playground/resolve/__tests__/resolve.spec.ts b/packages/playground/resolve/__tests__/resolve.spec.ts index 69858977fa8f68..bdb90f66b2bb13 100644 --- a/packages/playground/resolve/__tests__/resolve.spec.ts +++ b/packages/playground/resolve/__tests__/resolve.spec.ts @@ -65,3 +65,15 @@ test('plugin resolved virutal file', async () => { test('resolve inline package', async () => { expect(await page.textContent('.inline-pkg')).toMatch('[success]') }) + +test('resolve.extensions', async () => { + expect(await page.textContent('.custom-ext')).toMatch('[success]') +}) + +test('resolve.mainFields', async () => { + expect(await page.textContent('.custom-main-fields')).toMatch('[success]') +}) + +test('resolve.conditions', async () => { + expect(await page.textContent('.custom-condition')).toMatch('[success]') +}) diff --git a/packages/playground/resolve/custom-condition/index.custom.js b/packages/playground/resolve/custom-condition/index.custom.js new file mode 100644 index 00000000000000..399a606cad7795 --- /dev/null +++ b/packages/playground/resolve/custom-condition/index.custom.js @@ -0,0 +1 @@ +export const msg = '[success] custom condition' diff --git a/packages/playground/resolve/custom-condition/index.js b/packages/playground/resolve/custom-condition/index.js new file mode 100644 index 00000000000000..fc671a86f57b92 --- /dev/null +++ b/packages/playground/resolve/custom-condition/index.js @@ -0,0 +1 @@ +export const msg = '[fail]' diff --git a/packages/playground/resolve/custom-condition/package.json b/packages/playground/resolve/custom-condition/package.json new file mode 100644 index 00000000000000..1b107f323109ec --- /dev/null +++ b/packages/playground/resolve/custom-condition/package.json @@ -0,0 +1,12 @@ +{ + "name": "resolve-custom-condition", + "version": "1.0.0", + "main": "index.js", + "exports": { + ".": { + "custom": "./index.custom.js", + "import": "./index.js", + "require": "./index.js" + } + } +} diff --git a/packages/playground/resolve/custom-ext.es b/packages/playground/resolve/custom-ext.es new file mode 100644 index 00000000000000..000f3d188d0dea --- /dev/null +++ b/packages/playground/resolve/custom-ext.es @@ -0,0 +1 @@ +export const msg = `[success] custom ext` \ No newline at end of file diff --git a/packages/playground/resolve/custom-main-field/index.custom.js b/packages/playground/resolve/custom-main-field/index.custom.js new file mode 100644 index 00000000000000..181ce959462962 --- /dev/null +++ b/packages/playground/resolve/custom-main-field/index.custom.js @@ -0,0 +1 @@ +export const msg = '[success] custom main field' diff --git a/packages/playground/resolve/custom-main-field/index.js b/packages/playground/resolve/custom-main-field/index.js new file mode 100644 index 00000000000000..fc671a86f57b92 --- /dev/null +++ b/packages/playground/resolve/custom-main-field/index.js @@ -0,0 +1 @@ +export const msg = '[fail]' diff --git a/packages/playground/resolve/custom-main-field/package.json b/packages/playground/resolve/custom-main-field/package.json new file mode 100644 index 00000000000000..64b0e5134f4ca5 --- /dev/null +++ b/packages/playground/resolve/custom-main-field/package.json @@ -0,0 +1,6 @@ +{ + "name": "resolve-custom-main-field", + "version": "1.0.0", + "main": "index.js", + "custom": "index.custom.js" +} diff --git a/packages/playground/resolve/index.html b/packages/playground/resolve/index.html index 4e0a654ce33c87..733d73f2ba838d 100644 --- a/packages/playground/resolve/index.html +++ b/packages/playground/resolve/index.html @@ -42,6 +42,15 @@

Plugin resolved virtual file

Inline package

+

resolve.extensions

+

+ +

resolve.mainFields

+

+ +

resolve.conditions

+

+ +