From d8502e24cf971f6c7f1801c9db16fe34cf4cd6ea Mon Sep 17 00:00:00 2001 From: poyoho <907415276@qq.com> Date: Fri, 31 Dec 2021 15:49:05 +0800 Subject: [PATCH 001/174] docs: add override rule for the env (#6304) Co-authored-by: Bjorn Lu --- docs/guide/env-and-mode.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/guide/env-and-mode.md b/docs/guide/env-and-mode.md index e764325e1948cf..9d6defdf33c778 100644 --- a/docs/guide/env-and-mode.md +++ b/docs/guide/env-and-mode.md @@ -33,6 +33,15 @@ Vite uses [dotenv](https://github.com/motdotla/dotenv) to load additional enviro .env.[mode].local # only loaded in specified mode, ignored by git ``` +:::tip Env Loading Priorities + +An env file for a specific mode (e.g. `.env.production`) will take higher priority than a generic one (e.g. `.env`). + +In addition, environment variables that already exist when Vite is executed have the highest priority and will not be overwritten by `.env` files. + +`.env` files are loaded at the start of Vite. Restart the server after making changes. +::: + Loaded env variables are also exposed to your client source code via `import.meta.env`. To prevent accidentally leaking env variables to the client, only variables prefixed with `VITE_` are exposed to your Vite-processed code. e.g. the following file: From 577b31c954c0fe9ede38d9f38c7359160b1d6fe8 Mon Sep 17 00:00:00 2001 From: James Garbutt <43081j@users.noreply.github.com> Date: Fri, 31 Dec 2021 14:30:31 +0000 Subject: [PATCH 002/174] chore: replace chalk with picocolors (#6342) --- package.json | 2 +- pnpm-lock.yaml | 47 ++++++++++------------------------------- scripts/release.ts | 10 ++++----- scripts/verifyCommit.ts | 12 +++++------ 4 files changed, 23 insertions(+), 48 deletions(-) diff --git a/package.json b/package.json index 171d3094ebd03a..49e974836d3c4e 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,6 @@ "@types/semver": "^7.3.9", "@typescript-eslint/eslint-plugin": "^5.8.1", "@typescript-eslint/parser": "^5.8.1", - "chalk": "^4.1.2", "conventional-changelog-cli": "^2.2.2", "cross-env": "^7.0.3", "esbuild": "0.14.3", @@ -46,6 +45,7 @@ "minimist": "^1.2.5", "node-fetch": "^2.6.6", "npm-run-all": "^4.1.5", + "picocolors": "^1.0.0", "playwright-chromium": "^1.17.1", "prettier": "2.5.1", "prompts": "^2.4.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bf47e7009e2dc0..cfc47be7186c14 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -16,7 +16,6 @@ importers: '@types/semver': ^7.3.9 '@typescript-eslint/eslint-plugin': ^5.8.1 '@typescript-eslint/parser': ^5.8.1 - chalk: ^4.1.2 conventional-changelog-cli: ^2.2.2 cross-env: ^7.0.3 esbuild: 0.14.3 @@ -30,6 +29,7 @@ importers: minimist: ^1.2.5 node-fetch: ^2.6.6 npm-run-all: ^4.1.5 + picocolors: ^1.0.0 playwright-chromium: ^1.17.1 prettier: 2.5.1 prompts: ^2.4.2 @@ -52,7 +52,6 @@ importers: '@types/semver': 7.3.9 '@typescript-eslint/eslint-plugin': 5.8.1_3a47348159e115370aa4cba56aba33b6 '@typescript-eslint/parser': 5.8.1_eslint@8.5.0+typescript@4.5.4 - chalk: 4.1.2 conventional-changelog-cli: 2.2.2 cross-env: 7.0.3 esbuild: 0.14.3 @@ -66,6 +65,7 @@ importers: minimist: 1.2.5 node-fetch: 2.6.6 npm-run-all: 4.1.5 + picocolors: 1.0.0 playwright-chromium: 1.17.1 prettier: 2.5.1 prompts: 2.4.2 @@ -802,7 +802,7 @@ importers: '@rollup/plugin-dynamic-import-vars': 1.4.2_rollup@2.62.0 '@rollup/plugin-json': 4.1.0_rollup@2.62.0 '@rollup/plugin-node-resolve': 13.1.1_rollup@2.62.0 - '@rollup/plugin-typescript': 8.3.0_rollup@2.62.0+tslib@2.3.1 + '@rollup/plugin-typescript': 8.3.0_7c5ff569c0887b4f0035eb7cb6988163 '@rollup/pluginutils': 4.1.2 '@types/convert-source-map': 1.5.2 '@types/cross-spawn': 6.0.2 @@ -845,7 +845,7 @@ importers: periscopic: 2.0.3 picocolors: 1.0.0 postcss-import: 14.0.2_postcss@8.4.5 - postcss-load-config: 3.1.0 + postcss-load-config: 3.1.0_ts-node@10.4.0 postcss-modules: 4.3.0_postcss@8.4.5 resolve.exports: 1.1.0 rollup-plugin-license: 2.6.0_rollup@2.62.0 @@ -854,7 +854,7 @@ importers: source-map-support: 0.5.21 strip-ansi: 6.0.1 terser: 5.10.0_acorn@8.7.0 - tsconfck: 1.1.1 + tsconfck: 1.1.1_typescript@4.5.4 tslib: 2.3.1 types: link:types ws: 8.4.0 @@ -1995,7 +1995,7 @@ packages: rollup: 2.62.0 dev: true - /@rollup/plugin-typescript/8.3.0_rollup@2.62.0+tslib@2.3.1: + /@rollup/plugin-typescript/8.3.0_7c5ff569c0887b4f0035eb7cb6988163: resolution: {integrity: sha512-I5FpSvLbtAdwJ+naznv+B4sjXZUcIvLLceYpITAn7wAP8W0wqc5noLdGIp9HGVntNhRWXctwPYrSSFQxtl0FPA==} engines: {node: '>=8.0.0'} peerDependencies: @@ -2007,6 +2007,7 @@ packages: resolve: 1.20.0 rollup: 2.62.0 tslib: 2.3.1 + typescript: 4.5.4 dev: true /@rollup/pluginutils/3.1.0_rollup@2.62.0: @@ -4556,19 +4557,6 @@ packages: peerDependenciesMeta: debug: optional: true - dev: false - - /follow-redirects/1.14.6_debug@4.3.3: - resolution: {integrity: sha512-fhUl5EwSJbbl8AR+uYL2KQDxLkdSjZGR36xy46AO7cOMTrCMON6Sa28FmAnC2tRTDbd/Uuzz3aJBv7EBN7JH8A==} - engines: {node: '>=4.0'} - peerDependencies: - debug: '*' - peerDependenciesMeta: - debug: - optional: true - dependencies: - debug: 4.3.3 - dev: true /form-data/3.0.1: resolution: {integrity: sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==} @@ -4960,7 +4948,7 @@ packages: engines: {node: '>=8.0.0'} dependencies: eventemitter3: 4.0.7 - follow-redirects: 1.14.6_debug@4.3.3 + follow-redirects: 1.14.6 requires-port: 1.0.0 transitivePeerDependencies: - debug @@ -7002,20 +6990,6 @@ packages: postcss: 8.4.5 dev: false - /postcss-load-config/3.1.0: - resolution: {integrity: sha512-ipM8Ds01ZUophjDTQYSVP70slFSYg3T0/zyfII5vzhN6V57YSxMgG5syXuwi5VtS8wSf3iL30v0uBdoIVx4Q0g==} - engines: {node: '>= 10'} - peerDependencies: - ts-node: '>=9.0.0' - peerDependenciesMeta: - ts-node: - optional: true - dependencies: - import-cwd: 3.0.0 - lilconfig: 2.0.4 - yaml: 1.10.2 - dev: true - /postcss-load-config/3.1.0_ts-node@10.4.0: resolution: {integrity: sha512-ipM8Ds01ZUophjDTQYSVP70slFSYg3T0/zyfII5vzhN6V57YSxMgG5syXuwi5VtS8wSf3iL30v0uBdoIVx4Q0g==} engines: {node: '>= 10'} @@ -7029,7 +7003,6 @@ packages: lilconfig: 2.0.4 ts-node: 10.4.0_00264fd83560919cd06c986889baae0a yaml: 1.10.2 - dev: false /postcss-modules-extract-imports/3.0.0_postcss@8.4.5: resolution: {integrity: sha512-bdHleFnP3kZ4NYDhuGlVK+CMrQ/pqUm8bx/oGL93K6gVwiclvX5x0n76fYMKuIGKzlABOy13zsvqjb0f92TEXw==} @@ -8546,7 +8519,7 @@ packages: yn: 3.1.1 dev: true - /tsconfck/1.1.1: + /tsconfck/1.1.1_typescript@4.5.4: resolution: {integrity: sha512-uEsCWef+3lA9/YqpGt/mdr+nDovhlr+f0zoycYiOyVDDOUb3BjYFA71+Ee3LB/GiZBRDyTfKBK1kGN2iuPPuEA==} engines: {node: ^12.20 || ^14.13.1 || >= 16, pnpm: '>=6.7.0'} hasBin: true @@ -8555,6 +8528,8 @@ packages: peerDependenciesMeta: typescript: optional: true + dependencies: + typescript: 4.5.4 dev: true /tslib/1.14.1: diff --git a/scripts/release.ts b/scripts/release.ts index 03461a8a0208ea..3d456aacbc8638 100644 --- a/scripts/release.ts +++ b/scripts/release.ts @@ -1,7 +1,7 @@ /** * modified from https://github.com/vuejs/vue-next/blob/master/scripts/release.js */ -import chalk from 'chalk' +import colors from 'picocolors' import type { ExecaChildProcess, Options as ExecaOptions } from 'execa' import execa from 'execa' import { readFileSync, writeFileSync } from 'fs' @@ -45,11 +45,11 @@ const run: RunFn = (bin, args, opts = {}) => type DryRunFn = (bin: string, args: string[], opts?: any) => void const dryRun: DryRunFn = (bin, args, opts: any) => - console.log(chalk.blue(`[dryrun] ${bin} ${args.join(' ')}`), opts) + console.log(colors.blue(`[dryrun] ${bin} ${args.join(' ')}`), opts) const runIfNotDry = isDryRun ? dryRun : run -const step: (msg: string) => void = (msg) => console.log(chalk.cyan(msg)) +const step: (msg: string) => void = (msg) => console.log(colors.cyan(msg)) async function main(): Promise { let targetVersion: string | undefined = args._[0] @@ -170,10 +170,10 @@ async function publishPackage( await runIfNotDry('yarn', publicArgs, { stdio: 'pipe' }) - console.log(chalk.green(`Successfully published ${pkgName}@${version}`)) + console.log(colors.green(`Successfully published ${pkgName}@${version}`)) } catch (e: any) { if (e.stderr.match(/previously published/)) { - console.log(chalk.red(`Skipping already published: ${pkgName}`)) + console.log(colors.red(`Skipping already published: ${pkgName}`)) } else { throw e } diff --git a/scripts/verifyCommit.ts b/scripts/verifyCommit.ts index 437e723c85d17b..47ec89c2d1c9e1 100644 --- a/scripts/verifyCommit.ts +++ b/scripts/verifyCommit.ts @@ -1,6 +1,6 @@ // Invoked on the commit-msg git hook by yorkie. -import chalk from 'chalk' +import colors from 'picocolors' import { readFileSync } from 'fs' const msgPath = process.env.GIT_PARAMS! @@ -13,15 +13,15 @@ const commitRE = if (!releaseRE.test(msg) && !commitRE.test(msg)) { console.log() console.error( - ` ${chalk.bgRed.white(' ERROR ')} ${chalk.red( + ` ${colors.bgRed(colors.white(' ERROR '))} ${colors.red( `invalid commit message format.` )}\n\n` + - chalk.red( + colors.red( ` Proper commit message format is required for automated changelog generation. Examples:\n\n` ) + - ` ${chalk.green(`feat: add 'comments' option`)}\n` + - ` ${chalk.green(`fix: handle events on blur (close #28)`)}\n\n` + - chalk.red(` See .github/commit-convention.md for more details.\n`) + ` ${colors.green(`feat: add 'comments' option`)}\n` + + ` ${colors.green(`fix: handle events on blur (close #28)`)}\n\n` + + colors.red(` See .github/commit-convention.md for more details.\n`) ) process.exit(1) } From a49d72358f2d028f62b0e9fcdb096a0e5ddf24c3 Mon Sep 17 00:00:00 2001 From: toSayNothing <91143836+toSayNothing@users.noreply.github.com> Date: Sat, 1 Jan 2022 00:41:21 +0800 Subject: [PATCH 003/174] fix: prevent dev server crashing on malformed URI (fix #6300) (#6308) --- .../vite/src/node/server/middlewares/transform.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/vite/src/node/server/middlewares/transform.ts b/packages/vite/src/node/server/middlewares/transform.ts index 73a2efc4b47582..b84cee8e0d79c7 100644 --- a/packages/vite/src/node/server/middlewares/transform.ts +++ b/packages/vite/src/node/server/middlewares/transform.ts @@ -98,11 +98,15 @@ export function transformMiddleware( return } } - - let url = decodeURI(removeTimestampQuery(req.url!)).replace( - NULL_BYTE_PLACEHOLDER, - '\0' - ) + let url: string + try { + url = decodeURI(removeTimestampQuery(req.url!)).replace( + NULL_BYTE_PLACEHOLDER, + '\0' + ) + } catch (e) { + return next(e) + } const withoutQuery = cleanUrl(url) From 133fcea5223263b0ae08ac9a0422b55183ebd266 Mon Sep 17 00:00:00 2001 From: poyoho <907415276@qq.com> Date: Sun, 2 Jan 2022 16:36:01 +0800 Subject: [PATCH 004/174] feat(worker): support worker format, plugins and rollupOptions (fix #6191) (#6351) --- docs/config/index.md | 21 +++++++++++++++ .../worker/__tests__/worker.spec.ts | 5 +++- packages/playground/worker/index.html | 2 ++ packages/playground/worker/my-worker.ts | 3 ++- packages/playground/worker/package.json | 3 +++ packages/playground/worker/test-plugin.tsx | 1 + packages/playground/worker/vite.config.ts | 11 ++++++++ packages/vite/src/node/config.ts | 22 ++++++++++++++++ packages/vite/src/node/plugins/worker.ts | 26 +++++++++++++++---- pnpm-lock.yaml | 5 +++- 10 files changed, 91 insertions(+), 8 deletions(-) create mode 100644 packages/playground/worker/test-plugin.tsx create mode 100644 packages/playground/worker/vite.config.ts diff --git a/docs/config/index.md b/docs/config/index.md index b7cba23e2bce5f..040799ce7a0a0d 100644 --- a/docs/config/index.md +++ b/docs/config/index.md @@ -976,3 +976,24 @@ SSR options may be adjusted in minor releases. - **Default:** `node` Build target for the SSR server. + +## Worker Options + +### worker.format + +- **Type:** `'es' | 'iife'` +- **Default:** `iife` + + Output format for worker bundle. + +### worker.plugins + +- **Type:** [`(Plugin | Plugin[])[]`](#plugins) + + Vite plugins that apply to worker bundle + +### worker.rollupOptions + +- **Type:** [`RollupOptions`](https://rollupjs.org/guide/en/#big-list-of-options) + + Rollup options to build worker bundle. diff --git a/packages/playground/worker/__tests__/worker.spec.ts b/packages/playground/worker/__tests__/worker.spec.ts index b84ea39fef5d0a..21e1a47141d637 100644 --- a/packages/playground/worker/__tests__/worker.spec.ts +++ b/packages/playground/worker/__tests__/worker.spec.ts @@ -10,6 +10,10 @@ test('normal', async () => { () => page.textContent('.mode'), isBuild ? 'production' : 'development' ) + await untilUpdated( + () => page.textContent('.bundle-with-plugin'), + 'worker bundle with plugin success!' + ) }) test('TS output', async () => { @@ -52,7 +56,6 @@ if (isBuild) { test('inlined code generation', async () => { const assetsDir = path.resolve(testDir, 'dist/assets') const files = fs.readdirSync(assetsDir) - // should have 3 worker chunk expect(files.length).toBe(4) const index = files.find((f) => f.includes('index')) const content = fs.readFileSync(path.resolve(assetsDir, index), 'utf-8') diff --git a/packages/playground/worker/index.html b/packages/playground/worker/index.html index 20888835122fac..a075134df175e5 100644 --- a/packages/playground/worker/index.html +++ b/packages/playground/worker/index.html @@ -3,6 +3,7 @@
Response from worker:
+
bundle-with-plugin:
Response from inline worker:
@@ -32,6 +33,7 @@ worker.addEventListener('message', (e) => { text('.pong', e.data.msg) text('.mode', e.data.mode) + text('.bundle-with-plugin', e.data.bundleWithPlugin) }) document.querySelector('.ping').addEventListener('click', () => { diff --git a/packages/playground/worker/my-worker.ts b/packages/playground/worker/my-worker.ts index 2bcce3faa8a50e..550382be72c331 100644 --- a/packages/playground/worker/my-worker.ts +++ b/packages/playground/worker/my-worker.ts @@ -1,7 +1,8 @@ import { msg, mode } from './workerImport' +import { bundleWithPlugin } from './test-plugin' self.onmessage = (e) => { if (e.data === 'ping') { - self.postMessage({ msg, mode }) + self.postMessage({ msg, mode, bundleWithPlugin }) } } diff --git a/packages/playground/worker/package.json b/packages/playground/worker/package.json index 325f88f8f30a37..131df8c4cbf336 100644 --- a/packages/playground/worker/package.json +++ b/packages/playground/worker/package.json @@ -7,5 +7,8 @@ "build": "vite build", "debug": "node --inspect-brk ../../vite/bin/vite", "preview": "vite preview" + }, + "devDependencies": { + "@vitejs/plugin-vue-jsx": "workspace:*" } } diff --git a/packages/playground/worker/test-plugin.tsx b/packages/playground/worker/test-plugin.tsx new file mode 100644 index 00000000000000..15b6b94f460bc3 --- /dev/null +++ b/packages/playground/worker/test-plugin.tsx @@ -0,0 +1 @@ +export const bundleWithPlugin: string = 'worker bundle with plugin success!' diff --git a/packages/playground/worker/vite.config.ts b/packages/playground/worker/vite.config.ts new file mode 100644 index 00000000000000..6bf980f46e2362 --- /dev/null +++ b/packages/playground/worker/vite.config.ts @@ -0,0 +1,11 @@ +import vueJsx from '@vitejs/plugin-vue-jsx' +import { defineConfig } from 'vite' + +export default defineConfig({ + build: { + target: process.env.NODE_ENV === 'production' ? 'chrome60' : 'esnext' + }, + worker: { + plugins: [vueJsx()] + } +}) diff --git a/packages/vite/src/node/config.ts b/packages/vite/src/node/config.ts index 94a698eade6eb8..3cc0e95d442b1f 100644 --- a/packages/vite/src/node/config.ts +++ b/packages/vite/src/node/config.ts @@ -39,6 +39,7 @@ import aliasPlugin from '@rollup/plugin-alias' import { build } from 'esbuild' import { performance } from 'perf_hooks' import type { PackageCache } from './packages' +import type { RollupOptions } from 'rollup' const debug = createDebugger('vite:config') @@ -185,6 +186,27 @@ export interface UserConfig { * @deprecated use `resolve.dedupe` instead */ dedupe?: string[] + /** + * Worker bundle options + */ + worker?: { + /** + * Output format for worker bundle + * @default 'iife' + */ + format?: 'es' | 'iife' + /** + * Vite plugins that apply to worker bundle + */ + plugins?: (PluginOption | PluginOption[])[] + /** + * Rollup options to build worker bundle + */ + rollupOptions?: Omit< + RollupOptions, + 'plugins' | 'input' | 'onwarn' | 'preserveEntrySignatures' + > + } } export type SSRTarget = 'node' | 'webworker' diff --git a/packages/vite/src/node/plugins/worker.ts b/packages/vite/src/node/plugins/worker.ts index 2f644a7cad9844..dc9a55ce6ff55d 100644 --- a/packages/vite/src/node/plugins/worker.ts +++ b/packages/vite/src/node/plugins/worker.ts @@ -1,17 +1,23 @@ import type { ResolvedConfig } from '../config' +import { sortUserPlugins } from '../config' import type { Plugin } from '../plugin' -import { resolvePlugins } from '../plugins' import { fileToUrl, getAssetHash } from './asset' import { cleanUrl, injectQuery, parseRequest } from '../utils' import type Rollup from 'rollup' import { ENV_PUBLIC_PATH } from '../constants' import path from 'path' import { onRollupWarning } from '../build' +import { resolvePlugins } from '.' const WorkerFileId = 'worker_file' export function webWorkerPlugin(config: ResolvedConfig): Plugin { const isBuild = config.command === 'build' + const workerBundleOptions = { + format: config.worker?.format || 'iife', + plugins: sortUserPlugins(config.worker?.plugins as Plugin[]), + rollupOptions: config.worker?.rollupOptions || {} + } return { name: 'vite:worker', @@ -46,17 +52,26 @@ export function webWorkerPlugin(config: ResolvedConfig): Plugin { if (isBuild) { // bundle the file as entry to support imports const rollup = require('rollup') as typeof Rollup + const { plugins, rollupOptions, format } = workerBundleOptions + const [prePlugins, normalPlugins, postPlugins] = plugins const bundle = await rollup.rollup({ + ...rollupOptions, input: cleanUrl(id), - plugins: await resolvePlugins({ ...config }, [], [], []), + plugins: await resolvePlugins( + { ...config }, + prePlugins, + normalPlugins, + postPlugins + ), onwarn(warning, warn) { onRollupWarning(warning, warn, config) - } + }, + preserveEntrySignatures: false }) let code: string try { const { output } = await bundle.generate({ - format: 'iife', + format, sourcemap: config.build.sourcemap }) code = output[0].code @@ -65,13 +80,14 @@ export function webWorkerPlugin(config: ResolvedConfig): Plugin { } const content = Buffer.from(code) if (query.inline != null) { + const workerOptions = format === 'es' ? '{type: "module"}' : '{}' // inline as blob data url return `const encodedJs = "${content.toString('base64')}"; const blob = typeof window !== "undefined" && window.Blob && new Blob([atob(encodedJs)], { type: "text/javascript;charset=utf-8" }); export default function WorkerWrapper() { const objURL = blob && (window.URL || window.webkitURL).createObjectURL(blob); try { - return objURL ? new Worker(objURL) : new Worker("data:application/javascript;base64," + encodedJs, {type: "module"}); + return objURL ? new Worker(objURL, ${workerOptions}) : new Worker("data:application/javascript;base64," + encodedJs, {type: "module"}); } finally { objURL && (window.URL || window.webkitURL).revokeObjectURL(objURL); } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index cfc47be7186c14..8e6f737ef528ed 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -641,7 +641,10 @@ importers: specifiers: {} packages/playground/worker: - specifiers: {} + specifiers: + '@vitejs/plugin-vue-jsx': workspace:* + devDependencies: + '@vitejs/plugin-vue-jsx': link:../../plugin-vue-jsx packages/plugin-legacy: specifiers: From 9a58aaeef9756f8ae932a7a59f5c26392d8545cc Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 3 Jan 2022 05:43:12 +0100 Subject: [PATCH 005/174] chore(deps): update dependency sirv to v2 (#6358) --- package.json | 2 +- packages/vite/package.json | 2 +- pnpm-lock.yaml | 18 +++++++++--------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 49e974836d3c4e..6c5eb872addfee 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "rimraf": "^3.0.2", "rollup": "^2.59.0", "semver": "^7.3.5", - "sirv": "^1.0.19", + "sirv": "^2.0.0", "ts-jest": "^27.1.2", "ts-node": "^10.4.0", "typescript": "~4.5.4", diff --git a/packages/vite/package.json b/packages/vite/package.json index f1b73c2d873c2e..4c5960789353d0 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -109,7 +109,7 @@ "postcss-modules": "^4.3.0", "resolve.exports": "^1.1.0", "rollup-plugin-license": "^2.6.0", - "sirv": "^1.0.19", + "sirv": "^2.0.0", "source-map": "^0.6.1", "source-map-support": "^0.5.21", "strip-ansi": "^6.0.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8e6f737ef528ed..523baaa1e939c9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -36,7 +36,7 @@ importers: rimraf: ^3.0.2 rollup: ^2.59.0 semver: ^7.3.5 - sirv: ^1.0.19 + sirv: ^2.0.0 ts-jest: ^27.1.2 ts-node: ^10.4.0 typescript: ~4.5.4 @@ -72,7 +72,7 @@ importers: rimraf: 3.0.2 rollup: 2.62.0 semver: 7.3.5 - sirv: 1.0.19 + sirv: 2.0.0 ts-jest: 27.1.2_1b5a1be2010a86e622f02a11eaeb730f ts-node: 10.4.0_00264fd83560919cd06c986889baae0a typescript: 4.5.4 @@ -779,7 +779,7 @@ importers: resolve.exports: ^1.1.0 rollup: ^2.59.0 rollup-plugin-license: ^2.6.0 - sirv: ^1.0.19 + sirv: ^2.0.0 source-map: ^0.6.1 source-map-support: ^0.5.21 strip-ansi: ^6.0.1 @@ -852,7 +852,7 @@ importers: postcss-modules: 4.3.0_postcss@8.4.5 resolve.exports: 1.1.0 rollup-plugin-license: 2.6.0_rollup@2.62.0 - sirv: 1.0.19 + sirv: 2.0.0 source-map: 0.6.1 source-map-support: 0.5.21 strip-ansi: 6.0.1 @@ -7825,13 +7825,13 @@ packages: is-arrayish: 0.3.2 dev: false - /sirv/1.0.19: - resolution: {integrity: sha512-JuLThK3TnZG1TAKDwNIqNq6QA2afLOCcm+iE8D1Kj3GA40pSPsxQjjJl0J8X3tsR7T+CP1GavpzLwYkgVLWrZQ==} + /sirv/2.0.0: + resolution: {integrity: sha512-TT+4+zSM9LR8soWT5/4gOYHfB5a5XEOSV2LtmBRN5MUxi8kh7BSRGuoRYjeBaqhR4w+yx+k6t0OibDNgoLfF7w==} engines: {node: '>= 10'} dependencies: '@polka/url': 1.0.0-next.21 mrmime: 1.0.0 - totalist: 1.1.0 + totalist: 2.0.0 dev: true /sisteransi/1.0.5: @@ -8422,8 +8422,8 @@ packages: resolution: {integrity: sha1-zCAOqyYT9BZtJ/+a/HylbUnfbrQ=} dev: true - /totalist/1.1.0: - resolution: {integrity: sha512-gduQwd1rOdDMGxFG1gEvhV88Oirdo2p+KjoYFU7k2g+i7n6AFFbDQ5kMPUsW0pNbfQsB/cwXvT1i4Bue0s9g5g==} + /totalist/2.0.0: + resolution: {integrity: sha512-+Y17F0YzxfACxTyjfhnJQEe7afPA0GSpYlFkl2VFMxYP7jshQf9gXV7cH47EfToBumFThfKBvfAcoUn6fdNeRQ==} engines: {node: '>=6'} dev: true From 8613423c6251b3aef3ff45f34d8ea3fa134b5dfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EF=BC=A2=EF=BD=85=EF=BD=8E=E2=80=83=EF=BC=B4=EF=BD=85?= =?UTF-8?q?=EF=BD=81?= <66273043+benatshippabo@users.noreply.github.com> Date: Sun, 2 Jan 2022 21:31:17 -0800 Subject: [PATCH 006/174] docs(react): document opting out of automatic JSX runtime (#6326) --- packages/plugin-react/README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/plugin-react/README.md b/packages/plugin-react/README.md index 4f3f262d38ddab..588f947ec8b08c 100644 --- a/packages/plugin-react/README.md +++ b/packages/plugin-react/README.md @@ -33,6 +33,16 @@ react({ }) ``` +## Opting out of the automatic JSX runtime + +By default, the plugin uses the [automatic JSX runtime](https://github.com/alloc/vite-react-jsx#faq). However, if you encounter any issues, you may opt out using the `jsxRuntime` option. + +```js +react({ + jsxRuntime: 'classic' +}) +``` + ## Babel configuration The `babel` option lets you add plugins, presets, and [other configuration](https://babeljs.io/docs/en/options) to the Babel transformation performed on each JSX/TSX file. From 000ba2e00b14e6c595febfa6dcae862e2d341823 Mon Sep 17 00:00:00 2001 From: EGOIST <0x142857@gmail.com> Date: Mon, 3 Jan 2022 14:20:08 +0800 Subject: [PATCH 007/174] fix: strip query when resolving entry (#6233) --- packages/playground/vue/ExternalStyleCss.vue | 1 + packages/playground/vue/Main.vue | 2 ++ packages/playground/vue/package.json | 3 ++- packages/vite/src/node/plugins/resolve.ts | 5 +++++ pnpm-lock.yaml | 16 ++++++++++++++++ 5 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 packages/playground/vue/ExternalStyleCss.vue diff --git a/packages/playground/vue/ExternalStyleCss.vue b/packages/playground/vue/ExternalStyleCss.vue new file mode 100644 index 00000000000000..f58e3cd5c697a7 --- /dev/null +++ b/packages/playground/vue/ExternalStyleCss.vue @@ -0,0 +1 @@ + diff --git a/packages/playground/vue/Main.vue b/packages/playground/vue/Main.vue index d10ae401f7aa8e..ea14dc8f481b86 100644 --- a/packages/playground/vue/Main.vue +++ b/packages/playground/vue/Main.vue @@ -20,6 +20,7 @@ + diff --git a/packages/playground/ssr-vue/src/pages/Home.vue b/packages/playground/ssr-vue/src/pages/Home.vue index f03679734dc04b..3ca0ca985fe6ed 100644 --- a/packages/playground/ssr-vue/src/pages/Home.vue +++ b/packages/playground/ssr-vue/src/pages/Home.vue @@ -10,6 +10,11 @@

{{ state.url }}

{{ state.protocol }}

msg from nested virtual module: {{ virtualMsg }}

+ +
+ encrypted message: +

{{ encryptedMsg }}

+
@@ -18,6 +23,7 @@ import foo from '@foo' import { msg as virtualMsg } from '@virtual-file' import { reactive, defineAsyncComponent } from 'vue' +import Button from '../components/button' const ImportType = load('ImportType') const Foo = defineAsyncComponent(() => import('../components/Foo').then((mod) => mod.Foo) diff --git a/packages/vite/src/node/ssr/ssrManifestPlugin.ts b/packages/vite/src/node/ssr/ssrManifestPlugin.ts index 061cd2f419c6ba..e6811eae29b210 100644 --- a/packages/vite/src/node/ssr/ssrManifestPlugin.ts +++ b/packages/vite/src/node/ssr/ssrManifestPlugin.ts @@ -1,9 +1,13 @@ -import { relative } from 'path' -import { normalizePath } from '@rollup/pluginutils' +import { relative, basename, join, dirname } from 'path' +import { parse as parseImports } from 'es-module-lexer' +import type { ImportSpecifier } from 'es-module-lexer' +import type { OutputChunk } from 'rollup' import type { ResolvedConfig } from '..' import type { Plugin } from '../plugin' import { chunkToEmittedCssFileMap } from '../plugins/css' import { chunkToEmittedAssetsMap } from '../plugins/asset' +import { preloadMethod } from '../plugins/importAnalysisBuild' +import { normalizePath } from '../utils' export function ssrManifestPlugin(config: ResolvedConfig): Plugin { // module id => preload assets mapping @@ -40,6 +44,54 @@ export function ssrManifestPlugin(config: ResolvedConfig): Plugin { }) } } + if (chunk.code.includes(preloadMethod)) { + // generate css deps map + const code = chunk.code + let imports: ImportSpecifier[] + try { + imports = parseImports(code)[0].filter((i) => i.d > -1) + } catch (e: any) { + this.error(e, e.idx) + } + if (imports.length) { + for (let index = 0; index < imports.length; index++) { + const { + s: start, + e: end, + n: name, + d: dynamicIndex + } = imports[index] + if (dynamicIndex) { + // check the chunk being imported + const url = code.slice(start, end) + const deps: string[] = [] + const ownerFilename = chunk.fileName + // literal import - trace direct imports and add to deps + const analyzed: Set = new Set() + const addDeps = (filename: string) => { + if (filename === ownerFilename) return + if (analyzed.has(filename)) return + analyzed.add(filename) + const chunk = bundle[filename] as OutputChunk | undefined + if (chunk) { + const cssFiles = chunkToEmittedCssFileMap.get(chunk) + if (cssFiles) { + cssFiles.forEach((file) => { + deps.push(`/${file}`) + }) + } + chunk.imports.forEach(addDeps) + } + } + const normalizedFile = normalizePath( + join(dirname(chunk.fileName), url.slice(1, -1)) + ) + addDeps(normalizedFile) + ssrManifest[basename(name!)] = deps + } + } + } + } } } From 1f032115eff6bc9d65943d1c1ff3668ca6559ae6 Mon Sep 17 00:00:00 2001 From: patak-dev Date: Wed, 5 Jan 2022 15:08:09 +0100 Subject: [PATCH 019/174] release: v2.8.0-beta.0 --- packages/vite/CHANGELOG.md | 37 +++++++++++++++++++++++++++++++++++++ packages/vite/package.json | 2 +- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/packages/vite/CHANGELOG.md b/packages/vite/CHANGELOG.md index 87cc0d7eccf139..db3ac75fab3069 100644 --- a/packages/vite/CHANGELOG.md +++ b/packages/vite/CHANGELOG.md @@ -1,3 +1,40 @@ +# [2.8.0-beta.0](https://github.com/vitejs/vite/compare/v2.7.9...v2.8.0-beta.0) (2022-01-05) + + +### Bug Fixes + +* **build:** fix chokidar.ignore override ([#6317](https://github.com/vitejs/vite/issues/6317)) ([aa47549](https://github.com/vitejs/vite/commit/aa475494c61898638a592387ac907a939f1dd938)) +* **build:** fix watch crash with inline module ([#6373](https://github.com/vitejs/vite/issues/6373)) ([49d2f6d](https://github.com/vitejs/vite/commit/49d2f6dbd9445518b022f6c75ca397460a02d9d8)) +* check if e.stack exists in the first place ([#6362](https://github.com/vitejs/vite/issues/6362)) ([f144aa9](https://github.com/vitejs/vite/commit/f144aa9f1df2134dc6695db6e8eff25cac2b5263)) +* correct ssr flag in resolve calls (fix [#6213](https://github.com/vitejs/vite/issues/6213)) ([#6216](https://github.com/vitejs/vite/issues/6216)) ([6dd7d1a](https://github.com/vitejs/vite/commit/6dd7d1a7cb99737dd48e070607d0fe9ece35adab)) +* **css:** no emit assets in html style tag (fix [#5968](https://github.com/vitejs/vite/issues/5968)) ([#6321](https://github.com/vitejs/vite/issues/6321)) ([dc9fce1](https://github.com/vitejs/vite/commit/dc9fce144a957a5e7b3612b27bc657121a882edc)) +* don't force terser on non-legacy (fix [#6266](https://github.com/vitejs/vite/issues/6266)) ([#6272](https://github.com/vitejs/vite/issues/6272)) ([1da104e](https://github.com/vitejs/vite/commit/1da104e8597e2965313e8cd582d032bca551e4ee)) +* prevent dev server crashing on malformed URI (fix [#6300](https://github.com/vitejs/vite/issues/6300)) ([#6308](https://github.com/vitejs/vite/issues/6308)) ([a49d723](https://github.com/vitejs/vite/commit/a49d72358f2d028f62b0e9fcdb096a0e5ddf24c3)) +* replace chalk with picocolors ([#6277](https://github.com/vitejs/vite/issues/6277)) ([5a111ce](https://github.com/vitejs/vite/commit/5a111cedf31f579e3b8c8af5c4442d2e0cd5aa12)) +* replace execa with cross-spawn ([#6299](https://github.com/vitejs/vite/issues/6299)) ([f68ed8b](https://github.com/vitejs/vite/commit/f68ed8b4ebbec01491d069164b28a5948537f0d7)) +* **ssr:** move `vite:ssr-require-hook` after user plugins ([#6306](https://github.com/vitejs/vite/issues/6306)) ([d856c4b](https://github.com/vitejs/vite/commit/d856c4bd6798707e0cbdfc127a2e8b6c00c65dae)) +* strip NULL_BYTE_PLACEHOLDER before transform ([#6390](https://github.com/vitejs/vite/issues/6390)) ([5964949](https://github.com/vitejs/vite/commit/596494948a6e2f697232371b200c2d7a51d386bc)) +* strip query when resolving entry ([#6233](https://github.com/vitejs/vite/issues/6233)) ([000ba2e](https://github.com/vitejs/vite/commit/000ba2e00b14e6c595febfa6dcae862e2d341823)) +* this._implicitHeader is not a function ([#6313](https://github.com/vitejs/vite/issues/6313)) ([c5ba2f2](https://github.com/vitejs/vite/commit/c5ba2f24bd48b88907a1505bdf0a83d6b09f1d2b)) +* upgrade postcss-modules ([#6248](https://github.com/vitejs/vite/issues/6248)) ([ac3f434](https://github.com/vitejs/vite/commit/ac3f434b8b7bc827fd76a28989f8c3ebaa999ee9)) +* use `hires: true` for SSR require hook source map ([#6310](https://github.com/vitejs/vite/issues/6310)) ([0ebeb98](https://github.com/vitejs/vite/commit/0ebeb981789e6c29889db03fc11fd9b80c63883f)) + + +### Features + +* catch postcss error messages ([#6293](https://github.com/vitejs/vite/issues/6293)) ([4d75b2e](https://github.com/vitejs/vite/commit/4d75b2e39d4decd1294f62333bdae4ba577bf1cb)) +* **define:** prevent assignment ([#5515](https://github.com/vitejs/vite/issues/5515)) ([6d4ee18](https://github.com/vitejs/vite/commit/6d4ee18e0c45e7c1fedd36c24b631a8f97f40c0f)) +* import.meta.glob support ?raw ([#5545](https://github.com/vitejs/vite/issues/5545)) ([5279de6](https://github.com/vitejs/vite/commit/5279de6859df61b6191a4c3bfc76da582309a5ec)) +* option to disable pre-transform ([#6309](https://github.com/vitejs/vite/issues/6309)) ([2c14525](https://github.com/vitejs/vite/commit/2c145252b7870e8173886339b69f189878533839)) +* **server:** support headers configurable ([#5580](https://github.com/vitejs/vite/issues/5580)) ([db36e81](https://github.com/vitejs/vite/commit/db36e8158e06ff6a383d03b9680aafc7f62d5033)) +* **server:** trace `error.loc` back to original source ([#5467](https://github.com/vitejs/vite/issues/5467)) ([65cd44d](https://github.com/vitejs/vite/commit/65cd44dcabbf213b24d68cf02d787e7b9e138c21)) +* **ssr:** support preload dynamic css file in html head ([#5705](https://github.com/vitejs/vite/issues/5705)) ([07fca95](https://github.com/vitejs/vite/commit/07fca955519a98e19d4e138a17e19a000eef3f46)) +* support .cjs config file ([#5602](https://github.com/vitejs/vite/issues/5602)) ([cddd986](https://github.com/vitejs/vite/commit/cddd986b2a3c61afd53d6fde88f9f28d3c3a6b00)) +* **vite:** pass mode to preview command ([#6392](https://github.com/vitejs/vite/issues/6392)) ([1ff1103](https://github.com/vitejs/vite/commit/1ff1103ade691b0a3f564609fdc4e76d5122227b)) +* **worker:** support worker format, plugins and rollupOptions (fix [#6191](https://github.com/vitejs/vite/issues/6191)) ([#6351](https://github.com/vitejs/vite/issues/6351)) ([133fcea](https://github.com/vitejs/vite/commit/133fcea5223263b0ae08ac9a0422b55183ebd266)) + + + ## [2.7.9](https://github.com/vitejs/vite/compare/v2.7.8...v2.7.9) (2021-12-28) diff --git a/packages/vite/package.json b/packages/vite/package.json index 4c5960789353d0..44bfeb793c35ae 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -1,6 +1,6 @@ { "name": "vite", - "version": "2.7.9", + "version": "2.8.0-beta.0", "license": "MIT", "author": "Evan You", "description": "Native-ESM powered web dev build tool", From eb9b374e0f4c9dd1939a9d16ac5d252868b9001b Mon Sep 17 00:00:00 2001 From: Jeff Yang <32727188+ydcjeff@users.noreply.github.com> Date: Wed, 5 Jan 2022 20:48:11 +0630 Subject: [PATCH 020/174] workflow: switch to simple-git-hooks (#6219) --- package.json | 10 ++-- pnpm-lock.yaml | 116 ++++------------------------------------ scripts/verifyCommit.ts | 5 +- 3 files changed, 17 insertions(+), 114 deletions(-) diff --git a/package.json b/package.json index 6c5eb872addfee..732cd385fc1039 100644 --- a/package.json +++ b/package.json @@ -52,17 +52,17 @@ "rimraf": "^3.0.2", "rollup": "^2.59.0", "semver": "^7.3.5", + "simple-git-hooks": "^2.7.0", "sirv": "^2.0.0", "ts-jest": "^27.1.2", "ts-node": "^10.4.0", "typescript": "~4.5.4", "vite": "workspace:*", - "vitepress": "^0.20.10", - "yorkie": "^2.0.0" + "vitepress": "^0.20.10" }, - "gitHooks": { - "pre-commit": "lint-staged --concurrent false", - "commit-msg": "ts-node scripts/verifyCommit.ts" + "simple-git-hooks": { + "pre-commit": "pnpm exec lint-staged --concurrent false", + "commit-msg": "pnpm exec ts-node scripts/verifyCommit.ts $1" }, "lint-staged": { "*": [ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1d99bd1eb3919c..7dd7112fbc785c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -36,13 +36,13 @@ importers: rimraf: ^3.0.2 rollup: ^2.59.0 semver: ^7.3.5 + simple-git-hooks: ^2.7.0 sirv: ^2.0.0 ts-jest: ^27.1.2 ts-node: ^10.4.0 typescript: ~4.5.4 vite: workspace:* vitepress: ^0.20.10 - yorkie: ^2.0.0 devDependencies: '@microsoft/api-extractor': 7.19.3 '@types/fs-extra': 9.0.13 @@ -72,13 +72,13 @@ importers: rimraf: 3.0.2 rollup: 2.62.0 semver: 7.3.5 + simple-git-hooks: 2.7.0 sirv: 2.0.0 ts-jest: 27.1.2_1b5a1be2010a86e622f02a11eaeb730f ts-node: 10.4.0_00264fd83560919cd06c986889baae0a typescript: 4.5.4 vite: link:packages/vite vitepress: 0.20.10 - yorkie: 2.0.0 packages/create-vite: specifiers: @@ -3083,10 +3083,6 @@ packages: engines: {node: '>=10'} dev: false - /ci-info/1.6.0: - resolution: {integrity: sha512-vsGdkwSCDpWmP80ncATX7iea5DWQemg1UgCW5J8tqjU3lYw4FBYuj89J0CTVomA7BEfvSZd84GmHko+MxFQU2A==} - dev: true - /ci-info/3.3.0: resolution: {integrity: sha512-riT/3vI5YpVH6/qomlDnJow6TBee2PBKSEpx3O32EGPYbWGIRsIlGRms3Sm74wYE1JMo8RnO04Hb12+v1J5ICw==} dev: true @@ -3226,6 +3222,7 @@ packages: /commander/2.20.3: resolution: {integrity: sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==} + requiresBuild: true dev: true /commander/7.2.0: @@ -3544,16 +3541,6 @@ packages: resolution: {integrity: sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==} dev: true - /create-vite/2.7.2: - resolution: {integrity: sha512-4Eint1oL6GcZWGkgLbSmbzY1UNTkqQyjD9T4aM1YQsltKQ5ZNWDy+rvgYRPV9dR0XD6eLPs8TUUoge1xQCd4BA==} - engines: {node: '>=12.0.0'} - hasBin: true - dependencies: - kolorist: 1.5.0 - minimist: 1.2.5 - prompts: 2.4.2 - dev: false - /cross-env/7.0.3: resolution: {integrity: sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==} engines: {node: '>=10.14', npm: '>=6', yarn: '>=1'} @@ -3562,14 +3549,6 @@ packages: cross-spawn: 7.0.3 dev: true - /cross-spawn/5.1.0: - resolution: {integrity: sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=} - dependencies: - lru-cache: 4.1.5 - shebang-command: 1.2.0 - which: 1.3.1 - dev: true - /cross-spawn/6.0.5: resolution: {integrity: sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==} engines: {node: '>=4.8'} @@ -4371,19 +4350,6 @@ packages: resolution: {integrity: sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==} dev: true - /execa/0.8.0: - resolution: {integrity: sha1-2NdrvBtVIX7RkP1t1J08d07PyNo=} - engines: {node: '>=4'} - dependencies: - cross-spawn: 5.1.0 - get-stream: 3.0.0 - is-stream: 1.1.0 - npm-run-path: 2.0.2 - p-finally: 1.0.0 - signal-exit: 3.0.6 - strip-eof: 1.0.0 - dev: true - /execa/5.1.1: resolution: {integrity: sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==} engines: {node: '>=10'} @@ -4702,11 +4668,6 @@ packages: yargs: 16.2.0 dev: true - /get-stream/3.0.0: - resolution: {integrity: sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=} - engines: {node: '>=4'} - dev: true - /get-stream/5.2.0: resolution: {integrity: sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==} engines: {node: '>=8'} @@ -5154,13 +5115,6 @@ packages: engines: {node: '>= 0.4'} dev: true - /is-ci/1.2.1: - resolution: {integrity: sha512-s6tfsaQaQi3JNciBH6shVqEDvhGut0SUXr31ag8Pd8BBbVVlcGfWhpPmEOoM6RJ5TFhbypvf5yyRw/VXW1IiWg==} - hasBin: true - dependencies: - ci-info: 1.6.0 - dev: true - /is-color-stop/1.1.0: resolution: {integrity: sha1-z/9HGu5N1cnhWFmPvhKWe1za00U=} dependencies: @@ -5277,11 +5231,6 @@ packages: resolution: {integrity: sha512-IU0NmyknYZN0rChcKhRO1X8LYz5Isj/Fsqh8NJOSf+N/hCOTwy29F32Ik7a+QszE63IdvmwdTPDd6cZ5pg4cwA==} dev: true - /is-stream/1.1.0: - resolution: {integrity: sha1-EtSj3U5o4Lec6428hBc66A2RykQ=} - engines: {node: '>=0.10.0'} - dev: true - /is-stream/2.0.1: resolution: {integrity: sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==} engines: {node: '>=8'} @@ -6212,13 +6161,6 @@ packages: js-tokens: 4.0.0 dev: false - /lru-cache/4.1.5: - resolution: {integrity: sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==} - dependencies: - pseudomap: 1.0.2 - yallist: 2.1.2 - dev: true - /lru-cache/6.0.0: resolution: {integrity: sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==} engines: {node: '>=10'} @@ -6587,11 +6529,6 @@ packages: validate-npm-package-license: 3.0.4 dev: true - /normalize-path/1.0.0: - resolution: {integrity: sha1-MtDkcvkf80VwHBWoMRAY07CpA3k=} - engines: {node: '>=0.10.0'} - dev: true - /normalize-path/3.0.0: resolution: {integrity: sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==} engines: {node: '>=0.10.0'} @@ -6621,13 +6558,6 @@ packages: string.prototype.padend: 3.1.3 dev: true - /npm-run-path/2.0.2: - resolution: {integrity: sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=} - engines: {node: '>=4'} - dependencies: - path-key: 2.0.1 - dev: true - /npm-run-path/4.0.1: resolution: {integrity: sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==} engines: {node: '>=8'} @@ -6743,11 +6673,6 @@ packages: word-wrap: 1.2.3 dev: true - /p-finally/1.0.0: - resolution: {integrity: sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=} - engines: {node: '>=4'} - dev: true - /p-limit/1.3.0: resolution: {integrity: sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==} engines: {node: '>=4'} @@ -7204,10 +7129,6 @@ packages: dev: true optional: true - /pseudomap/1.0.2: - resolution: {integrity: sha1-8FKijacOYYkX7wqKw0wa5aaChrM=} - dev: true - /psl/1.8.0: resolution: {integrity: sha512-RIdOzyoavK+hA18OGGWDqUTsCLhtA7IcZ/6NCs4fFJaHBDab+pDDmDIByWFRQJq2Cd7r1OoQxBGKOaztq+hjIQ==} dev: true @@ -7835,6 +7756,12 @@ packages: /signal-exit/3.0.6: resolution: {integrity: sha512-sDl4qMFpijcGw22U5w63KmD3cZJfBuFlVNbVMKje2keoKML7X2UzWbc4XrmEbDwg0NXJc3yv4/ox7b+JWb57kQ==} + /simple-git-hooks/2.7.0: + resolution: {integrity: sha512-nQe6ASMO9zn5/htIrU37xEIHGr9E6wikXelLbOeTcfsX2O++DHaVug7RSQoq+kO7DvZTH37WA5gW49hN9HTDmQ==} + hasBin: true + requiresBuild: true + dev: true + /simple-swizzle/0.2.2: resolution: {integrity: sha1-pNprY1/8zMoz9w0Xy5JZLeleVXo=} dependencies: @@ -8127,21 +8054,11 @@ packages: engines: {node: '>=8'} dev: true - /strip-eof/1.0.0: - resolution: {integrity: sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=} - engines: {node: '>=0.10.0'} - dev: true - /strip-final-newline/2.0.0: resolution: {integrity: sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==} engines: {node: '>=6'} dev: true - /strip-indent/2.0.0: - resolution: {integrity: sha1-XvjbKV0B5u1sv3qrlpmNeCJSe2g=} - engines: {node: '>=4'} - dev: true - /strip-indent/3.0.0: resolution: {integrity: sha512-laJTa3Jb+VQpaC6DseHhF7dXVqHTfJPCRDaEbid/drOhgitgYku/letMUqOXFoWV0zIIUbjpdH2t+tYj4bQMRQ==} engines: {node: '>=8'} @@ -8993,10 +8910,6 @@ packages: engines: {node: '>=10'} dev: true - /yallist/2.1.2: - resolution: {integrity: sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=} - dev: true - /yallist/4.0.0: resolution: {integrity: sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==} @@ -9040,17 +8953,6 @@ packages: engines: {node: '>=6'} dev: true - /yorkie/2.0.0: - resolution: {integrity: sha512-jcKpkthap6x63MB4TxwCyuIGkV0oYP/YRyuQU5UO0Yz/E/ZAu+653/uov+phdmO54n6BcvFRyyt0RRrWdN2mpw==} - engines: {node: '>=4'} - requiresBuild: true - dependencies: - execa: 0.8.0 - is-ci: 1.2.1 - normalize-path: 1.0.0 - strip-indent: 2.0.0 - dev: true - /youch/2.2.2: resolution: {integrity: sha512-/FaCeG3GkuJwaMR34GHVg0l8jCbafZLHiFowSjqLlqhC6OMyf2tPJBu8UirF7/NI9X/R5ai4QfEKUCOxMAGxZQ==} dependencies: diff --git a/scripts/verifyCommit.ts b/scripts/verifyCommit.ts index 47ec89c2d1c9e1..e433e3aa1aa3e5 100644 --- a/scripts/verifyCommit.ts +++ b/scripts/verifyCommit.ts @@ -1,9 +1,10 @@ -// Invoked on the commit-msg git hook by yorkie. +// Invoked on the commit-msg git hook by simple-git-hooks. import colors from 'picocolors' import { readFileSync } from 'fs' -const msgPath = process.env.GIT_PARAMS! +// get $1 from commit-msg script +const msgPath = process.argv[2] const msg = readFileSync(msgPath, 'utf-8').trim() const releaseRE = /^v\d/ From a34561490b4b866d8d4f98c697435dcb68a5c3ed Mon Sep 17 00:00:00 2001 From: poyoho <907415276@qq.com> Date: Thu, 6 Jan 2022 16:40:35 +0800 Subject: [PATCH 021/174] feat: new Worker can bundle URL('path', import.meta.url) script (fix #5979) (#6356) --- .../worker/__tests__/worker.spec.ts | 16 +++- packages/playground/worker/index.html | 39 +++++++- packages/playground/worker/newUrl/module.js | 1 + .../worker/newUrl/url-shared-worker.js | 6 ++ .../playground/worker/newUrl/url-worker.js | 3 + packages/vite/src/node/config.ts | 33 ++++++- packages/vite/src/node/plugins/index.ts | 2 + packages/vite/src/node/plugins/worker.ts | 71 +++++++------- .../src/node/plugins/workerImportMetaUrl.ts | 96 +++++++++++++++++++ 9 files changed, 221 insertions(+), 46 deletions(-) create mode 100644 packages/playground/worker/newUrl/module.js create mode 100644 packages/playground/worker/newUrl/url-shared-worker.js create mode 100644 packages/playground/worker/newUrl/url-worker.js create mode 100644 packages/vite/src/node/plugins/workerImportMetaUrl.ts diff --git a/packages/playground/worker/__tests__/worker.spec.ts b/packages/playground/worker/__tests__/worker.spec.ts index 21e1a47141d637..5992a37f933f2a 100644 --- a/packages/playground/worker/__tests__/worker.spec.ts +++ b/packages/playground/worker/__tests__/worker.spec.ts @@ -52,11 +52,11 @@ test.concurrent.each([[true], [false]])('shared worker', async (doTick) => { }) if (isBuild) { + const assetsDir = path.resolve(testDir, 'dist/assets') // assert correct files test('inlined code generation', async () => { - const assetsDir = path.resolve(testDir, 'dist/assets') const files = fs.readdirSync(assetsDir) - expect(files.length).toBe(4) + expect(files.length).toBe(6) const index = files.find((f) => f.includes('index')) const content = fs.readFileSync(path.resolve(assetsDir, index), 'utf-8') const worker = files.find((f) => f.includes('my-worker')) @@ -75,4 +75,16 @@ if (isBuild) { expect(content).toMatch(`(window.URL||window.webkitURL).createObjectURL`) expect(content).toMatch(`window.Blob`) }) + + test('worker need bundle', () => { + fs.readdirSync(assetsDir) + .filter( + (file) => + file.includes('url-worker') || file.includes('url-shared-worker') + ) + .forEach((file) => { + const content = fs.readFileSync(path.resolve(assetsDir, file), 'utf-8') + expect(content.startsWith('(function(){')).toBe(true) + }) + }) } diff --git a/packages/playground/worker/index.html b/packages/playground/worker/index.html index a075134df175e5..be0b3becb5f94f 100644 --- a/packages/playground/worker/index.html +++ b/packages/playground/worker/index.html @@ -20,16 +20,22 @@ 0 +

new Worker(new Url('path', import.meta.url))

+
+ +

new SharedWorker(new Url('path', import.meta.url))

+
+ diff --git a/packages/playground/worker/newUrl/module.js b/packages/playground/worker/newUrl/module.js new file mode 100644 index 00000000000000..8b84d26d5c74f3 --- /dev/null +++ b/packages/playground/worker/newUrl/module.js @@ -0,0 +1 @@ +export default 'A string' diff --git a/packages/playground/worker/newUrl/url-shared-worker.js b/packages/playground/worker/newUrl/url-shared-worker.js new file mode 100644 index 00000000000000..f52de169243056 --- /dev/null +++ b/packages/playground/worker/newUrl/url-shared-worker.js @@ -0,0 +1,6 @@ +import constant from './module' + +self.onconnect = (event) => { + const port = event.ports[0] + port.postMessage(constant) +} diff --git a/packages/playground/worker/newUrl/url-worker.js b/packages/playground/worker/newUrl/url-worker.js new file mode 100644 index 00000000000000..afd91bfe613dc2 --- /dev/null +++ b/packages/playground/worker/newUrl/url-worker.js @@ -0,0 +1,3 @@ +import constant from './module' + +self.postMessage(constant) diff --git a/packages/vite/src/node/config.ts b/packages/vite/src/node/config.ts index 1996e0fd8b8491..68f7e99ddac045 100644 --- a/packages/vite/src/node/config.ts +++ b/packages/vite/src/node/config.ts @@ -222,6 +222,12 @@ export interface SSROptions { target?: SSRTarget } +export interface ResolveWorkerOptions { + format: 'es' | 'iife' + plugins: Plugin[] + rollupOptions: RollupOptions +} + export interface InlineConfig extends UserConfig { configFile?: string | false envFile?: false @@ -230,7 +236,7 @@ export interface InlineConfig extends UserConfig { export type ResolvedConfig = Readonly< Omit< UserConfig, - 'plugins' | 'alias' | 'dedupe' | 'assetsInclude' | 'optimizeDeps' + 'plugins' | 'alias' | 'dedupe' | 'assetsInclude' | 'optimizeDeps' | 'worker' > & { configFile: string | undefined configFileDependencies: string[] @@ -255,6 +261,7 @@ export type ResolvedConfig = Readonly< optimizeDeps: Omit /** @internal */ packageCache: PackageCache + worker: ResolveWorkerOptions } > @@ -326,6 +333,13 @@ export async function resolveConfig( const [prePlugins, normalPlugins, postPlugins] = sortUserPlugins(rawUserPlugins) + // resolve worker + const resolvedWorkerOptions: ResolveWorkerOptions = { + format: config.worker?.format || 'iife', + plugins: [], + rollupOptions: config.worker?.rollupOptions || {} + } + // run config hooks const userPlugins = [...prePlugins, ...normalPlugins, ...postPlugins] for (const p of userPlugins) { @@ -487,9 +501,24 @@ export async function resolveConfig( preserveSymlinks: config.resolve?.preserveSymlinks, ...config.optimizeDeps?.esbuildOptions } - } + }, + worker: resolvedWorkerOptions } + // flat config.worker.plugin + const [workerPrePlugins, workerNormalPlugins, workerPostPlugins] = + sortUserPlugins(config.worker?.plugins as Plugin[]) + const workerResolved = { ...resolved } + resolved.worker.plugins = await resolvePlugins( + workerResolved, + workerPrePlugins, + workerNormalPlugins, + workerPostPlugins + ) + // call configResolved worker plugins hooks + await Promise.all( + resolved.worker.plugins.map((p) => p.configResolved?.(workerResolved)) + ) ;(resolved.plugins as Plugin[]) = await resolvePlugins( resolved, prePlugins, diff --git a/packages/vite/src/node/plugins/index.ts b/packages/vite/src/node/plugins/index.ts index fccdfb449b7ffe..e4f3d453527af3 100644 --- a/packages/vite/src/node/plugins/index.ts +++ b/packages/vite/src/node/plugins/index.ts @@ -15,6 +15,7 @@ import { webWorkerPlugin } from './worker' import { preAliasPlugin } from './preAlias' import { definePlugin } from './define' import { ssrRequireHookPlugin } from './ssrRequireHook' +import { workerImportMetaUrlPlugin } from './workerImportMetaUrl' export async function resolvePlugins( config: ResolvedConfig, @@ -56,6 +57,7 @@ export async function resolvePlugins( ), wasmPlugin(config), webWorkerPlugin(config), + workerImportMetaUrlPlugin(config), assetPlugin(config), ...normalPlugins, definePlugin(config), diff --git a/packages/vite/src/node/plugins/worker.ts b/packages/vite/src/node/plugins/worker.ts index dc9a55ce6ff55d..5ce0936748ea05 100644 --- a/packages/vite/src/node/plugins/worker.ts +++ b/packages/vite/src/node/plugins/worker.ts @@ -1,5 +1,4 @@ import type { ResolvedConfig } from '../config' -import { sortUserPlugins } from '../config' import type { Plugin } from '../plugin' import { fileToUrl, getAssetHash } from './asset' import { cleanUrl, injectQuery, parseRequest } from '../utils' @@ -7,17 +6,40 @@ import type Rollup from 'rollup' import { ENV_PUBLIC_PATH } from '../constants' import path from 'path' import { onRollupWarning } from '../build' -import { resolvePlugins } from '.' const WorkerFileId = 'worker_file' +export async function bundleWorkerEntry( + config: ResolvedConfig, + id: string +): Promise { + // bundle the file as entry to support imports + const rollup = require('rollup') as typeof Rollup + const { plugins, rollupOptions, format } = config.worker + const bundle = await rollup.rollup({ + ...rollupOptions, + input: cleanUrl(id), + plugins, + onwarn(warning, warn) { + onRollupWarning(warning, warn, config) + }, + preserveEntrySignatures: false + }) + let code: string + try { + const { output } = await bundle.generate({ + format, + sourcemap: config.build.sourcemap + }) + code = output[0].code + } finally { + await bundle.close() + } + return Buffer.from(code) +} + export function webWorkerPlugin(config: ResolvedConfig): Plugin { const isBuild = config.command === 'build' - const workerBundleOptions = { - format: config.worker?.format || 'iife', - plugins: sortUserPlugins(config.worker?.plugins as Plugin[]), - rollupOptions: config.worker?.rollupOptions || {} - } return { name: 'vite:worker', @@ -50,39 +72,12 @@ export function webWorkerPlugin(config: ResolvedConfig): Plugin { let url: string if (isBuild) { - // bundle the file as entry to support imports - const rollup = require('rollup') as typeof Rollup - const { plugins, rollupOptions, format } = workerBundleOptions - const [prePlugins, normalPlugins, postPlugins] = plugins - const bundle = await rollup.rollup({ - ...rollupOptions, - input: cleanUrl(id), - plugins: await resolvePlugins( - { ...config }, - prePlugins, - normalPlugins, - postPlugins - ), - onwarn(warning, warn) { - onRollupWarning(warning, warn, config) - }, - preserveEntrySignatures: false - }) - let code: string - try { - const { output } = await bundle.generate({ - format, - sourcemap: config.build.sourcemap - }) - code = output[0].code - } finally { - await bundle.close() - } - const content = Buffer.from(code) + const code = await bundleWorkerEntry(config, id) if (query.inline != null) { + const { format } = config.worker const workerOptions = format === 'es' ? '{type: "module"}' : '{}' // inline as blob data url - return `const encodedJs = "${content.toString('base64')}"; + return `const encodedJs = "${code.toString('base64')}"; const blob = typeof window !== "undefined" && window.Blob && new Blob([atob(encodedJs)], { type: "text/javascript;charset=utf-8" }); export default function WorkerWrapper() { const objURL = blob && (window.URL || window.webkitURL).createObjectURL(blob); @@ -94,7 +89,7 @@ export function webWorkerPlugin(config: ResolvedConfig): Plugin { }` } else { const basename = path.parse(cleanUrl(id)).name - const contentHash = getAssetHash(content) + const contentHash = getAssetHash(code) const fileName = path.posix.join( config.build.assetsDir, `${basename}.${contentHash}.js` diff --git a/packages/vite/src/node/plugins/workerImportMetaUrl.ts b/packages/vite/src/node/plugins/workerImportMetaUrl.ts new file mode 100644 index 00000000000000..13c0ef2bb3883b --- /dev/null +++ b/packages/vite/src/node/plugins/workerImportMetaUrl.ts @@ -0,0 +1,96 @@ +import type { ResolvedConfig } from '../config' +import type { Plugin } from '../plugin' +import { getAssetHash, fileToUrl } from './asset' +import { + cleanUrl, + injectQuery, + multilineCommentsRE, + singlelineCommentsRE +} from '../utils' +import path from 'path' +import { bundleWorkerEntry } from './worker' +import { parseRequest } from '../utils' +import { ENV_PUBLIC_PATH } from '../constants' +import MagicString from 'magic-string' + +const WORKER_FILE_ID = 'worker_url_file' + +export function workerImportMetaUrlPlugin(config: ResolvedConfig): Plugin { + const isBuild = config.command === 'build' + + return { + name: 'vite:worker-import-meta-url', + + async transform(code, id, options) { + const query = parseRequest(id) + if (query && query[WORKER_FILE_ID] != null) { + return { + code: `import '${ENV_PUBLIC_PATH}'\n` + code + } + } + if ( + (code.includes('new Worker') || code.includes('new ShareWorker')) && + code.includes('new URL') && + code.includes(`import.meta.url`) + ) { + const importMetaUrlRE = + /\bnew\s+(Worker|SharedWorker)\s*\(\s*(new\s+URL\s*\(\s*('[^']+'|"[^"]+"|`[^`]+`)\s*,\s*import\.meta\.url\s*\))/g + const noCommentsCode = code + .replace(multilineCommentsRE, (m) => ' '.repeat(m.length)) + .replace(singlelineCommentsRE, (m) => ' '.repeat(m.length)) + let match: RegExpExecArray | null + let s: MagicString | null = null + while ((match = importMetaUrlRE.exec(noCommentsCode))) { + const { 0: allExp, 2: exp, 3: rawUrl, index } = match + + const urlIndex = allExp.indexOf(exp) + index + + if (options?.ssr) { + this.error( + `\`new URL(url, import.meta.url)\` is not supported in SSR.`, + urlIndex + ) + } + + // potential dynamic template string + if (rawUrl[0] === '`' && /\$\{/.test(rawUrl)) { + this.error( + `\`new URL(url, import.meta.url)\` is not supported in dynamic template string.`, + urlIndex + ) + } + + s ||= new MagicString(code) + + const file = path.resolve(path.dirname(id), rawUrl.slice(1, -1)) + let url: string + if (isBuild) { + const content = await bundleWorkerEntry(config, file) + const basename = path.parse(cleanUrl(file)).name + const contentHash = getAssetHash(content) + const fileName = path.posix.join( + config.build.assetsDir, + `${basename}.${contentHash}.js` + ) + url = `__VITE_ASSET__${this.emitFile({ + fileName, + type: 'asset', + source: content + })}__` + } else { + url = await fileToUrl(cleanUrl(file), config, this) + url = injectQuery(url, WORKER_FILE_ID) + } + s.overwrite(urlIndex, urlIndex + exp.length, JSON.stringify(url)) + } + if (s) { + return { + code: s.toString(), + map: config.build.sourcemap ? s.generateMap({ hires: true }) : null + } + } + return null + } + } + } +} From bd4c3a5dcbb20da5cfd93daf38932bccb45a7742 Mon Sep 17 00:00:00 2001 From: patak-dev Date: Thu, 6 Jan 2022 10:45:20 +0100 Subject: [PATCH 022/174] release: v2.8.0-beta.1 --- packages/vite/CHANGELOG.md | 9 +++++++++ packages/vite/package.json | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/vite/CHANGELOG.md b/packages/vite/CHANGELOG.md index db3ac75fab3069..9f35b77c65c961 100644 --- a/packages/vite/CHANGELOG.md +++ b/packages/vite/CHANGELOG.md @@ -1,3 +1,12 @@ +# [2.8.0-beta.1](https://github.com/vitejs/vite/compare/v2.8.0-beta.0...v2.8.0-beta.1) (2022-01-06) + + +### Features + +* new Worker can bundle URL('path', import.meta.url) script (fix [#5979](https://github.com/vitejs/vite/issues/5979)) ([#6356](https://github.com/vitejs/vite/issues/6356)) ([a345614](https://github.com/vitejs/vite/commit/a34561490b4b866d8d4f98c697435dcb68a5c3ed)) + + + # [2.8.0-beta.0](https://github.com/vitejs/vite/compare/v2.7.9...v2.8.0-beta.0) (2022-01-05) diff --git a/packages/vite/package.json b/packages/vite/package.json index 44bfeb793c35ae..eff26ff2eed88b 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -1,6 +1,6 @@ { "name": "vite", - "version": "2.8.0-beta.0", + "version": "2.8.0-beta.1", "license": "MIT", "author": "Evan You", "description": "Native-ESM powered web dev build tool", From 647168b2b44b82b1a1cbd8e639f74ddf52a5d5cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arnaud=20Barr=C3=A9?= Date: Fri, 7 Jan 2022 17:24:44 +0100 Subject: [PATCH 023/174] fix: use cacheDir for resolveHttpsConfig (#6416) --- packages/vite/src/node/http.ts | 4 ++-- packages/vite/src/node/server/index.ts | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/vite/src/node/http.ts b/packages/vite/src/node/http.ts index 28be35c276c6c8..becc2191efac7f 100644 --- a/packages/vite/src/node/http.ts +++ b/packages/vite/src/node/http.ts @@ -121,8 +121,8 @@ export async function resolveHttpServer( } export async function resolveHttpsConfig( - https?: boolean | HttpsServerOptions, - cacheDir?: string + https: boolean | HttpsServerOptions | undefined, + cacheDir: string | undefined ): Promise { if (!https) return undefined diff --git a/packages/vite/src/node/server/index.ts b/packages/vite/src/node/server/index.ts index 61bda062268d52..edd7f43f84f8b0 100644 --- a/packages/vite/src/node/server/index.ts +++ b/packages/vite/src/node/server/index.ts @@ -303,7 +303,10 @@ export async function createServer( const config = await resolveConfig(inlineConfig, 'serve', 'development') const root = config.root const serverConfig = config.server - const httpsOptions = await resolveHttpsConfig(config.server.https) + const httpsOptions = await resolveHttpsConfig( + config.server.https, + config.cacheDir + ) let { middlewareMode } = serverConfig if (middlewareMode === true) { middlewareMode = 'ssr' From 8fb854fd62f0edc9b1d1bab79b7d9b11cd03cf90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E9=9D=92=E5=B7=9D?= <46062972+ShenQingchuan@users.noreply.github.com> Date: Sat, 8 Jan 2022 00:49:29 +0800 Subject: [PATCH 024/174] chore: add translation contribution guide. (#6400) * chore: add translation contribution guide. * chore: some fix. * chore: update Co-authored-by: patak-dev --- CONTRIBUTING.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 891e05cff3c5e4..4d1c076df2d544 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -183,3 +183,28 @@ We already have many config options, and we should avoid fixing an issue by addi - Whether the problem can be fixed with a smarter default - Whether the problem has workaround using existing options - Whether the problem can be addressed with a plugin instead + +## Docs translation contribution + +If you would like to start a translation in your language, you are welcome to contribute! Please join [the #translations channel in Vite Land](https://chat.vitejs.dev) to discuss and coordinate with others. + +The english docs are embeded in the main Vite repo, to allow contributors to work on docs, tests and implementation in the same PR. Translations are done by forking the main repo. + +### How to start a translation repo + +1. In order to get all doc files, you first need to clone this repo in your personal account. +2. Keep all the files in `docs/` and remove everything else. + + - You should setup your translation site based on all the files in `docs/` folder as a Vitepress project. + (that said, `package.json` is need). + + - Refresh git history by removing `.git` and then `git init` + +3. Translate the docs. + + - During this stage, you may be translating documents and synchronizing updates at the same time, but don't worry about that, it's very common in translation contribution. + +4. Push your commits to your Github repo. you can setup a netlify preview as well. +5. Use [Ryu-cho](https://github.com/vuejs-translations/ryu-cho) tool to setup a Github Action, automatically track English docs update later. + +We recommend talking with others in Vite Land so you find more contributors for your language to share the maintainance work. Once the translation is done, communicate it to the Vite team so the repo can be moved to the official vitejs org in GitHub. From 4f820e59c5e28787950d415e05f057e35cbb5005 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 10 Jan 2022 09:23:12 +0100 Subject: [PATCH 025/174] chore(deps): update dependency node-forge to v1 (#6425) --- packages/vite/package.json | 2 +- pnpm-lock.yaml | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/vite/package.json b/packages/vite/package.json index eff26ff2eed88b..d48e5c33154d59 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -99,7 +99,7 @@ "magic-string": "^0.25.7", "micromatch": "^4.0.4", "mrmime": "^1.0.0", - "node-forge": "^0.10.0", + "node-forge": "^1.2.0", "okie": "^1.0.1", "open": "^8.4.0", "periscopic": "^2.0.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7dd7112fbc785c..a0336ef4b55d04 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -427,6 +427,9 @@ importers: resolve-exports-path: link:exports-path resolve-linked: link:../resolve-linked + packages/playground/resolve-config: + specifiers: {} + packages/playground/resolve-linked: specifiers: {} @@ -768,7 +771,7 @@ importers: magic-string: ^0.25.7 micromatch: ^4.0.4 mrmime: ^1.0.0 - node-forge: ^0.10.0 + node-forge: ^1.2.0 okie: ^1.0.1 open: ^8.4.0 periscopic: ^2.0.3 @@ -844,7 +847,7 @@ importers: magic-string: 0.25.7 micromatch: 4.0.4 mrmime: 1.0.0 - node-forge: 0.10.0 + node-forge: 1.2.0 okie: 1.0.1 open: 8.4.0 periscopic: 2.0.3 @@ -6495,6 +6498,11 @@ packages: engines: {node: '>= 6.0.0'} dev: true + /node-forge/1.2.0: + resolution: {integrity: sha512-M4AsdaP0bGNaSPtatd/+f76asocI0cFaURRdeQVZvrJBrYp2Qohv5hDbGHykuNqCb1BYjWHjdS6HlN50qbztwA==} + engines: {node: '>= 6.13.0'} + dev: true + /node-int64/0.4.0: resolution: {integrity: sha1-h6kGXNs1XTGC2PlM4RGIuCXGijs=} dev: true From 028cbeb34adef217f274be7c4a7dd5c9f9b12b29 Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Mon, 10 Jan 2022 03:26:07 -0500 Subject: [PATCH 026/174] fix: improve array config merging (#6344) --- .../vite/src/node/__tests__/config.spec.ts | 16 ++++++++++++ packages/vite/src/node/config.ts | 25 ++++++++++--------- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/packages/vite/src/node/__tests__/config.spec.ts b/packages/vite/src/node/__tests__/config.spec.ts index dc4452262797fc..7afd67fe792d20 100644 --- a/packages/vite/src/node/__tests__/config.spec.ts +++ b/packages/vite/src/node/__tests__/config.spec.ts @@ -46,6 +46,22 @@ describe('mergeConfig', () => { expect(mergeConfig(baseConfig, newConfig)).toEqual(mergedConfig) }) + test('handles arrays', () => { + const baseConfig: UserConfigExport = { + envPrefix: 'string1' + } + + const newConfig: UserConfigExport = { + envPrefix: ['string2', 'string3'] + } + + const mergedConfig: UserConfigExport = { + envPrefix: ['string1', 'string2', 'string3'] + } + + expect(mergeConfig(baseConfig, newConfig)).toEqual(mergedConfig) + }) + test('handles assetsInclude', () => { const baseConfig: UserConfigExport = { assetsInclude: 'some-string' diff --git a/packages/vite/src/node/config.ts b/packages/vite/src/node/config.ts index 68f7e99ddac045..931dcc885876a9 100644 --- a/packages/vite/src/node/config.ts +++ b/packages/vite/src/node/config.ts @@ -728,18 +728,6 @@ function mergeConfigRecursively( } const existing = merged[key] - if (Array.isArray(existing) && Array.isArray(value)) { - merged[key] = [...existing, ...value] - continue - } - if (isObject(existing) && isObject(value)) { - merged[key] = mergeConfigRecursively( - existing, - value, - rootPath ? `${rootPath}.${key}` : key - ) - continue - } // fields that require special handling if (existing != null) { @@ -754,6 +742,19 @@ function mergeConfigRecursively( } } + if (Array.isArray(existing) || Array.isArray(value)) { + merged[key] = [...arraify(existing), ...arraify(value)] + continue + } + if (isObject(existing) && isObject(value)) { + merged[key] = mergeConfigRecursively( + existing, + value, + rootPath ? `${rootPath}.${key}` : key + ) + continue + } + merged[key] = value } return merged From ccf7d791497139951fde58168999d44e18f706ee Mon Sep 17 00:00:00 2001 From: Oyster Lee Date: Tue, 11 Jan 2022 16:58:26 +0800 Subject: [PATCH 027/174] fix(types): add missing options parameter to importMeta (#6433) --- packages/vite/types/importMeta.d.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/vite/types/importMeta.d.ts b/packages/vite/types/importMeta.d.ts index d93fed42129c26..4ff865658cf372 100644 --- a/packages/vite/types/importMeta.d.ts +++ b/packages/vite/types/importMeta.d.ts @@ -4,6 +4,8 @@ /* eslint-disable @typescript-eslint/consistent-type-imports */ +import type { AssertOptions } from '../src/node/importGlob' + interface ImportMeta { url: string @@ -50,14 +52,20 @@ interface ImportMeta { readonly env: ImportMetaEnv - glob(pattern: string): Record< + glob( + pattern: string, + options?: AssertOptions + ): Record< string, () => Promise<{ [key: string]: any }> > - globEager(pattern: string): Record< + globEager( + pattern: string, + options?: AssertOptions + ): Record< string, { [key: string]: any From 5d7b4c31b8e44add7c192ae8af4b90b9378ae1fe Mon Sep 17 00:00:00 2001 From: Jeff Yang <32727188+ydcjeff@users.noreply.github.com> Date: Tue, 11 Jan 2022 21:11:30 +0630 Subject: [PATCH 028/174] fix(types): dynamic import in import.meta (#6456) ref #6433 --- packages/vite/types/importMeta.d.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/vite/types/importMeta.d.ts b/packages/vite/types/importMeta.d.ts index 4ff865658cf372..2a8e319738ef56 100644 --- a/packages/vite/types/importMeta.d.ts +++ b/packages/vite/types/importMeta.d.ts @@ -4,8 +4,6 @@ /* eslint-disable @typescript-eslint/consistent-type-imports */ -import type { AssertOptions } from '../src/node/importGlob' - interface ImportMeta { url: string @@ -54,7 +52,7 @@ interface ImportMeta { glob( pattern: string, - options?: AssertOptions + options?: import('../src/node/importGlob').AssertOptions ): Record< string, () => Promise<{ @@ -64,7 +62,7 @@ interface ImportMeta { globEager( pattern: string, - options?: AssertOptions + options?: import('../src/node/importGlob').AssertOptions ): Record< string, { From 7541a8d570d9bbf0ab0cd4264cae985dddaf3189 Mon Sep 17 00:00:00 2001 From: Daniel Imfeld Date: Tue, 11 Jan 2022 11:57:31 -1000 Subject: [PATCH 029/174] fix: only run build-html plugin on bundler inputs (fix #4067) (#5342) --- .../playground/html/__tests__/html.spec.ts | 19 +++++++++++++++ packages/playground/html/importAsString.html | 5 ++++ packages/playground/html/main.js | 2 ++ packages/playground/html/vite.config.js | 12 ++++++++++ packages/vite/src/node/plugins/html.ts | 23 ++++++++++++++++++- 5 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 packages/playground/html/importAsString.html diff --git a/packages/playground/html/__tests__/html.spec.ts b/packages/playground/html/__tests__/html.spec.ts index 66f537e5026361..1a663efb146977 100644 --- a/packages/playground/html/__tests__/html.spec.ts +++ b/packages/playground/html/__tests__/html.spec.ts @@ -197,6 +197,25 @@ describe('noBody', () => { }) }) +describe('importAsString', () => { + // The build-html plugin should not alter HTML that is not an input. + test('not transformed', async () => { + const messages = [] + function addConsoleMessage(message) { + messages.push(message.args()[0]) + } + + page.on('console', addConsoleMessage) + await page.goto(viteTestUrl + '/index.html') + await page.waitForLoadState() + page.off('console', addConsoleMessage) + + const result = messages.map((m) => m.toString()).join('\n') + expect(result).toMatch('Some imported HTML') + expect(result).not.toMatch('This is injected') + }) +}) + describe('unicode path', () => { test('direct access', async () => { await page.goto( diff --git a/packages/playground/html/importAsString.html b/packages/playground/html/importAsString.html new file mode 100644 index 00000000000000..a9f57d697bef91 --- /dev/null +++ b/packages/playground/html/importAsString.html @@ -0,0 +1,5 @@ + + + Some imported HTML + + diff --git a/packages/playground/html/main.js b/packages/playground/html/main.js index cd769880553ced..c44ec322c965f7 100644 --- a/packages/playground/html/main.js +++ b/packages/playground/html/main.js @@ -1,4 +1,6 @@ import { msg } from './shared' +import asString from './importAsString.html' import './common.css' console.log(msg + ' from main') +console.log('loaded string ' + asString) diff --git a/packages/playground/html/vite.config.js b/packages/playground/html/vite.config.js index 1703e02cc05366..7dc01af7d9ca79 100644 --- a/packages/playground/html/vite.config.js +++ b/packages/playground/html/vite.config.js @@ -157,6 +157,18 @@ ${ } ] } + }, + { + // Emulate rollup-plugin-string + name: 'import-as-string-module', + transform(code, id) { + if (id.endsWith('importAsString.html')) { + return { + code: `export default ${JSON.stringify(code)}`, + map: { mappings: '' } + } + } + } } ] } diff --git a/packages/vite/src/node/plugins/html.ts b/packages/vite/src/node/plugins/html.ts index 0cbad741d27738..8ddf77aac37f1d 100644 --- a/packages/vite/src/node/plugins/html.ts +++ b/packages/vite/src/node/plugins/html.ts @@ -214,11 +214,32 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin { // Same reason with `htmlInlineProxyPlugin` isAsyncScriptMap.set(config, new Map()) + const inputFiles = new Set() + return { name: 'vite:build-html', + buildStart({ input }) { + isAsyncScriptMap.set(config, new Map()) + + let allInputs: string[] + if (typeof input === 'string') { + allInputs = [input] + } else if (Array.isArray(input)) { + allInputs = input + } else { + allInputs = Object.values(input) + } + + for (const filename of allInputs) { + if (filename.endsWith('.html')) { + inputFiles.add(normalizePath(filename)) + } + } + }, + async transform(html, id) { - if (id.endsWith('.html')) { + if (inputFiles.has(id)) { const publicPath = `/${slash(path.relative(config.root, id))}` // pre-transform html = await applyHtmlTransforms(html, preHooks, { From 6408a3ab9bd97f1542982755b5044871a78b59d4 Mon Sep 17 00:00:00 2001 From: OneNail <31649110+OneNail@users.noreply.github.com> Date: Wed, 12 Jan 2022 06:08:09 +0800 Subject: [PATCH 030/174] feat: add customResolver option to resolve.alias (#5876) --- docs/config/index.md | 4 ++-- .../playground/alias/__tests__/alias.spec.ts | 6 ++++++ packages/playground/alias/customResolver.js | 1 + packages/playground/alias/index.html | 3 +++ packages/playground/alias/vite.config.js | 9 ++++++++- packages/vite/src/node/config.ts | 16 ++++++++++++++-- 6 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 packages/playground/alias/customResolver.js diff --git a/docs/config/index.md b/docs/config/index.md index 040799ce7a0a0d..5d2de719e8ccaa 100644 --- a/docs/config/index.md +++ b/docs/config/index.md @@ -174,9 +174,9 @@ export default defineConfig(async ({ command, mode }) => { ### resolve.alias - **Type:** - `Record | Array<{ find: string | RegExp, replacement: string }>` + `Record | Array<{ find: string | RegExp, replacement: string, customResolver?: ResolverFunction | ResolverObject }>` - 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. + 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, customResolver }` 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. diff --git a/packages/playground/alias/__tests__/alias.spec.ts b/packages/playground/alias/__tests__/alias.spec.ts index 5d6ab59a948a22..835dd37521bc77 100644 --- a/packages/playground/alias/__tests__/alias.spec.ts +++ b/packages/playground/alias/__tests__/alias.spec.ts @@ -43,3 +43,9 @@ test('aliased module', async () => { '[success] aliased module' ) }) + +test('custom resolver', async () => { + expect(await page.textContent('.custom-resolver')).toMatch( + '[success] alias to custom-resolver path' + ) +}) diff --git a/packages/playground/alias/customResolver.js b/packages/playground/alias/customResolver.js new file mode 100644 index 00000000000000..1a793ab006958e --- /dev/null +++ b/packages/playground/alias/customResolver.js @@ -0,0 +1 @@ +export const msg = `[success] alias to custom-resolver path` diff --git a/packages/playground/alias/index.html b/packages/playground/alias/index.html index 00a165234e3354..274e8ae635b71e 100644 --- a/packages/playground/alias/index.html +++ b/packages/playground/alias/index.html @@ -6,6 +6,7 @@

Alias

+

@@ -15,6 +16,7 @@

Alias

import { msg as regexMsg } from 'regex/test' import { msg as depMsg } from 'dep' import { msg as moduleMsg } from 'aliased-module/index.js' + import { msg as customResolverMsg } from 'custom-resolver' function text(el, text) { document.querySelector(el).textContent = text @@ -25,6 +27,7 @@

Alias

text('.regex', regexMsg + ' via regex') text('.dep', depMsg) text('.aliased-module', moduleMsg) + text('.custom-resolver', customResolverMsg) import { createApp } from 'vue' import { ref } from 'foo' diff --git a/packages/playground/alias/vite.config.js b/packages/playground/alias/vite.config.js index 34ed93051964d0..530fe86a3de2cb 100644 --- a/packages/playground/alias/vite.config.js +++ b/packages/playground/alias/vite.config.js @@ -17,7 +17,14 @@ module.exports = { // 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' } + { find: 'foo', replacement: 'vue' }, + { + find: 'custom-resolver', + replacement: path.resolve(__dirname, 'test.js'), + customResolver(id) { + return id.replace('test.js', 'customResolver.js') + } + } ] }, build: { diff --git a/packages/vite/src/node/config.ts b/packages/vite/src/node/config.ts index 931dcc885876a9..639f4e9176fda9 100644 --- a/packages/vite/src/node/config.ts +++ b/packages/vite/src/node/config.ts @@ -785,7 +785,11 @@ function normalizeAlias(o: AliasOptions): Alias[] { // https://github.com/vitejs/vite/issues/1363 // work around https://github.com/rollup/plugins/issues/759 -function normalizeSingleAlias({ find, replacement }: Alias): Alias { +function normalizeSingleAlias({ + find, + replacement, + customResolver +}: Alias): Alias { if ( typeof find === 'string' && find.endsWith('/') && @@ -794,7 +798,15 @@ function normalizeSingleAlias({ find, replacement }: Alias): Alias { find = find.slice(0, find.length - 1) replacement = replacement.slice(0, replacement.length - 1) } - return { find, replacement } + + const alias: Alias = { + find, + replacement + } + if (customResolver) { + alias.customResolver = customResolver + } + return alias } export function sortUserPlugins( From 669d7e0f4b6ea4a73d3598ab1473b58c72bf093b Mon Sep 17 00:00:00 2001 From: Fran Dios Date: Wed, 12 Jan 2022 13:37:58 +0100 Subject: [PATCH 031/174] feat: allow globs in node_modules when pattern is explicit (#6056) --- .gitignore | 1 + .../glob-import/__tests__/glob-import.spec.ts | 7 ++++ .../glob-import/dir/node_modules/hoge.js | 1 + packages/playground/glob-import/index.html | 39 ++++++++++++------- packages/vite/src/node/importGlob.ts | 3 +- 5 files changed, 36 insertions(+), 15 deletions(-) create mode 100644 packages/playground/glob-import/dir/node_modules/hoge.js diff --git a/.gitignore b/.gitignore index 6a9f8063929462..44abdd7bf563db 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .DS_Store node_modules +!**/glob-import/dir/node_modules dist dist-ssr TODOs.md diff --git a/packages/playground/glob-import/__tests__/glob-import.spec.ts b/packages/playground/glob-import/__tests__/glob-import.spec.ts index 311f94cd00571a..3a2425736548ea 100644 --- a/packages/playground/glob-import/__tests__/glob-import.spec.ts +++ b/packages/playground/glob-import/__tests__/glob-import.spec.ts @@ -45,6 +45,10 @@ const allResult = { } } +const nodeModulesResult = { + '/dir/node_modules/hoge.js': { msg: 'hoge' } +} + const rawResult = { '/dir/baz.json': { msg: 'baz' @@ -55,6 +59,9 @@ test('should work', async () => { expect(await page.textContent('.result')).toBe( JSON.stringify(allResult, null, 2) ) + expect(await page.textContent('.result-node_modules')).toBe( + JSON.stringify(nodeModulesResult, null, 2) + ) }) test('import glob raw', async () => { diff --git a/packages/playground/glob-import/dir/node_modules/hoge.js b/packages/playground/glob-import/dir/node_modules/hoge.js new file mode 100644 index 00000000000000..874eb4312f0dc5 --- /dev/null +++ b/packages/playground/glob-import/dir/node_modules/hoge.js @@ -0,0 +1 @@ +export const msg = 'hoge' diff --git a/packages/playground/glob-import/index.html b/packages/playground/glob-import/index.html index e408ec8adda602..bb5e2f3c18f752 100644 --- a/packages/playground/glob-import/index.html +++ b/packages/playground/glob-import/index.html @@ -1,8 +1,30 @@

+

 

 
 
 
 
 
 

url in style tag

url

diff --git a/packages/playground/vue-lib/src-lib/CompB.vue b/packages/playground/vue-lib/src-lib/CompB.vue new file mode 100644 index 00000000000000..cca30168fb6753 --- /dev/null +++ b/packages/playground/vue-lib/src-lib/CompB.vue @@ -0,0 +1,8 @@ + + diff --git a/packages/playground/vue-lib/src-lib/index.ts b/packages/playground/vue-lib/src-lib/index.ts new file mode 100644 index 00000000000000..f83abd4ec72118 --- /dev/null +++ b/packages/playground/vue-lib/src-lib/index.ts @@ -0,0 +1,2 @@ +export { default as CompA } from './CompA.vue' +export { default as CompB } from './CompB.vue' diff --git a/packages/playground/vue-lib/vite.config.consumer.ts b/packages/playground/vue-lib/vite.config.consumer.ts new file mode 100644 index 00000000000000..9e75b5cfbeabcb --- /dev/null +++ b/packages/playground/vue-lib/vite.config.consumer.ts @@ -0,0 +1,10 @@ +import { defineConfig } from 'vite' +import vue from '@vitejs/plugin-vue' + +export default defineConfig({ + root: __dirname, + build: { + outDir: 'dist/consumer' + }, + plugins: [vue()] +}) diff --git a/packages/playground/vue-lib/vite.config.lib.ts b/packages/playground/vue-lib/vite.config.lib.ts new file mode 100644 index 00000000000000..a888382d008a8c --- /dev/null +++ b/packages/playground/vue-lib/vite.config.lib.ts @@ -0,0 +1,23 @@ +import path from 'path' +import { defineConfig } from 'vite' +import vue from '@vitejs/plugin-vue' + +export default defineConfig({ + root: __dirname, + build: { + outDir: 'dist/lib', + lib: { + entry: path.resolve(__dirname, 'src-lib/index.ts'), + name: 'MyVueLib', + formats: ['es'], + fileName: (format) => `my-vue-lib.${format}.js` + }, + rollupOptions: { + external: ['vue'], + output: { + globals: { vue: 'Vue' } + } + } + }, + plugins: [vue()] +}) diff --git a/packages/plugin-vue/src/main.ts b/packages/plugin-vue/src/main.ts index 29c5cffa4cfa81..3df0e664748dd5 100644 --- a/packages/plugin-vue/src/main.ts +++ b/packages/plugin-vue/src/main.ts @@ -299,7 +299,7 @@ async function genStyleCode( attachedProps: [string, string][] ) { let stylesCode = `` - let hasCSSModules = false + let cssModulesMap: Record | undefined if (descriptor.styles.length) { for (let i = 0; i < descriptor.styles.length; i++) { const style = descriptor.styles[i] @@ -320,12 +320,13 @@ async function genStyleCode( ` diff --git a/packages/playground/vue/Main.vue b/packages/playground/vue/Main.vue index ea14dc8f481b86..d10ae401f7aa8e 100644 --- a/packages/playground/vue/Main.vue +++ b/packages/playground/vue/Main.vue @@ -20,7 +20,6 @@ - + + + + + + diff --git a/docs/.vitepress/theme/SponsorsSidebar.vue b/docs/.vitepress/theme/SponsorsSidebar.vue new file mode 100644 index 00000000000000..bb27c8b5ee157d --- /dev/null +++ b/docs/.vitepress/theme/SponsorsSidebar.vue @@ -0,0 +1,31 @@ + + + + + diff --git a/docs/.vitepress/theme/index.js b/docs/.vitepress/theme/index.js index 5d0a1b7a652039..babdc165f30ed8 100644 --- a/docs/.vitepress/theme/index.js +++ b/docs/.vitepress/theme/index.js @@ -1,7 +1,6 @@ import Theme from 'vitepress/theme' import { h } from 'vue' -import sponsors from './sponsors.json' -import './sponsors.css' +import SponsorsSidebar from './SponsorsSidebar.vue' import './custom.css' export default { @@ -9,29 +8,7 @@ export default { Layout() { return h(Theme.Layout, null, { 'sidebar-bottom': () => - h('div', { class: 'sponsors sidebar' }, [ - h( - 'a', - { - href: 'https://github.com/sponsors/yyx990803', - target: '_blank', - rel: 'noopener' - }, - [h('span', 'Sponsors')] - ), - ...sponsors.map(({ href, src, name, id }) => - h( - 'a', - { - href, - target: '_blank', - rel: 'noopener', - 'aria-label': 'sponsor-img' - }, - [h('img', { src, alt: name, id: `sponsor-${id}` })] - ) - ) - ]) + h('div', { class: 'sponsors sidebar' }, [h(SponsorsSidebar)]) }) } } diff --git a/docs/.vitepress/theme/sponsors.css b/docs/.vitepress/theme/sponsors.css deleted file mode 100644 index 904b4945ed57d6..00000000000000 --- a/docs/.vitepress/theme/sponsors.css +++ /dev/null @@ -1,56 +0,0 @@ -.sponsors { - padding: 0 1.5rem 2rem; - font-size: 0.8rem; -} - -.sponsors a { - color: #999; - margin: 1em 2em; - display: block; -} - -.sponsors img { - max-width: 160px; - max-height: 40px; -} - -.sponsors.frontpage { - text-align: center; -} - -.sponsors.frontpage img { - display: inline-block; - vertical-align: middle; -} - -.sponsors.frontpage h2 { - color: #999; - font-size: 1.2rem; - border: none; -} - -.sponsors.sidebar a img { - max-height: 36px; -} - -.platinum-sponsors { - margin-bottom: 1.5em; -} - -.platinum-sponsors a img { - max-width: 240px; - max-height: 60px; -} - -.gold-sponsors { - display: flex; - flex-wrap: wrap; - justify-content: center; - align-items: center; -} - -/* special cases */ -#sponsor-mux { - padding: 5px 0; - min-height: 36px; -} diff --git a/docs/.vitepress/theme/sponsors.json b/docs/.vitepress/theme/sponsors.json deleted file mode 100644 index 6d788ac4b84808..00000000000000 --- a/docs/.vitepress/theme/sponsors.json +++ /dev/null @@ -1,45 +0,0 @@ -[ - { - "id": "stackblitz", - "name": "StackBlitz", - "href": "https://stackblitz.com/", - "src": "/stackblitz.svg", - "tier": "platinum" - }, - { - "id": "cypress", - "name": "Cypress.io", - "href": "https://cypress.io", - "src": "/cypress.svg" - }, - { - "id": "tailwind", - "name": "Tailwind Labs", - "href": "https://tailwindcss.com", - "src": "/tailwind-labs.svg" - }, - { - "id": "vuejobs", - "name": "Vue Jobs", - "href": "https://vuejobs.com/?ref=vuejs", - "src": "/vuejobs.png" - }, - { - "id": "mux", - "name": "Mux", - "href": "https://mux.com", - "src": "/mux.svg" - }, - { - "id": "plaid", - "name": "Plaid Inc.", - "href": "https://plaid.co.jp/", - "src": "/plaid.svg" - }, - { - "id": "divriots", - "name": "divriots", - "href": "https://divriots.com/", - "src": "/divriots.png" - } -] diff --git a/docs/index.md b/docs/index.md index 81b0eb027e8f05..ce1678de00404e 100644 --- a/docs/index.md +++ b/docs/index.md @@ -23,21 +23,16 @@ features: footer: MIT Licensed | Copyright © 2019-present Evan You & Vite Contributors --- -
-

Sponsors

-
- - - -
-
- - - -
- Become a sponsor on GitHub -
- + +

Sponsors

+ + + + + +

+ Become a sponsor on GitHub +

From 7a2ddb43fbe2b777129818d88792db6e848ce2f6 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 11 Feb 2022 10:10:35 +0100 Subject: [PATCH 116/174] chore(deps): update dependency @ampproject/remapping to v2 (#6690) --- packages/vite/package.json | 2 +- pnpm-lock.yaml | 17 ++++------------- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/packages/vite/package.json b/packages/vite/package.json index 21b83d49e50622..494b6aebc54ea2 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -53,7 +53,7 @@ "fsevents": "~2.3.2" }, "devDependencies": { - "@ampproject/remapping": "^1.1.1", + "@ampproject/remapping": "^2.1.0", "@babel/parser": "^7.17.0", "@babel/types": "^7.17.0", "@rollup/plugin-alias": "^3.1.9", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b40b226c292e61..ab4083cb6a7635 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -735,7 +735,7 @@ importers: packages/vite: specifiers: - '@ampproject/remapping': ^1.1.1 + '@ampproject/remapping': ^2.1.0 '@babel/parser': ^7.17.0 '@babel/types': ^7.17.0 '@rollup/plugin-alias': ^3.1.9 @@ -813,7 +813,7 @@ importers: optionalDependencies: fsevents: 2.3.2 devDependencies: - '@ampproject/remapping': 1.1.1 + '@ampproject/remapping': 2.1.0 '@babel/parser': 7.17.0 '@babel/types': 7.17.0 '@rollup/plugin-alias': 3.1.9_rollup@2.62.0 @@ -991,14 +991,6 @@ packages: '@algolia/requester-common': 4.11.0 dev: true - /@ampproject/remapping/1.1.1: - resolution: {integrity: sha512-YVAcA4DKLOj296CF5SrQ8cYiMRiUGc2sqFpLxsDGWE34suHqhGP/5yMsDHKsrh8hs8I5TiRVXNwKPWQpX3iGjw==} - engines: {node: '>=6.0.0'} - dependencies: - '@jridgewell/resolve-uri': 3.0.3 - sourcemap-codec: 1.4.8 - dev: true - /@ampproject/remapping/2.1.0: resolution: {integrity: sha512-d5RysTlJ7hmw5Tw4UxgxcY3lkMe92n8sXCcuLPAyIAHK6j8DefDwtGnVVDgOnv+RnEosulDJ9NPKQL27bDId0g==} engines: {node: '>=6.0.0'} @@ -5157,7 +5149,6 @@ packages: /graceful-fs/4.2.9: resolution: {integrity: sha512-NtNxqUcXgpW2iMrfqSfR73Glt39K+BLwWsPs94yR63v45T0Wbej7eRmL5cWfwEgqXnmjQp3zaJTshdRW/qC2ZQ==} - dev: true /handlebars/4.7.7: resolution: {integrity: sha512-aAcXm5OAfE/8IXkcZvCepKU3VzW1/39Fb5ZuqMtgI/hT8X2YgoMvBY5dLhq/cpOvw7Lk1nK/UF71aLG/ZnVYRA==} @@ -6333,7 +6324,7 @@ packages: dependencies: universalify: 2.0.0 optionalDependencies: - graceful-fs: 4.2.8 + graceful-fs: 4.2.9 /jsonparse/1.3.1: resolution: {integrity: sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA=} @@ -6388,7 +6379,7 @@ packages: tslib: 2.3.1 optionalDependencies: errno: 0.1.8 - graceful-fs: 4.2.8 + graceful-fs: 4.2.9 image-size: 0.5.5 make-dir: 2.1.0 mime: 1.6.0 From 2c02ce7061f9d4a9a8e70a96d89e930b4e6ed448 Mon Sep 17 00:00:00 2001 From: Valentin Date: Fri, 11 Feb 2022 10:12:03 +0100 Subject: [PATCH 117/174] docs: change worker config to object instead of array (#6844) --- packages/vite/CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/vite/CHANGELOG.md b/packages/vite/CHANGELOG.md index f436a99d9175e2..f3cf3406306cc8 100644 --- a/packages/vite/CHANGELOG.md +++ b/packages/vite/CHANGELOG.md @@ -46,10 +46,10 @@ The worker plugins pipeline isn't shared with the main Vite pipeline, there may import PluginX from 'vite-plugin-x' export default { plugins: [ PluginX() ] - worker: [ + worker: { format: 'es', plugins: [ PluginX() ] - ] + } } ``` From f63a72e77214ea31884680a3c5facf4fcee5d226 Mon Sep 17 00:00:00 2001 From: reid j sherman Date: Fri, 11 Feb 2022 01:29:14 -0800 Subject: [PATCH 118/174] docs: rename empty git repo from master to main (#6857) --- docs/guide/static-deploy.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/guide/static-deploy.md b/docs/guide/static-deploy.md index 574ceda541da15..43b047dd7f53eb 100644 --- a/docs/guide/static-deploy.md +++ b/docs/guide/static-deploy.md @@ -80,6 +80,7 @@ Now the `preview` method will launch the server at `http://localhost:8080`. # echo 'www.example.com' > CNAME git init + git checkout -b main git add -A git commit -m 'deploy' From 0941620705eea1a08509a4f5a28dd3099a711e58 Mon Sep 17 00:00:00 2001 From: Zheeeng Date: Fri, 11 Feb 2022 19:49:13 +0800 Subject: [PATCH 119/174] chore: build signatures (#6841) --- packages/vite/src/node/build.ts | 39 ++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/packages/vite/src/node/build.ts b/packages/vite/src/node/build.ts index 7c7d1d18037174..b9936f8583b46c 100644 --- a/packages/vite/src/node/build.ts +++ b/packages/vite/src/node/build.ts @@ -769,7 +769,7 @@ function resolveExternal( ssrExternals: string[], user: ExternalOption | undefined ): ExternalOption { - return ((id, parentId, isResolved) => { + return (id, parentId, isResolved) => { if (shouldExternalizeForSSR(id, ssrExternals)) { return true } @@ -782,7 +782,7 @@ function resolveExternal( return isExternal(id, user) } } - }) as ExternalOption + } } function isExternal(id: string, test: string | RegExp) { @@ -793,39 +793,48 @@ function isExternal(id: string, test: string | RegExp) { } } -function injectSsrFlagToHooks(p: Plugin): Plugin { - const { resolveId, load, transform } = p +function injectSsrFlagToHooks(plugin: Plugin): Plugin { + const { resolveId, load, transform } = plugin return { - ...p, + ...plugin, resolveId: wrapSsrResolveId(resolveId), load: wrapSsrLoad(load), transform: wrapSsrTransform(transform) } } -function wrapSsrResolveId(fn: Function | undefined) { +function wrapSsrResolveId( + fn?: Rollup.ResolveIdHook +): Rollup.ResolveIdHook | undefined { if (!fn) return - return function (this: any, id: any, importer: any, options: any) { + + return function (id, importer, options) { return fn.call(this, id, importer, injectSsrFlag(options)) } } -function wrapSsrLoad(fn: Function | undefined) { +function wrapSsrLoad(fn?: Rollup.LoadHook): Rollup.LoadHook | undefined { if (!fn) return - // Receiving options param to be future-proof if Rollup adds it - return function (this: any, id: any, ...args: any[]) { + + return function (id, ...args) { + // @ts-expect-error: Receiving options param to be future-proof if Rollup adds it return fn.call(this, id, injectSsrFlag(args[0])) } } -function wrapSsrTransform(fn: Function | undefined) { +function wrapSsrTransform( + fn?: Rollup.TransformHook +): Rollup.TransformHook | undefined { if (!fn) return - // Receiving options param to be future-proof if Rollup adds it - return function (this: any, code: any, importer: any, ...args: any[]) { + + return function (code, importer, ...args) { + // @ts-expect-error: Receiving options param to be future-proof if Rollup adds it return fn.call(this, code, importer, injectSsrFlag(args[0])) } } -function injectSsrFlag(options: any = {}) { - return { ...options, ssr: true } +function injectSsrFlag>( + options?: T +): T & { ssr: boolean } { + return { ...(options ?? {}), ssr: true } as T & { ssr: boolean } } From de20c73ef37b179c1791c0f96da04d29cfd48840 Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Fri, 11 Feb 2022 19:51:32 +0800 Subject: [PATCH 120/174] fix(scan): escape for virtual modules (#6863) --- packages/vite/src/node/optimizer/scan.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vite/src/node/optimizer/scan.ts b/packages/vite/src/node/optimizer/scan.ts index 9ba65d23684305..280776b2e7d38d 100644 --- a/packages/vite/src/node/optimizer/scan.ts +++ b/packages/vite/src/node/optimizer/scan.ts @@ -284,7 +284,7 @@ function esbuildScanPlugin( loader, contents: localContent } - js += `import '${virtualModulePrefix}${path}';\n` + js += `import ${JSON.stringify(virtualModulePrefix + path)}\n` } else { js += content + '\n' } From a3a9941be7017a21c875786683c7b0225e3fdee5 Mon Sep 17 00:00:00 2001 From: Zheeeng Date: Fri, 11 Feb 2022 19:55:29 +0800 Subject: [PATCH 121/174] chore(types): remove unnecessary type assertion (#6784) --- packages/vite/src/node/http.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vite/src/node/http.ts b/packages/vite/src/node/http.ts index fd45907ce0b723..f1266ddb93ba12 100644 --- a/packages/vite/src/node/http.ts +++ b/packages/vite/src/node/http.ts @@ -144,7 +144,7 @@ export async function resolveHttpsConfig( function readFileIfExists(value?: string | Buffer | any[]) { if (typeof value === 'string') { try { - return fs.readFileSync(path.resolve(value as string)) + return fs.readFileSync(path.resolve(value)) } catch (e) { return value } From 0282e7a523d1cccdc490c1df20b3013d5144ea19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Cotiniaux?= Date: Fri, 11 Feb 2022 12:56:07 +0100 Subject: [PATCH 122/174] chore: remove cancelled sponsor img (#6781) --- docs/public/finclip.png | Bin 13876 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 docs/public/finclip.png diff --git a/docs/public/finclip.png b/docs/public/finclip.png deleted file mode 100644 index 9110e6d56c164d598209d4b26ed019360efa181f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 13876 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 Date: Fri, 11 Feb 2022 13:17:10 +0100 Subject: [PATCH 123/174] release: v2.8.1 --- packages/vite/CHANGELOG.md | 10 +++++++ packages/vite/LICENSE.md | 56 ++++++++++++++++++++++++++++++++++++++ packages/vite/package.json | 2 +- 3 files changed, 67 insertions(+), 1 deletion(-) diff --git a/packages/vite/CHANGELOG.md b/packages/vite/CHANGELOG.md index f3cf3406306cc8..50925e58baffdb 100644 --- a/packages/vite/CHANGELOG.md +++ b/packages/vite/CHANGELOG.md @@ -1,3 +1,13 @@ +## [2.8.1](https://github.com/vitejs/vite/compare/v2.8.0...v2.8.1) (2022-02-11) + + +### Bug Fixes + +* **deps:** update all non-major dependencies ([#6782](https://github.com/vitejs/vite/issues/6782)) ([e38be3e](https://github.com/vitejs/vite/commit/e38be3e6ca7bf79319d5d7188e1d347b1d6091ef)) +* **scan:** escape for virtual modules ([#6863](https://github.com/vitejs/vite/issues/6863)) ([de20c73](https://github.com/vitejs/vite/commit/de20c73ef37b179c1791c0f96da04d29cfd48840)) + + + # [2.8.0](https://github.com/vitejs/vite/compare/v2.8.0-beta.7...v2.8.0) (2022-02-09) ### Reduced Footprint diff --git a/packages/vite/LICENSE.md b/packages/vite/LICENSE.md index e7849fe80aa577..e3a445f8cfdbe3 100644 --- a/packages/vite/LICENSE.md +++ b/packages/vite/LICENSE.md @@ -264,6 +264,62 @@ Repository: https://github.com/jridgewell/resolve-uri --------------------------------------- +## @jridgewell/sourcemap-codec +License: MIT +By: Rich Harris +Repository: git+https://github.com/jridgewell/sourcemap-codec.git + +> The MIT License +> +> Copyright (c) 2015 Rich Harris +> +> Permission is hereby granted, free of charge, to any person obtaining a copy +> of this software and associated documentation files (the "Software"), to deal +> in the Software without restriction, including without limitation the rights +> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +> copies of the Software, and to permit persons to whom the Software is +> furnished to do so, subject to the following conditions: +> +> The above copyright notice and this permission notice shall be included in +> all copies or substantial portions of the Software. +> +> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +> THE SOFTWARE. + +--------------------------------------- + +## @jridgewell/trace-mapping +License: MIT +By: Justin Ridgewell +Repository: git+https://github.com/jridgewell/trace-mapping.git + +> Copyright 2022 Justin Ridgewell +> +> Permission is hereby granted, free of charge, to any person obtaining a copy +> of this software and associated documentation files (the "Software"), to deal +> in the Software without restriction, including without limitation the rights +> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +> copies of the Software, and to permit persons to whom the Software is +> furnished to do so, subject to the following conditions: +> +> The above copyright notice and this permission notice shall be included in +> all copies or substantial portions of the Software. +> +> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +> SOFTWARE. + +--------------------------------------- + ## @nodelib/fs.scandir License: MIT Repository: https://github.com/nodelib/nodelib/tree/master/packages/fs/fs.scandir diff --git a/packages/vite/package.json b/packages/vite/package.json index 494b6aebc54ea2..2f57fb3f59164d 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -1,6 +1,6 @@ { "name": "vite", - "version": "2.8.0", + "version": "2.8.1", "license": "MIT", "author": "Evan You", "description": "Native-ESM powered web dev build tool", From a23eeb205f10b0c7a26517ed804f85468480892f Mon Sep 17 00:00:00 2001 From: patak Date: Fri, 11 Feb 2022 14:15:02 +0100 Subject: [PATCH 124/174] chore: release action (#6669) --- .github/workflows/release.yml | 78 ++++++++++++++++++++ scripts/release.ts | 129 +++++++++++++++++++++++++--------- 2 files changed, 172 insertions(+), 35 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000000000..0c3b0c183ef3a1 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,78 @@ +name: Release + +on: + workflow_dispatch: + inputs: + branch: + description: "branch" + required: true + type: string + default: "main" + package: + description: "package" + required: true + type: choice + options: + - vite + - plugin-legacy + - plugin-vue + - plugin-vue-jsx + - plugin-react + - create-vite + type: + description: "type" + required: true + type: choice + options: + - next + - stable + - minor-beta + - major-beta + - minor + - major + +jobs: + release: + # prevents this action from running on forks + if: github.repository == 'vitejs/vite' + name: Release + runs-on: ${{ matrix.os }} + environment: Release + strategy: + matrix: + # pseudo-matrix for convenience, NEVER use more than a single combination + node: [16] + os: [ubuntu-latest] + steps: + - name: checkout + uses: actions/checkout@v2 + with: + # This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits + ref: ${{ github.event.inputs.branch }} + fetch-depth: 0 + - uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node }} + - run: git config user.name vitebot + - run: git config user.email vitejs.bot@gmail.com + - run: npm i -g pnpm@6 + - run: npm i -g yarn # even if the repo is using pnpm, Vite still uses yarn v1 for publishing + - uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node }} + cache: "pnpm" + cache-dependency-path: "**/pnpm-lock.yaml" + - name: install + run: pnpm install --frozen-lockfile --prefer-offline + - name: Creating .npmrc + run: | + cat << EOF > "$HOME/.npmrc" + //registry.npmjs.org/:_authToken=$NPM_TOKEN + EOF + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + - name: Release + run: pnpm --dir packages/${{ github.event.inputs.package }} release -- --quiet --type ${{ github.event.inputs.type }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/scripts/release.ts b/scripts/release.ts index 4c3006fe1f0475..e24f539547f014 100644 --- a/scripts/release.ts +++ b/scripts/release.ts @@ -12,6 +12,11 @@ import semver from 'semver' const args = require('minimist')(process.argv.slice(2)) +// For GitHub Actions use +// Regular release : release --type next --quiet +// Start beta : release --type (minor-beta|major-beta) --quiet +// Release from beta : release --type stable --quiet + const pkgDir = process.cwd() const pkgPath = path.resolve(pkgDir, 'package.json') const pkg: { name: string; version: string } = require(pkgPath) @@ -55,27 +60,75 @@ async function main(): Promise { let targetVersion: string | undefined = args._[0] if (!targetVersion) { - // no explicit version, offer suggestions - const { release }: { release: string } = await prompts({ - type: 'select', - name: 'release', - message: 'Select release type', - choices: versionIncrements - .map((i) => `${i} (${inc(i)})`) - .concat(['custom']) - .map((i) => ({ value: i, title: i })) - }) - - if (release === 'custom') { - const res: { version: string } = await prompts({ - type: 'text', - name: 'version', - message: 'Input custom version', - initial: currentVersion - }) - targetVersion = res.version + const type: string | undefined = args.type + if (type) { + const currentBeta = currentVersion.includes('beta') + if (type === 'next') { + targetVersion = inc(currentBeta ? 'prerelease' : 'patch') + } else if (type === 'stable') { + // Out of beta + if (!currentBeta) { + throw new Error( + `Current version: ${currentVersion} isn't a beta, stable can't be used` + ) + } + targetVersion = inc('patch') + } else if (type === 'minor-beta') { + if (currentBeta) { + throw new Error( + `Current version: ${currentVersion} is already a beta, minor-beta can't be used` + ) + } + targetVersion = inc('preminor') + } else if (type === 'major-beta') { + if (currentBeta) { + throw new Error( + `Current version: ${currentVersion} is already a beta, major-beta can't be used` + ) + } + targetVersion = inc('premajor') + } else if (type === 'minor') { + if (currentBeta) { + throw new Error( + `Current version: ${currentVersion} is a beta, use stable to release it first` + ) + } + targetVersion = inc('minor') + } else if (type === 'major') { + if (currentBeta) { + throw new Error( + `Current version: ${currentVersion} is a beta, use stable to release it first` + ) + } + targetVersion = inc('major') + } else { + throw new Error( + `type: ${type} isn't a valid type. Use stable, minor-beta, major-beta, or next` + ) + } } else { - targetVersion = release.match(/\((.*)\)/)![1] + // no explicit version or type, offer suggestions + const { release }: { release: string } = await prompts({ + type: 'select', + name: 'release', + message: 'Select release type', + choices: versionIncrements + .map((i) => `${i} (${inc(i)})`) + .concat(['custom']) + .map((i) => ({ value: i, title: i })) + }) + + if (release === 'custom') { + const res: { version: string } = await prompts({ + type: 'text', + name: 'version', + message: 'Input custom version', + initial: currentVersion + }) + targetVersion = res.version + } else { + targetVersion = release.match(/\((.*)\)/)![1] + } } } @@ -86,24 +139,30 @@ async function main(): Promise { const tag = pkgName === 'vite' ? `v${targetVersion}` : `${pkgName}@${targetVersion}` - if (targetVersion.includes('beta') && !args.tag) { - const { tagBeta }: { tagBeta: boolean } = await prompts({ - type: 'confirm', - name: 'tagBeta', - message: `Publish under dist-tag "beta"?` - }) + if (!args.quiet) { + if (targetVersion.includes('beta') && !args.tag) { + const { tagBeta }: { tagBeta: boolean } = await prompts({ + type: 'confirm', + name: 'tagBeta', + message: `Publish under dist-tag "beta"?` + }) - if (tagBeta) args.tag = 'beta' - } + if (tagBeta) args.tag = 'beta' + } - const { yes }: { yes: boolean } = await prompts({ - type: 'confirm', - name: 'yes', - message: `Releasing ${tag}. Confirm?` - }) + const { yes }: { yes: boolean } = await prompts({ + type: 'confirm', + name: 'yes', + message: `Releasing ${tag}. Confirm?` + }) - if (!yes) { - return + if (!yes) { + return + } + } else { + if (targetVersion.includes('beta') && !args.tag) { + args.tag = 'beta' + } } step('\nUpdating package version...') From 82e5016d1b5c8fceebfc0f9d2246df6be2104eaf Mon Sep 17 00:00:00 2001 From: Evan You Date: Fri, 11 Feb 2022 08:16:42 -0500 Subject: [PATCH 125/174] Update release-tag.yml --- .github/workflows/release-tag.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-tag.yml b/.github/workflows/release-tag.yml index 5ed9495899340a..f9d5b8de30bec9 100644 --- a/.github/workflows/release-tag.yml +++ b/.github/workflows/release-tag.yml @@ -1,4 +1,4 @@ -name: release +name: Add GitHub Release Tag on: push: From 56e67c214e884fa3dcd168527117a2621c92e8a8 Mon Sep 17 00:00:00 2001 From: patak-dev Date: Fri, 11 Feb 2022 21:31:28 +0100 Subject: [PATCH 126/174] chore: config yarn registry in release action --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0c3b0c183ef3a1..b059c0bfa35bc0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -57,6 +57,7 @@ jobs: - run: git config user.email vitejs.bot@gmail.com - run: npm i -g pnpm@6 - run: npm i -g yarn # even if the repo is using pnpm, Vite still uses yarn v1 for publishing + - run: yarn config set registry https://registry.npmjs.org # Yarn's default registry proxy doesn't work in CI - uses: actions/setup-node@v2 with: node-version: ${{ matrix.node }} From 997b8f11cb156cc374ae991875a09534b5489a93 Mon Sep 17 00:00:00 2001 From: Aron Griffis Date: Fri, 11 Feb 2022 15:37:07 -0500 Subject: [PATCH 127/174] fix(plugin-legacy): require Vite 2.8.0 (#6272) (#6869) --- packages/plugin-legacy/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/plugin-legacy/package.json b/packages/plugin-legacy/package.json index a503421e19e13f..cba6f7466a95a8 100644 --- a/packages/plugin-legacy/package.json +++ b/packages/plugin-legacy/package.json @@ -33,6 +33,6 @@ "systemjs": "^6.12.1" }, "peerDependencies": { - "vite": "^2.7.8" + "vite": "^2.8.0" } } From 19a58dd320e9dd582bb7868e1621d8bde835eda6 Mon Sep 17 00:00:00 2001 From: patak-dev Date: Fri, 11 Feb 2022 22:08:58 +0100 Subject: [PATCH 128/174] release: plugin-legacy@1.7.1 --- packages/plugin-legacy/CHANGELOG.md | 8 ++++++++ packages/plugin-legacy/package.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/plugin-legacy/CHANGELOG.md b/packages/plugin-legacy/CHANGELOG.md index da053294652427..e92ca1e12357fe 100644 --- a/packages/plugin-legacy/CHANGELOG.md +++ b/packages/plugin-legacy/CHANGELOG.md @@ -1,3 +1,11 @@ +## [1.7.1](https://github.com/vitejs/vite/compare/plugin-legacy@1.7.0...plugin-legacy@1.7.1) (2022-02-11) + +### Bug Fixes + +* require Vite 2.8.0 ([#6272](https://github.com/vitejs/vite/issues/6272)) ([#6869](https://github.com/vitejs/vite/issues/6869)) ([997b8f1](https://github.com/vitejs/vite/commit/997b8f11cb156cc374ae991875a09534b5489a93)) + + + # [1.7.0](https://github.com/vitejs/vite/compare/plugin-legacy@1.6.4...plugin-legacy@1.7.0) (2022-02-09) diff --git a/packages/plugin-legacy/package.json b/packages/plugin-legacy/package.json index cba6f7466a95a8..45c09f607fdfab 100644 --- a/packages/plugin-legacy/package.json +++ b/packages/plugin-legacy/package.json @@ -1,6 +1,6 @@ { "name": "@vitejs/plugin-legacy", - "version": "1.7.0", + "version": "1.7.1", "license": "MIT", "author": "Evan You", "files": [ From 6ea6e08d23a967461cdb5a5fc6d48a6625188c2f Mon Sep 17 00:00:00 2001 From: patak-dev Date: Sat, 12 Feb 2022 08:09:45 +0100 Subject: [PATCH 129/174] release: plugin-vue-jsx@1.3.5 --- packages/plugin-vue-jsx/CHANGELOG.md | 4 ++++ packages/plugin-vue-jsx/package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/plugin-vue-jsx/CHANGELOG.md b/packages/plugin-vue-jsx/CHANGELOG.md index 30618d5b056ef9..594f12c90f0909 100644 --- a/packages/plugin-vue-jsx/CHANGELOG.md +++ b/packages/plugin-vue-jsx/CHANGELOG.md @@ -1,3 +1,7 @@ +## [1.3.5](https://github.com/vitejs/vite/compare/plugin-vue-jsx@1.3.4...plugin-vue-jsx@1.3.5) (2022-02-12) + + + ## [1.3.4](https://github.com/vitejs/vite/compare/plugin-vue-jsx@1.3.3...plugin-vue-jsx@1.3.4) (2022-02-09) diff --git a/packages/plugin-vue-jsx/package.json b/packages/plugin-vue-jsx/package.json index 3724cd25c7c381..c26a343c9c4227 100644 --- a/packages/plugin-vue-jsx/package.json +++ b/packages/plugin-vue-jsx/package.json @@ -1,6 +1,6 @@ { "name": "@vitejs/plugin-vue-jsx", - "version": "1.3.4", + "version": "1.3.5", "license": "MIT", "author": "Evan You", "files": [ From fe8ef39eb37df7565dbbfce6a09c2eb7ceeaa56e Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Sat, 12 Feb 2022 19:14:31 +0800 Subject: [PATCH 130/174] workflow: separate version bumping and publishing on release (#6879) --- .github/workflows/publish.yml | 37 ++++ .github/workflows/release.yml | 79 -------- package.json | 2 + packages/create-vite/package.json | 4 - packages/create-vite/updateVersions.ts | 23 --- packages/plugin-legacy/package.json | 4 - packages/plugin-react/package.json | 3 +- packages/plugin-vue-jsx/package.json | 4 - packages/plugin-vue/package.json | 3 +- packages/vite/package.json | 3 +- scripts/publishCI.ts | 31 +++ scripts/release.ts | 265 +++++++------------------ scripts/releaseUtils.ts | 215 ++++++++++++++++++++ 13 files changed, 361 insertions(+), 312 deletions(-) create mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/release.yml delete mode 100644 packages/create-vite/updateVersions.ts create mode 100644 scripts/publishCI.ts create mode 100644 scripts/releaseUtils.ts diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000000000..f4df5af00cc23c --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,37 @@ +name: Publish Package + +on: + push: + tags: + - "v*" # Push events to matching v*, i.e. v1.0, v20.15.10 + - "plugin-*" # Push events to matching plugin-*, i.e. plugin-(vue|vue-jsx|react|legacy)@1.0.0 + - "create-vite*" # # Push events to matching create-vite*, i.e. create-vite@1.0.0 + +jobs: + publish: + # prevents this action from running on forks + if: github.repository == 'vitejs/vite' + runs-on: ubuntu-latest + environment: Release + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Install pnpm + uses: pnpm/action-setup@v2 + with: + version: 6 + + - name: Set node version to 16.x + uses: actions/setup-node@v2 + with: + node-version: 16.x + cache: "pnpm" + + - name: Install deps + run: pnpm install + + - name: Publish package + run: pnpm run ci-publish -- ${{ github.ref_name }} --dry + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index b059c0bfa35bc0..00000000000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,79 +0,0 @@ -name: Release - -on: - workflow_dispatch: - inputs: - branch: - description: "branch" - required: true - type: string - default: "main" - package: - description: "package" - required: true - type: choice - options: - - vite - - plugin-legacy - - plugin-vue - - plugin-vue-jsx - - plugin-react - - create-vite - type: - description: "type" - required: true - type: choice - options: - - next - - stable - - minor-beta - - major-beta - - minor - - major - -jobs: - release: - # prevents this action from running on forks - if: github.repository == 'vitejs/vite' - name: Release - runs-on: ${{ matrix.os }} - environment: Release - strategy: - matrix: - # pseudo-matrix for convenience, NEVER use more than a single combination - node: [16] - os: [ubuntu-latest] - steps: - - name: checkout - uses: actions/checkout@v2 - with: - # This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits - ref: ${{ github.event.inputs.branch }} - fetch-depth: 0 - - uses: actions/setup-node@v2 - with: - node-version: ${{ matrix.node }} - - run: git config user.name vitebot - - run: git config user.email vitejs.bot@gmail.com - - run: npm i -g pnpm@6 - - run: npm i -g yarn # even if the repo is using pnpm, Vite still uses yarn v1 for publishing - - run: yarn config set registry https://registry.npmjs.org # Yarn's default registry proxy doesn't work in CI - - uses: actions/setup-node@v2 - with: - node-version: ${{ matrix.node }} - cache: "pnpm" - cache-dependency-path: "**/pnpm-lock.yaml" - - name: install - run: pnpm install --frozen-lockfile --prefer-offline - - name: Creating .npmrc - run: | - cat << EOF > "$HOME/.npmrc" - //registry.npmjs.org/:_authToken=$NPM_TOKEN - EOF - env: - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - - name: Release - run: pnpm --dir packages/${{ github.event.inputs.package }} release -- --quiet --type ${{ github.event.inputs.type }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/package.json b/package.json index 63c7e38d0d0652..72b7076ee65d01 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,8 @@ "docs": "vitepress dev docs", "build-docs": "vitepress build docs", "serve-docs": "vitepress serve docs", + "release": "ts-node scripts/release.ts", + "ci-publish": "ts-node scripts/publishCI.ts", "build": "run-s build-vite build-plugin-vue build-plugin-react", "build-vite": "cd packages/vite && npm run build", "build-plugin-vue": "cd packages/plugin-vue && npm run build", diff --git a/packages/create-vite/package.json b/packages/create-vite/package.json index 6ff118b7793840..5d873b83fe515b 100644 --- a/packages/create-vite/package.json +++ b/packages/create-vite/package.json @@ -12,10 +12,6 @@ "template-*" ], "main": "index.js", - "scripts": { - "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s --commit-path . --lerna-package create-vite", - "release": "ts-node updateVersions && ts-node ../../scripts/release.ts --skipBuild" - }, "engines": { "node": ">=12.0.0" }, diff --git a/packages/create-vite/updateVersions.ts b/packages/create-vite/updateVersions.ts deleted file mode 100644 index 7125fce9119f07..00000000000000 --- a/packages/create-vite/updateVersions.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { readdirSync, writeFileSync } from 'fs' -import { join } from 'path' - -const latestVersion = require('../vite/package.json').version -const isLatestPreRelease = /beta|alpha|rc/.test(latestVersion) - -;(async () => { - const templates = readdirSync(__dirname).filter((dir) => - dir.startsWith('template-') - ) - for (const template of templates) { - const pkgPath = join(__dirname, template, `package.json`) - const pkg = require(pkgPath) - if (!isLatestPreRelease) { - pkg.devDependencies.vite = `^` + latestVersion - } - if (template.startsWith('template-vue')) { - pkg.devDependencies['@vitejs/plugin-vue'] = - `^` + require('../plugin-vue/package.json').version - } - writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n') - } -})() diff --git a/packages/plugin-legacy/package.json b/packages/plugin-legacy/package.json index 45c09f607fdfab..e464c18b4dca1d 100644 --- a/packages/plugin-legacy/package.json +++ b/packages/plugin-legacy/package.json @@ -9,10 +9,6 @@ ], "main": "index.js", "types": "index.d.ts", - "scripts": { - "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s --commit-path . --lerna-package plugin-legacy", - "release": "ts-node ../../scripts/release.ts --skipBuild" - }, "engines": { "node": ">=12.0.0" }, diff --git a/packages/plugin-react/package.json b/packages/plugin-react/package.json index 1047a390865f4f..67df1d30b89b0c 100644 --- a/packages/plugin-react/package.json +++ b/packages/plugin-react/package.json @@ -18,8 +18,7 @@ "build-bundle": "esbuild src/index.ts --bundle --platform=node --target=node12 --external:@babel/* --external:@rollup/* --external:resolve --external:react-refresh/* --outfile=dist/index.js && npm run patch-dist", "patch-dist": "ts-node ../../scripts/patchEsbuildDist.ts dist/index.js viteReact", "build-types": "tsc -p . --emitDeclarationOnly --outDir temp && api-extractor run && rimraf temp", - "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s --commit-path . --lerna-package plugin-react", - "release": "ts-node ../../scripts/release.ts" + "prepublishOnly": "npm run build" }, "engines": { "node": ">=12.0.0" diff --git a/packages/plugin-vue-jsx/package.json b/packages/plugin-vue-jsx/package.json index c26a343c9c4227..dff19a227804d1 100644 --- a/packages/plugin-vue-jsx/package.json +++ b/packages/plugin-vue-jsx/package.json @@ -9,10 +9,6 @@ ], "main": "index.js", "types": "index.d.ts", - "scripts": { - "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s --commit-path . --lerna-package plugin-vue-jsx", - "release": "ts-node ../../scripts/release.ts --skipBuild" - }, "engines": { "node": ">=12.0.0" }, diff --git a/packages/plugin-vue/package.json b/packages/plugin-vue/package.json index f54042da5bf948..ca8836d8e81d36 100644 --- a/packages/plugin-vue/package.json +++ b/packages/plugin-vue/package.json @@ -16,8 +16,7 @@ "build-bundle": "esbuild src/index.ts --bundle --platform=node --target=node12 --external:@vue/compiler-sfc --external:vue/compiler-sfc --external:vite --outfile=dist/index.js & npm run patch-dist", "patch-dist": "ts-node ../../scripts/patchEsbuildDist.ts dist/index.js vuePlugin", "build-types": "tsc -p . --emitDeclarationOnly --outDir temp && api-extractor run && rimraf temp", - "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s --commit-path . --lerna-package plugin-vue", - "release": "ts-node ../../scripts/release.ts" + "prepublishOnly": "npm run build" }, "engines": { "node": ">=12.0.0" diff --git a/packages/vite/package.json b/packages/vite/package.json index 2f57fb3f59164d..9bd14ca89a4d16 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -39,8 +39,7 @@ "roll-types": "api-extractor run && rimraf temp", "lint": "eslint --ext .ts src/**", "format": "prettier --write --parser typescript \"src/**/*.ts\"", - "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s --commit-path .", - "release": "ts-node ../../scripts/release.ts" + "prepublishOnly": "npm run build" }, "//": "READ CONTRIBUTING.md to understand what to put under deps vs. devDeps!", "dependencies": { diff --git a/scripts/publishCI.ts b/scripts/publishCI.ts new file mode 100644 index 00000000000000..7df0893a15b788 --- /dev/null +++ b/scripts/publishCI.ts @@ -0,0 +1,31 @@ +import { args, getPackageInfo, publishPackage, step } from './releaseUtils' + +async function main() { + const tag = args._[0] + + if (!tag) { + throw new Error('No tag specified') + } + + let pkgName = 'vite' + let version + + if (tag.includes('@')) [pkgName, version] = tag.split('@') + else version = tag + + if (version.startsWith('v')) version = version.slice(1) + + const { currentVersion, pkgDir } = getPackageInfo(pkgName) + if (currentVersion !== version) + throw new Error( + `Package version from tag "${version}" mismatches with current version "${currentVersion}"` + ) + + step('Publishing package...') + await publishPackage(pkgDir, version.includes('beta') ? 'beta' : undefined) +} + +main().catch((err) => { + console.error(err) + process.exit(1) +}) diff --git a/scripts/release.ts b/scripts/release.ts index e24f539547f014..6ec929a1d3a340 100644 --- a/scripts/release.ts +++ b/scripts/release.ts @@ -1,134 +1,54 @@ -/** - * modified from https://github.com/vuejs/core/blob/master/scripts/release.js - */ -import colors from 'picocolors' -import type { ExecaChildProcess, Options as ExecaOptions } from 'execa' -import execa from 'execa' -import { readFileSync, writeFileSync } from 'fs' -import path from 'path' import prompts from 'prompts' -import type { ReleaseType } from 'semver' import semver from 'semver' +import colors from 'picocolors' +import { + args, + getPackageInfo, + getVersionChoices, + isDryRun, + logRecentCommits, + packages, + run, + runIfNotDry, + step, + updateTemplateVersions, + updateVersion +} from './releaseUtils' -const args = require('minimist')(process.argv.slice(2)) - -// For GitHub Actions use -// Regular release : release --type next --quiet -// Start beta : release --type (minor-beta|major-beta) --quiet -// Release from beta : release --type stable --quiet - -const pkgDir = process.cwd() -const pkgPath = path.resolve(pkgDir, 'package.json') -const pkg: { name: string; version: string } = require(pkgPath) -const pkgName = pkg.name.replace(/^@vitejs\//, '') -const currentVersion = pkg.version -const isDryRun: boolean = args.dry -const skipBuild: boolean = args.skipBuild - -const versionIncrements: ReleaseType[] = [ - 'patch', - 'minor', - 'major', - 'prepatch', - 'preminor', - 'premajor', - 'prerelease' -] - -const inc: (i: ReleaseType) => string = (i) => - semver.inc(currentVersion, i, 'beta')! - -type RunFn = ( - bin: string, - args: string[], - opts?: ExecaOptions -) => ExecaChildProcess - -const run: RunFn = (bin, args, opts = {}) => - execa(bin, args, { stdio: 'inherit', ...opts }) - -type DryRunFn = (bin: string, args: string[], opts?: any) => void +async function main(): Promise { + let targetVersion: string | undefined -const dryRun: DryRunFn = (bin, args, opts: any) => - console.log(colors.blue(`[dryrun] ${bin} ${args.join(' ')}`), opts) + const { pkg }: { pkg: string } = await prompts({ + type: 'select', + name: 'pkg', + message: 'Select package', + choices: packages.map((i) => ({ value: i, title: i })) + }) -const runIfNotDry = isDryRun ? dryRun : run + if (!pkg) return -const step: (msg: string) => void = (msg) => console.log(colors.cyan(msg)) + await logRecentCommits(pkg) -async function main(): Promise { - let targetVersion: string | undefined = args._[0] + const { currentVersion, pkgName, pkgPath, pkgDir } = getPackageInfo(pkg) if (!targetVersion) { - const type: string | undefined = args.type - if (type) { - const currentBeta = currentVersion.includes('beta') - if (type === 'next') { - targetVersion = inc(currentBeta ? 'prerelease' : 'patch') - } else if (type === 'stable') { - // Out of beta - if (!currentBeta) { - throw new Error( - `Current version: ${currentVersion} isn't a beta, stable can't be used` - ) - } - targetVersion = inc('patch') - } else if (type === 'minor-beta') { - if (currentBeta) { - throw new Error( - `Current version: ${currentVersion} is already a beta, minor-beta can't be used` - ) - } - targetVersion = inc('preminor') - } else if (type === 'major-beta') { - if (currentBeta) { - throw new Error( - `Current version: ${currentVersion} is already a beta, major-beta can't be used` - ) - } - targetVersion = inc('premajor') - } else if (type === 'minor') { - if (currentBeta) { - throw new Error( - `Current version: ${currentVersion} is a beta, use stable to release it first` - ) - } - targetVersion = inc('minor') - } else if (type === 'major') { - if (currentBeta) { - throw new Error( - `Current version: ${currentVersion} is a beta, use stable to release it first` - ) - } - targetVersion = inc('major') - } else { - throw new Error( - `type: ${type} isn't a valid type. Use stable, minor-beta, major-beta, or next` - ) - } - } else { - // no explicit version or type, offer suggestions - const { release }: { release: string } = await prompts({ - type: 'select', - name: 'release', - message: 'Select release type', - choices: versionIncrements - .map((i) => `${i} (${inc(i)})`) - .concat(['custom']) - .map((i) => ({ value: i, title: i })) - }) + const { release }: { release: string } = await prompts({ + type: 'select', + name: 'release', + message: 'Select release type', + choices: getVersionChoices(currentVersion) + }) - if (release === 'custom') { - const res: { version: string } = await prompts({ - type: 'text', - name: 'version', - message: 'Input custom version', - initial: currentVersion - }) - targetVersion = res.version - } else { - targetVersion = release.match(/\((.*)\)/)![1] - } + if (release === 'custom') { + const res: { version: string } = await prompts({ + type: 'text', + name: 'version', + message: 'Input custom version', + initial: currentVersion + }) + targetVersion = res.version + } else { + targetVersion = release } } @@ -139,44 +59,37 @@ async function main(): Promise { const tag = pkgName === 'vite' ? `v${targetVersion}` : `${pkgName}@${targetVersion}` - if (!args.quiet) { - if (targetVersion.includes('beta') && !args.tag) { - const { tagBeta }: { tagBeta: boolean } = await prompts({ - type: 'confirm', - name: 'tagBeta', - message: `Publish under dist-tag "beta"?` - }) - - if (tagBeta) args.tag = 'beta' - } + if (targetVersion.includes('beta') && !args.tag) { + args.tag = 'beta' + } - const { yes }: { yes: boolean } = await prompts({ - type: 'confirm', - name: 'yes', - message: `Releasing ${tag}. Confirm?` - }) + const { yes }: { yes: boolean } = await prompts({ + type: 'confirm', + name: 'yes', + message: `Releasing ${colors.yellow(tag)} Confirm?` + }) - if (!yes) { - return - } - } else { - if (targetVersion.includes('beta') && !args.tag) { - args.tag = 'beta' - } + if (!yes) { + return } step('\nUpdating package version...') - updateVersion(targetVersion) - - step('\nBuilding package...') - if (!skipBuild && !isDryRun) { - await run('pnpm', ['run', 'build']) - } else { - console.log(`(skipped)`) - } + updateVersion(pkgPath, targetVersion) + if (pkgName === 'create-vite') updateTemplateVersions(targetVersion) step('\nGenerating changelog...') - await run('pnpm', ['run', 'changelog']) + const changelogArgs = [ + 'conventional-changelog', + '-p', + 'angular', + '-i', + 'CHANGELOG.md', + '-s', + '--commit-path', + '.' + ] + if (pkgName !== 'vite') changelogArgs.push('--lerna-package', 'plugin-vue') + await run('npx', changelogArgs, { cwd: pkgDir }) const { stdout } = await run('git', ['diff'], { stdio: 'pipe' }) if (stdout) { @@ -186,59 +99,27 @@ async function main(): Promise { await runIfNotDry('git', ['tag', tag]) } else { console.log('No changes to commit.') + return } - step('\nPublishing package...') - await publishPackage(targetVersion, runIfNotDry) - step('\nPushing to GitHub...') await runIfNotDry('git', ['push', 'origin', `refs/tags/${tag}`]) await runIfNotDry('git', ['push']) if (isDryRun) { console.log(`\nDry run finished - run git diff to see package changes.`) + } else { + console.log( + colors.green( + '\nPushed, publishing should starts shortly on CI.\nhttps://github.com/vitejs/vite/actions/workflows/publish.yml' + ) + ) } console.log() } -function updateVersion(version: string): void { - const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8')) - pkg.version = version - writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n') -} - -async function publishPackage( - version: string, - runIfNotDry: RunFn | DryRunFn -): Promise { - const publicArgs = [ - 'publish', - '--no-git-tag-version', - '--new-version', - version, - '--access', - 'public' - ] - if (args.tag) { - publicArgs.push(`--tag`, args.tag) - } - try { - // important: we still use Yarn 1 to publish since we rely on its specific - // behavior - await runIfNotDry('yarn', publicArgs, { - stdio: 'pipe' - }) - console.log(colors.green(`Successfully published ${pkgName}@${version}`)) - } catch (e: any) { - if (e.stderr.match(/previously published/)) { - console.log(colors.red(`Skipping already published: ${pkgName}`)) - } else { - throw e - } - } -} - main().catch((err) => { console.error(err) + process.exit(1) }) diff --git a/scripts/releaseUtils.ts b/scripts/releaseUtils.ts new file mode 100644 index 00000000000000..c2626a083552d0 --- /dev/null +++ b/scripts/releaseUtils.ts @@ -0,0 +1,215 @@ +/** + * modified from https://github.com/vuejs/core/blob/master/scripts/release.js + */ +import colors from 'picocolors' +import type { Options as ExecaOptions } from 'execa' +import execa from 'execa' +import { readFileSync, writeFileSync, existsSync, readdirSync } from 'fs' +import path from 'path' +import type { ReleaseType } from 'semver' +import semver from 'semver' + +export const args = require('minimist')(process.argv.slice(2)) + +export const isDryRun = !!args.dry + +if (isDryRun) { + console.log(colors.inverse(colors.yellow(' DRY RUN '))) + console.log() +} + +export const packages = [ + 'vite', + 'create-vite', + 'plugin-legacy', + 'plugin-react', + 'plugin-vue', + 'plugin-vue-jsx' +] + +export const versionIncrements: ReleaseType[] = [ + 'patch', + 'minor', + 'major' + // 'prepatch', + // 'preminor', + // 'premajor', + // 'prerelease' +] + +export function getPackageInfo(pkgName: string) { + const pkgDir = path.resolve(__dirname, '../packages/' + pkgName) + + if (!existsSync(pkgDir)) { + throw new Error(`Package ${pkgName} not found`) + } + + const pkgPath = path.resolve(pkgDir, 'package.json') + const pkg: { + name: string + version: string + private?: boolean + } = require(pkgPath) + const currentVersion = pkg.version + + if (pkg.private) { + throw new Error(`Package ${pkgName} is private`) + } + + return { + pkg, + pkgName, + pkgDir, + pkgPath, + currentVersion + } +} + +export async function run( + bin: string, + args: string[], + opts: ExecaOptions = {} +) { + return execa(bin, args, { stdio: 'inherit', ...opts }) +} + +export async function dryRun( + bin: string, + args: string[], + opts?: ExecaOptions +) { + return console.log( + colors.blue(`[dryrun] ${bin} ${args.join(' ')}`), + opts || '' + ) +} + +export const runIfNotDry = isDryRun ? dryRun : run + +export function step(msg: string) { + return console.log(colors.cyan(msg)) +} + +export function getVersionChoices(currentVersion: string) { + const currentBeta = currentVersion.includes('beta') + + const inc: (i: ReleaseType) => string = (i) => + semver.inc(currentVersion, i, 'beta')! + + const versionChoices = [ + { + title: 'next', + value: inc(currentBeta ? 'prerelease' : 'patch') + }, + ...(currentBeta + ? [ + { + title: 'stable', + value: inc('patch') + } + ] + : [ + { + title: 'beta-minor', + value: inc('preminor') + }, + { + title: 'beta-major', + value: inc('premajor') + }, + { + title: 'minor', + value: inc('minor') + }, + { + title: 'major', + value: inc('major') + } + ]), + { value: 'custom', title: 'custom' } + ].map((i) => { + i.title = `${i.title} (${i.value})` + return i + }) + + return versionChoices +} + +export function updateVersion(pkgPath: string, version: string): void { + const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8')) + pkg.version = version + writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n') +} + +export async function publishPackage( + pkdDir: string, + tag?: string +): Promise { + const publicArgs = ['publish', '--access', 'public'] + if (tag) { + publicArgs.push(`--tag`, tag) + } + await runIfNotDry('npm', publicArgs, { + stdio: 'pipe', + cwd: pkdDir + }) +} + +export async function getLatestTag(pkgName: string) { + const tags = (await run('git', ['tag'], { stdio: 'pipe' })).stdout + .split(/\n/) + .filter(Boolean) + const prefix = pkgName === 'vite' ? 'v' : `${pkgName}@` + return tags + .filter((tag) => tag.startsWith(prefix)) + .sort() + .reverse()[0] +} + +export async function logRecentCommits(pkgName: string) { + const tag = await getLatestTag(pkgName) + if (!tag) return + const sha = await run('git', ['rev-list', '-n', '1', tag], { + stdio: 'pipe' + }).then((res) => res.stdout.trim()) + console.log( + colors.bold( + `\n${colors.blue(`i`)} Commits of ${colors.green( + pkgName + )} since ${colors.green(tag)} ${colors.gray(`(${sha.slice(0, 5)})`)}` + ) + ) + await run( + 'git', + [ + '--no-pager', + 'log', + `${sha}..HEAD`, + '--oneline', + '--', + `packages/${pkgName}` + ], + { stdio: 'inherit' } + ) + console.log() +} + +export async function updateTemplateVersions(version: string) { + if (/beta|alpha|rc/.test(version)) return + + const dir = path.resolve(__dirname, '../packages/create-vite') + + const templates = readdirSync(dir).filter((dir) => + dir.startsWith('template-') + ) + for (const template of templates) { + const pkgPath = path.join(dir, template, `package.json`) + const pkg = require(pkgPath) + pkg.devDependencies.vite = `^` + version + if (template.startsWith('template-vue')) { + pkg.devDependencies['@vitejs/plugin-vue'] = + `^` + require('../packages/plugin-vue/package.json').version + } + writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n') + } +} From 8e923fae96de811ca9c621049c061d0fffcc52d1 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Sat, 12 Feb 2022 19:25:35 +0800 Subject: [PATCH 131/174] chore(ci): remove dry flag --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index f4df5af00cc23c..ffdd5ea6399ad5 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -32,6 +32,6 @@ jobs: run: pnpm install - name: Publish package - run: pnpm run ci-publish -- ${{ github.ref_name }} --dry + run: pnpm run ci-publish -- ${{ github.ref_name }} env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} From 254cc456c190086b2cba9c9e149720828ca3f00d Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Sat, 12 Feb 2022 19:31:21 +0800 Subject: [PATCH 132/174] chore: fix create-vite bumping script (#6881) --- scripts/release.ts | 2 +- scripts/releaseUtils.ts | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/release.ts b/scripts/release.ts index 6ec929a1d3a340..d536eca1f70586 100644 --- a/scripts/release.ts +++ b/scripts/release.ts @@ -75,7 +75,7 @@ async function main(): Promise { step('\nUpdating package version...') updateVersion(pkgPath, targetVersion) - if (pkgName === 'create-vite') updateTemplateVersions(targetVersion) + if (pkgName === 'create-vite') updateTemplateVersions() step('\nGenerating changelog...') const changelogArgs = [ diff --git a/scripts/releaseUtils.ts b/scripts/releaseUtils.ts index c2626a083552d0..b444835db7b6d0 100644 --- a/scripts/releaseUtils.ts +++ b/scripts/releaseUtils.ts @@ -194,8 +194,9 @@ export async function logRecentCommits(pkgName: string) { console.log() } -export async function updateTemplateVersions(version: string) { - if (/beta|alpha|rc/.test(version)) return +export async function updateTemplateVersions() { + const viteVersion = require('../packages/vite/package.json').version + if (/beta|alpha|rc/.test(viteVersion)) return const dir = path.resolve(__dirname, '../packages/create-vite') @@ -205,7 +206,7 @@ export async function updateTemplateVersions(version: string) { for (const template of templates) { const pkgPath = path.join(dir, template, `package.json`) const pkg = require(pkgPath) - pkg.devDependencies.vite = `^` + version + pkg.devDependencies.vite = `^` + viteVersion if (template.startsWith('template-vue')) { pkg.devDependencies['@vitejs/plugin-vue'] = `^` + require('../packages/plugin-vue/package.json').version From fcb53a365832449b9c23783781141498a4d0da58 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Sat, 12 Feb 2022 19:31:50 +0800 Subject: [PATCH 133/174] release: plugin-vue-jsx@1.3.6 --- 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 594f12c90f0909..8473e8f8af24f3 100644 --- a/packages/plugin-vue-jsx/CHANGELOG.md +++ b/packages/plugin-vue-jsx/CHANGELOG.md @@ -1,3 +1,12 @@ +## [1.3.6](https://github.com/vitejs/vite/compare/plugin-vue@2.2.0...plugin-vue@1.3.6) (2022-02-12) + + +### Bug Fixes + +* **deps:** update all non-major dependencies ([#6782](https://github.com/vitejs/vite/issues/6782)) ([e38be3e](https://github.com/vitejs/vite/commit/e38be3e6ca7bf79319d5d7188e1d347b1d6091ef)) + + + ## [1.3.5](https://github.com/vitejs/vite/compare/plugin-vue-jsx@1.3.4...plugin-vue-jsx@1.3.5) (2022-02-12) diff --git a/packages/plugin-vue-jsx/package.json b/packages/plugin-vue-jsx/package.json index dff19a227804d1..027f6d99180163 100644 --- a/packages/plugin-vue-jsx/package.json +++ b/packages/plugin-vue-jsx/package.json @@ -1,6 +1,6 @@ { "name": "@vitejs/plugin-vue-jsx", - "version": "1.3.5", + "version": "1.3.6", "license": "MIT", "author": "Evan You", "files": [ From 5e26d5f663a9c8888405ea495a64271b51a9046d Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Sat, 12 Feb 2022 19:47:58 +0800 Subject: [PATCH 134/174] chore: fix releasing token (#6882) --- .github/workflows/publish.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index ffdd5ea6399ad5..eb8f4513707872 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -26,11 +26,20 @@ jobs: uses: actions/setup-node@v2 with: node-version: 16.x + registry-url: https://registry.npmjs.org/ cache: "pnpm" - name: Install deps run: pnpm install + - name: Creating .npmrc + run: | + cat << EOF > "$HOME/.npmrc" + //registry.npmjs.org/:_authToken=$NPM_TOKEN + EOF + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + - name: Publish package run: pnpm run ci-publish -- ${{ github.ref_name }} env: From 78e84c80c0f49d6f7c8a0e10c4257a477a221280 Mon Sep 17 00:00:00 2001 From: Michael Oliver Date: Sat, 12 Feb 2022 20:50:18 +0000 Subject: [PATCH 135/174] feat: make `import.meta.glob` and `import.meta.globEager` generic (#5073) --- packages/vite/types/importMeta.d.ts | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/packages/vite/types/importMeta.d.ts b/packages/vite/types/importMeta.d.ts index 625e075333e48d..732310490350eb 100644 --- a/packages/vite/types/importMeta.d.ts +++ b/packages/vite/types/importMeta.d.ts @@ -59,25 +59,15 @@ interface ImportMeta { readonly env: ImportMetaEnv - glob( + glob( pattern: string, options?: AssertOptions - ): Record< - string, - () => Promise<{ - [key: string]: any - }> - > + ): Record Promise> - globEager( + globEager( pattern: string, options?: AssertOptions - ): Record< - string, - { - [key: string]: any - } - > + ): Record } interface ImportMetaEnv { From 62cbe68ab713d5aba626a1e3a4da46e8c2320bf3 Mon Sep 17 00:00:00 2001 From: Ivan Demchuk Date: Sun, 13 Feb 2022 11:58:49 +0200 Subject: [PATCH 136/174] perf: improve isFileReadable performance (#6868) --- packages/vite/src/node/utils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/vite/src/node/utils.ts b/packages/vite/src/node/utils.ts index d723b25a54122d..2b2ba6fb859107 100644 --- a/packages/vite/src/node/utils.ts +++ b/packages/vite/src/node/utils.ts @@ -422,8 +422,8 @@ export function writeFile( */ export function isFileReadable(filename: string): boolean { try { - fs.accessSync(filename, fs.constants.R_OK) - return true + const stat = fs.statSync(filename, { throwIfNoEntry: false }) + return !!stat } catch { return false } From 2eabcb9a30a413ff540cbdd60a919a0d1f72fb35 Mon Sep 17 00:00:00 2001 From: Jeff Yang <32727188+ydcjeff@users.noreply.github.com> Date: Sun, 13 Feb 2022 22:24:33 +0630 Subject: [PATCH 137/174] perf: lazy import preview function (#6898) --- packages/vite/src/node/cli.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vite/src/node/cli.ts b/packages/vite/src/node/cli.ts index 1b3af6b90e6f65..2a4f3a77918144 100644 --- a/packages/vite/src/node/cli.ts +++ b/packages/vite/src/node/cli.ts @@ -6,7 +6,6 @@ import type { ServerOptions } from './server' import type { LogLevel } from './logger' import { createLogger } from './logger' import { resolveConfig } from '.' -import { preview } from './preview' const cli = cac('vite') @@ -230,6 +229,7 @@ cli strictPort?: boolean } & GlobalCLIOptions ) => { + const { preview } = await import('./preview') try { const server = await preview({ root, From e385346c53b3bb54f2e1abcb7348e33d7e075fd4 Mon Sep 17 00:00:00 2001 From: ygj6 <7699524+ygj6@users.noreply.github.com> Date: Mon, 14 Feb 2022 11:49:36 +0800 Subject: [PATCH 138/174] feat: custom manifest file name (#6667) --- docs/config/index.md | 8 ++++---- packages/vite/src/node/build.ts | 4 ++-- packages/vite/src/node/cli.ts | 4 ++-- packages/vite/src/node/plugins/manifest.ts | 5 ++++- packages/vite/src/node/ssr/ssrManifestPlugin.ts | 5 ++++- 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/docs/config/index.md b/docs/config/index.md index 233e08b8f864e3..ba84c49b2f5820 100644 --- a/docs/config/index.md +++ b/docs/config/index.md @@ -772,19 +772,19 @@ export default defineConfig({ ### build.manifest -- **Type:** `boolean` +- **Type:** `boolean | string` - **Default:** `false` - **Related:** [Backend Integration](/guide/backend-integration) - When set to `true`, the build will also generate a `manifest.json` file that contains a mapping of non-hashed asset filenames to their hashed versions, which can then be used by a server framework to render the correct asset links. + When set to `true`, the build will also generate a `manifest.json` file that contains a mapping of non-hashed asset filenames to their hashed versions, which can then be used by a server framework to render the correct asset links. When the value is a string, it will be used as the manifest file name. ### build.ssrManifest -- **Type:** `boolean` +- **Type:** `boolean | string` - **Default:** `false` - **Related:** [Server-Side Rendering](/guide/ssr) - When set to `true`, the build will also generate a SSR manifest for determining style links and asset preload directives in production. + When set to `true`, the build will also generate a SSR manifest for determining style links and asset preload directives in production. When the value is a string, it will be used as the manifest file name. ### build.ssr diff --git a/packages/vite/src/node/build.ts b/packages/vite/src/node/build.ts index b9936f8583b46c..c8a1a0f17fa4a4 100644 --- a/packages/vite/src/node/build.ts +++ b/packages/vite/src/node/build.ts @@ -179,7 +179,7 @@ export interface BuildOptions { * ``` * @default false */ - manifest?: boolean + manifest?: boolean | string /** * Build in library mode. The value should be the global name of the lib in * UMD mode. This will produce esm + cjs + umd bundle formats with default @@ -195,7 +195,7 @@ export interface BuildOptions { * Generate SSR manifest for determining style links and asset preload * directives in production. */ - ssrManifest?: boolean + ssrManifest?: boolean | string /** * Set to false to disable reporting compressed chunk sizes. * Can slightly improve build speed. diff --git a/packages/vite/src/node/cli.ts b/packages/vite/src/node/cli.ts index 2a4f3a77918144..91b3d4e6bee998 100644 --- a/packages/vite/src/node/cli.ts +++ b/packages/vite/src/node/cli.ts @@ -149,8 +149,8 @@ cli `[boolean | "terser" | "esbuild"] enable/disable minification, ` + `or specify minifier to use (default: esbuild)` ) - .option('--manifest', `[boolean] emit build manifest json`) - .option('--ssrManifest', `[boolean] emit ssr manifest json`) + .option('--manifest [name]', `[boolean | string] emit build manifest json`) + .option('--ssrManifest [name]', `[boolean | string] emit ssr manifest json`) .option( '--emptyOutDir', `[boolean] force empty outDir when it's outside of root` diff --git a/packages/vite/src/node/plugins/manifest.ts b/packages/vite/src/node/plugins/manifest.ts index 2ce4869e67d98d..d6dceb507ca946 100644 --- a/packages/vite/src/node/plugins/manifest.ts +++ b/packages/vite/src/node/plugins/manifest.ts @@ -113,7 +113,10 @@ export function manifestPlugin(config: ResolvedConfig): Plugin { const outputLength = Array.isArray(output) ? output.length : 1 if (outputCount >= outputLength) { this.emitFile({ - fileName: `manifest.json`, + fileName: + typeof config.build.manifest === 'string' + ? config.build.manifest + : 'manifest.json', type: 'asset', source: JSON.stringify(manifest, null, 2) }) diff --git a/packages/vite/src/node/ssr/ssrManifestPlugin.ts b/packages/vite/src/node/ssr/ssrManifestPlugin.ts index e6811eae29b210..a92550e39d4ed0 100644 --- a/packages/vite/src/node/ssr/ssrManifestPlugin.ts +++ b/packages/vite/src/node/ssr/ssrManifestPlugin.ts @@ -96,7 +96,10 @@ export function ssrManifestPlugin(config: ResolvedConfig): Plugin { } this.emitFile({ - fileName: 'ssr-manifest.json', + fileName: + typeof config.build.ssrManifest === 'string' + ? config.build.ssrManifest + : 'ssr-manifest.json', type: 'asset', source: JSON.stringify(ssrManifest, null, 2) }) From 55eca7cf2750690d66eff8007bc1d6b5f0edb292 Mon Sep 17 00:00:00 2001 From: patak-dev Date: Mon, 14 Feb 2022 11:13:56 +0100 Subject: [PATCH 139/174] release: plugin-vue-jsx@1.3.7 --- 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 8473e8f8af24f3..0ad338dbd211eb 100644 --- a/packages/plugin-vue-jsx/CHANGELOG.md +++ b/packages/plugin-vue-jsx/CHANGELOG.md @@ -1,3 +1,12 @@ +## [1.3.7](https://github.com/vitejs/vite/compare/plugin-vue@2.2.0...plugin-vue@1.3.7) (2022-02-14) + + +### Bug Fixes + +* **deps:** update all non-major dependencies ([#6782](https://github.com/vitejs/vite/issues/6782)) ([e38be3e](https://github.com/vitejs/vite/commit/e38be3e6ca7bf79319d5d7188e1d347b1d6091ef)) + + + ## [1.3.6](https://github.com/vitejs/vite/compare/plugin-vue@2.2.0...plugin-vue@1.3.6) (2022-02-12) diff --git a/packages/plugin-vue-jsx/package.json b/packages/plugin-vue-jsx/package.json index 027f6d99180163..f8289b79f4c445 100644 --- a/packages/plugin-vue-jsx/package.json +++ b/packages/plugin-vue-jsx/package.json @@ -1,6 +1,6 @@ { "name": "@vitejs/plugin-vue-jsx", - "version": "1.3.6", + "version": "1.3.7", "license": "MIT", "author": "Evan You", "files": [ From e8c840abd2767445a5e49bab6540a66b941d7239 Mon Sep 17 00:00:00 2001 From: patak-dev Date: Mon, 14 Feb 2022 11:21:37 +0100 Subject: [PATCH 140/174] release: v2.8.2 --- packages/vite/CHANGELOG.md | 16 ++++++++++++++++ packages/vite/package.json | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/packages/vite/CHANGELOG.md b/packages/vite/CHANGELOG.md index 50925e58baffdb..13226de36642eb 100644 --- a/packages/vite/CHANGELOG.md +++ b/packages/vite/CHANGELOG.md @@ -1,3 +1,19 @@ +## [2.8.2](https://github.com/vitejs/vite/compare/v2.8.1...v2.8.2) (2022-02-14) + + +### Features + +* custom manifest file name ([#6667](https://github.com/vitejs/vite/issues/6667)) ([e385346](https://github.com/vitejs/vite/commit/e385346c53b3bb54f2e1abcb7348e33d7e075fd4)) +* make `import.meta.glob` and `import.meta.globEager` generic ([#5073](https://github.com/vitejs/vite/issues/5073)) ([78e84c8](https://github.com/vitejs/vite/commit/78e84c80c0f49d6f7c8a0e10c4257a477a221280)) + + +### Performance Improvements + +* improve isFileReadable performance ([#6868](https://github.com/vitejs/vite/issues/6868)) ([62cbe68](https://github.com/vitejs/vite/commit/62cbe68ab713d5aba626a1e3a4da46e8c2320bf3)) +* lazy import preview function ([#6898](https://github.com/vitejs/vite/issues/6898)) ([2eabcb9](https://github.com/vitejs/vite/commit/2eabcb9a30a413ff540cbdd60a919a0d1f72fb35)) + + + ## [2.8.1](https://github.com/vitejs/vite/compare/v2.8.0...v2.8.1) (2022-02-11) diff --git a/packages/vite/package.json b/packages/vite/package.json index 9bd14ca89a4d16..94029dc45cc008 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -1,6 +1,6 @@ { "name": "vite", - "version": "2.8.1", + "version": "2.8.2", "license": "MIT", "author": "Evan You", "description": "Native-ESM powered web dev build tool", From 0e58e72ab3b36156fb32bf983fe56c7621a11106 Mon Sep 17 00:00:00 2001 From: Zheeeng Date: Tue, 15 Feb 2022 15:21:55 +0800 Subject: [PATCH 141/174] chore: prefer using nullish-coalescing over or logic operator (#6790) --- packages/playground/testUtils.ts | 4 ++-- packages/vite/src/node/ssr/ssrManifestPlugin.ts | 2 +- packages/vite/src/node/ssr/ssrStacktrace.ts | 2 +- packages/vite/src/node/utils.ts | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/playground/testUtils.ts b/packages/playground/testUtils.ts index 3c6cba769b3ffe..0ae0c6e8766e95 100644 --- a/packages/playground/testUtils.ts +++ b/packages/playground/testUtils.ts @@ -56,7 +56,7 @@ async function toEl(el: string | ElementHandle): Promise { export async function getColor(el: string | ElementHandle): Promise { el = await toEl(el) const rgb = await el.evaluate((el) => getComputedStyle(el as Element).color) - return hexToNameMap[rgbToHex(rgb)] || rgb + return hexToNameMap[rgbToHex(rgb)] ?? rgb } export async function getBg(el: string | ElementHandle): Promise { @@ -119,7 +119,7 @@ export async function untilUpdated( if (isBuild && !runInBuild) return const maxTries = process.env.CI ? 100 : 50 for (let tries = 0; tries < maxTries; tries++) { - const actual = (await poll()) || '' + const actual = (await poll()) ?? '' if (actual.indexOf(expected) > -1 || tries === maxTries - 1) { expect(actual).toMatch(expected) break diff --git a/packages/vite/src/node/ssr/ssrManifestPlugin.ts b/packages/vite/src/node/ssr/ssrManifestPlugin.ts index a92550e39d4ed0..351c91349a3ca3 100644 --- a/packages/vite/src/node/ssr/ssrManifestPlugin.ts +++ b/packages/vite/src/node/ssr/ssrManifestPlugin.ts @@ -29,7 +29,7 @@ export function ssrManifestPlugin(config: ResolvedConfig): Plugin { for (const id in chunk.modules) { const normalizedId = normalizePath(relative(config.root, id)) const mappedChunks = - ssrManifest[normalizedId] || (ssrManifest[normalizedId] = []) + ssrManifest[normalizedId] ?? (ssrManifest[normalizedId] = []) if (!chunk.isEntry) { mappedChunks.push(base + chunk.fileName) } diff --git a/packages/vite/src/node/ssr/ssrStacktrace.ts b/packages/vite/src/node/ssr/ssrStacktrace.ts index 75fcd8d2933c6f..0d847cb7da7041 100644 --- a/packages/vite/src/node/ssr/ssrStacktrace.ts +++ b/packages/vite/src/node/ssr/ssrStacktrace.ts @@ -46,7 +46,7 @@ export function ssrRewriteStacktrace( return input } - const source = `${pos.source}:${pos.line || 0}:${pos.column || 0}` + const source = `${pos.source}:${pos.line ?? 0}:${pos.column ?? 0}` if (!varName || varName === 'eval') { return ` at ${source}` } else { diff --git a/packages/vite/src/node/utils.ts b/packages/vite/src/node/utils.ts index 2b2ba6fb859107..3012e6d57e6c65 100644 --- a/packages/vite/src/node/utils.ts +++ b/packages/vite/src/node/utils.ts @@ -222,7 +222,7 @@ export function injectQuery(url: string, queryToInject: string): string { } pathname = decodeURIComponent(pathname) return `${pathname}?${queryToInject}${search ? `&` + search.slice(1) : ''}${ - hash || '' + hash ?? '' }` } @@ -518,7 +518,7 @@ export async function processSrcSet( ) return ret.reduce((prev, { url, descriptor }, index) => { - descriptor = descriptor || '' + descriptor ??= '' return (prev += url + ` ${descriptor}${index === ret.length - 1 ? '' : ', '}`) }, '') From 3480f27d4db7f7ebd27164d9185e7b387762274e Mon Sep 17 00:00:00 2001 From: Zheeeng Date: Tue, 15 Feb 2022 15:22:33 +0800 Subject: [PATCH 142/174] chore(types): correct typing in jestPerTestSetup (#6786) --- scripts/jestPerTestSetup.ts | 24 +++++++++++++----------- scripts/tsconfig.json | 2 +- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/scripts/jestPerTestSetup.ts b/scripts/jestPerTestSetup.ts index 89209c3ffcbf69..9c15edf9f059bf 100644 --- a/scripts/jestPerTestSetup.ts +++ b/scripts/jestPerTestSetup.ts @@ -10,8 +10,7 @@ import type { Logger } from 'vite' import { createServer, build } from 'vite' -import type { Page } from 'playwright-chromium' -// eslint-disable-next-line node/no-extraneous-import +import type { Page, ConsoleMessage } from 'playwright-chromium' import type { RollupError, RollupWatcher, RollupWatcherEvent } from 'rollup' const isBuildTest = !!process.env.VITE_TEST_BUILD @@ -45,13 +44,15 @@ let server: ViteDevServer | http.Server let tempDir: string let rootDir: string -const setBeforeAllError = (err) => ((global as any).beforeAllError = err) -const getBeforeAllError = () => (global as any).beforeAllError +const setBeforeAllError = (err: Error | null) => { + global.beforeAllError = err +} +const getBeforeAllError = () => global.beforeAllError //init with null so old errors don't carry over setBeforeAllError(null) -const logs = ((global as any).browserLogs = []) -const onConsole = (msg) => { +const logs: string[] = (global.browserLogs = []) +const onConsole = (msg: ConsoleMessage) => { logs.push(msg.text()) } @@ -145,7 +146,7 @@ beforeAll(async () => { await page.goto(url) } } - } catch (e) { + } catch (e: any) { // jest doesn't exit if our setup has error here // https://github.com/facebook/jest/issues/2713 setBeforeAllError(e) @@ -172,11 +173,12 @@ afterAll(async () => { function startStaticServer(): Promise { // check if the test project has base config const configFile = resolve(rootDir, 'vite.config.js') - let config: UserConfig + let config: UserConfig | undefined try { config = require(configFile) } catch (e) {} - const base = (config?.base || '/') === '/' ? '' : config.base + // fallback internal base to '' + const base = (config?.base ?? '/') === '/' ? '' : config?.base ?? '' // @ts-ignore if (config && config.__test__) { @@ -219,10 +221,10 @@ export async function notifyRebuildComplete( watcher: RollupWatcher ): Promise { let callback: (event: RollupWatcherEvent) => void - await new Promise((resolve, reject) => { + await new Promise((resolve, reject) => { callback = (event) => { if (event.code === 'END') { - resolve(true) + resolve() } } watcher.on('event', callback) diff --git a/scripts/tsconfig.json b/scripts/tsconfig.json index 6a32b899cb43ab..5c70fcc7f15823 100644 --- a/scripts/tsconfig.json +++ b/scripts/tsconfig.json @@ -8,6 +8,6 @@ "esModuleInterop": true, "skipLibCheck": true, "forceConsistentCasingInFileNames": true, - "types": ["node"] + "types": ["node", "jest"] } } From a9a1ae2db6a81a2fd31db370b58686e442047d9e Mon Sep 17 00:00:00 2001 From: patak Date: Tue, 15 Feb 2022 17:17:28 +0100 Subject: [PATCH 143/174] fix: revert update dotenv-expand #6703, fix #6858 (#6934) --- packages/vite/package.json | 2 +- packages/vite/src/node/config.ts | 2 +- pnpm-lock.yaml | 9 ++++----- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/packages/vite/package.json b/packages/vite/package.json index 94029dc45cc008..728f6e00b84c7f 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -87,7 +87,7 @@ "cross-spawn": "^7.0.3", "debug": "^4.3.3", "dotenv": "^14.3.2", - "dotenv-expand": "^6.0.1", + "dotenv-expand": "^5.1.0", "es-module-lexer": "^0.9.3", "estree-walker": "^2.0.2", "etag": "^1.8.1", diff --git a/packages/vite/src/node/config.ts b/packages/vite/src/node/config.ts index f73f4fb8662d6b..2a607dd6ba9948 100644 --- a/packages/vite/src/node/config.ts +++ b/packages/vite/src/node/config.ts @@ -21,7 +21,7 @@ import { resolvePlugins } from './plugins' import colors from 'picocolors' import type { ESBuildOptions } from './plugins/esbuild' import dotenv from 'dotenv' -import { expand as dotenvExpand } from 'dotenv-expand' +import dotenvExpand from 'dotenv-expand' import type { Alias, AliasOptions } from 'types/alias' import { CLIENT_ENTRY, ENV_ENTRY, DEFAULT_ASSETS_RE } from './constants' import type { InternalResolveOptions, ResolveOptions } from './plugins/resolve' diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ab4083cb6a7635..418cf16f0eb6b1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -770,7 +770,7 @@ importers: cross-spawn: ^7.0.3 debug: ^4.3.3 dotenv: ^14.3.2 - dotenv-expand: ^6.0.1 + dotenv-expand: ^5.1.0 es-module-lexer: ^0.9.3 esbuild: ^0.14.14 estree-walker: ^2.0.2 @@ -848,7 +848,7 @@ importers: cross-spawn: 7.0.3 debug: 4.3.3 dotenv: 14.3.2 - dotenv-expand: 6.0.1 + dotenv-expand: 5.1.0 es-module-lexer: 0.9.3 estree-walker: 2.0.2 etag: 1.8.1 @@ -4212,9 +4212,8 @@ packages: is-obj: 2.0.0 dev: true - /dotenv-expand/6.0.1: - resolution: {integrity: sha512-GNHcCOyRKLCXWnH3L/+sJ04PQxxgTOZDCPuQQnqkqPMGIilyoxHZ2JUNmh2VWKCfzVKH/AZsqcbuSYlDDVb/xw==} - engines: {node: '>=12'} + /dotenv-expand/5.1.0: + resolution: {integrity: sha512-YXQl1DSa4/PQyRfgrv6aoNjhasp/p4qs9FjJ4q4cQk+8m4r6k4ZSiEyytKG8f8W9gi8WsQtIObNmKd+tMzNTmA==} dev: true /dotenv/14.3.2: From ac9652b0fc9aa947da4a62ff9553e23aee1dee8f Mon Sep 17 00:00:00 2001 From: patak-dev Date: Tue, 15 Feb 2022 18:07:13 +0100 Subject: [PATCH 144/174] release: v2.8.3 --- packages/vite/CHANGELOG.md | 9 +++++++++ packages/vite/package.json | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/vite/CHANGELOG.md b/packages/vite/CHANGELOG.md index 13226de36642eb..fb262e6e13e783 100644 --- a/packages/vite/CHANGELOG.md +++ b/packages/vite/CHANGELOG.md @@ -1,3 +1,12 @@ +## [2.8.3](https://github.com/vitejs/vite/compare/v2.8.2...v2.8.3) (2022-02-15) + + +### Bug Fixes + +* revert update dotenv-expand [#6703](https://github.com/vitejs/vite/issues/6703), fix [#6858](https://github.com/vitejs/vite/issues/6858) ([#6934](https://github.com/vitejs/vite/issues/6934)) ([a9a1ae2](https://github.com/vitejs/vite/commit/a9a1ae2db6a81a2fd31db370b58686e442047d9e)) + + + ## [2.8.2](https://github.com/vitejs/vite/compare/v2.8.1...v2.8.2) (2022-02-14) diff --git a/packages/vite/package.json b/packages/vite/package.json index 728f6e00b84c7f..0eff7b535822df 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -1,6 +1,6 @@ { "name": "vite", - "version": "2.8.2", + "version": "2.8.3", "license": "MIT", "author": "Evan You", "description": "Native-ESM powered web dev build tool", From 3f27d58036bfe4149e563a105c08c2d4771db288 Mon Sep 17 00:00:00 2001 From: patak Date: Tue, 15 Feb 2022 22:33:41 +0100 Subject: [PATCH 145/174] chore(deps): avoid updating dotenv-expand to v6+ (#6936) --- .github/renovate.json5 | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/renovate.json5 b/.github/renovate.json5 index 763dfcfc467d9d..06fe0e7ea2aaff 100644 --- a/.github/renovate.json5 +++ b/.github/renovate.json5 @@ -28,6 +28,7 @@ "react-router", // `react-router:v6.0.0+` has breaking changes "react-router-dom", // `react-router-dom:v6.0.0+` has breaking changes "source-map", // `source-map:v0.7.0+` needs more investigation + "dotenv-expand", // `dotenv-expand:6.0.0+` has breaking changes (#6858) // ESM Only => https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c#how-can-i-move-my-commonjs-project-to-esm "node-fetch", From e2349569cf96e506e0d5fff1d043727a77fdad70 Mon Sep 17 00:00:00 2001 From: ocavue Date: Wed, 16 Feb 2022 21:20:45 +0800 Subject: [PATCH 146/174] docs: add backticks (#6945) --- docs/config/index.md | 2 +- packages/vite/src/node/config.ts | 2 +- packages/vite/src/node/optimizer/index.ts | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/config/index.md b/docs/config/index.md index ba84c49b2f5820..d4ee7a96a6fa67 100644 --- a/docs/config/index.md +++ b/docs/config/index.md @@ -923,7 +923,7 @@ export default defineConfig({ - **Type:** `string | string[]` - By default, Vite will crawl your index.html to detect dependencies that need to be pre-bundled. If build.rollupOptions.input is specified, Vite will crawl those entry points instead. + By default, Vite will crawl your `index.html` to detect dependencies that need to be pre-bundled. If `build.rollupOptions.input` is specified, Vite will crawl those entry points instead. If neither of these fit your needs, you can specify custom entries using this option - the value should be a [fast-glob pattern](https://github.com/mrmlnc/fast-glob#basic-syntax) or array of patterns that are relative from Vite project root. This will overwrite default entries inference. diff --git a/packages/vite/src/node/config.ts b/packages/vite/src/node/config.ts index 2a607dd6ba9948..fbda8d5166cb1b 100644 --- a/packages/vite/src/node/config.ts +++ b/packages/vite/src/node/config.ts @@ -92,7 +92,7 @@ export interface UserConfig { * the performance. You can use `--force` flag or manually delete the directory * to regenerate the cache files. The value can be either an absolute file * system path or a path relative to . - * Default to `.vite` when no package.json is detected. + * Default to `.vite` when no `package.json` is detected. * @default 'node_modules/.vite' */ cacheDir?: string diff --git a/packages/vite/src/node/optimizer/index.ts b/packages/vite/src/node/optimizer/index.ts index 6102e832841a89..c13a26c63b3c1c 100644 --- a/packages/vite/src/node/optimizer/index.ts +++ b/packages/vite/src/node/optimizer/index.ts @@ -30,8 +30,8 @@ export type ExportsData = ReturnType & { export interface DepOptimizationOptions { /** - * By default, Vite will crawl your index.html to detect dependencies that - * need to be pre-bundled. If build.rollupOptions.input is specified, Vite + * By default, Vite will crawl your `index.html` to detect dependencies that + * need to be pre-bundled. If `build.rollupOptions.input` is specified, Vite * will crawl those entry points instead. * * If neither of these fit your needs, you can specify custom entries using From 4120908c518c8a89354aa93ffd6ebf5436123134 Mon Sep 17 00:00:00 2001 From: yoho <907415276@qq.com> Date: Thu, 17 Feb 2022 21:14:06 +0800 Subject: [PATCH 147/174] docs: import.meta.glob support ?raw (#6953) Co-authored-by: ygj6 <7699524+ygj6@users.noreply.github.com> --- docs/guide/features.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/docs/guide/features.md b/docs/guide/features.md index da8e3b1de092b2..c7fd2424b53cb1 100644 --- a/docs/guide/features.md +++ b/docs/guide/features.md @@ -298,6 +298,22 @@ const modules = { } ``` +`import.meta.glob` and `import.meta.globEager` also support importing files as strings, similar to [Importing Asset as String](https://vitejs.dev/guide/assets.html#importing-asset-as-string). Here, we use the [Import Assertions](https://github.com/tc39/proposal-import-assertions#synopsis) syntax to import. + +```js +const modules = import.meta.glob('./dir/*.js', { assert: { type: 'raw' } }) +``` + +The above will be transformed into the following: + +```js +// code produced by vite +const modules = { + './dir/foo.js': '{\n "msg": "foo"\n}\n', + './dir/bar.js': '{\n "msg": "bar"\n}\n' +} +``` + Note that: - This is a Vite-only feature and is not a web or ES standard. From 08cf4e106534481fd8eff2e6e4a986270c28f894 Mon Sep 17 00:00:00 2001 From: Sepush Date: Thu, 17 Feb 2022 21:15:51 +0800 Subject: [PATCH 148/174] chore(ci): update issue-helper version (#6955) --- .github/workflows/issue-close-require.yml | 2 +- .github/workflows/issue-labeled.yml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/issue-close-require.yml b/.github/workflows/issue-close-require.yml index 02ac374b06c426..97f9dd3a449c3c 100644 --- a/.github/workflows/issue-close-require.yml +++ b/.github/workflows/issue-close-require.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest steps: - name: need reproduction - uses: actions-cool/issues-helper@v2 + uses: actions-cool/issues-helper@v3 with: actions: "close-issues" token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/issue-labeled.yml b/.github/workflows/issue-labeled.yml index a63021952fd73d..b6f3919dfa63a2 100644 --- a/.github/workflows/issue-labeled.yml +++ b/.github/workflows/issue-labeled.yml @@ -10,7 +10,7 @@ jobs: steps: - name: contribution welcome if: github.event.label.name == 'contribution welcome' || github.event.label.name == 'help wanted' - uses: actions-cool/issues-helper@v2 + uses: actions-cool/issues-helper@v3 with: actions: "create-comment, remove-labels" token: ${{ secrets.GITHUB_TOKEN }} @@ -21,7 +21,7 @@ jobs: - name: remove pending if: github.event.label.name == 'enhancement' || github.event.label.name == 'bug' || (contains(github.event.label.name, 'pending triage') == false && startsWith(github.event.label.name, 'bug:') == true) - uses: actions-cool/issues-helper@v2 + uses: actions-cool/issues-helper@v3 with: actions: "remove-labels" token: ${{ secrets.GITHUB_TOKEN }} @@ -30,7 +30,7 @@ jobs: - name: need reproduction if: github.event.label.name == 'need reproduction' - uses: actions-cool/issues-helper@v2 + uses: actions-cool/issues-helper@v3 with: actions: "create-comment, remove-labels" token: ${{ secrets.GITHUB_TOKEN }} From 3f3f4737d5242547fb83f8d2522ba91cc1d96fb0 Mon Sep 17 00:00:00 2001 From: Nurettin Kaya Date: Thu, 17 Feb 2022 13:24:44 -0800 Subject: [PATCH 149/174] fix: normalize postcss dependency messages (#6959) --- .../tailwind/__test__/tailwind.spec.ts | 22 ++++++++++++++++++- packages/playground/tailwind/src/App.vue | 2 +- .../playground/tailwind/tailwind.config.js | 7 +++++- packages/vite/src/node/plugins/css.ts | 2 +- 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/packages/playground/tailwind/__test__/tailwind.spec.ts b/packages/playground/tailwind/__test__/tailwind.spec.ts index 105eb245bf207e..47f6b7ccf49037 100644 --- a/packages/playground/tailwind/__test__/tailwind.spec.ts +++ b/packages/playground/tailwind/__test__/tailwind.spec.ts @@ -5,7 +5,7 @@ test('should render', async () => { }) if (!isBuild) { - test('regenerate CSS and HMR', async () => { + test('regenerate CSS and HMR (glob pattern)', async () => { browserLogs.length = 0 const el = await page.$('#pagetitle') const el2 = await page.$('#helloroot') @@ -37,4 +37,24 @@ if (!isBuild) { browserLogs.length = 0 }) + + test('regenerate CSS and HMR (relative path)', async () => { + browserLogs.length = 0 + const el = await page.$('h1') + + expect(await getColor(el)).toBe('black') + + editFile('src/App.vue', (code) => + code.replace('text-black', 'text-[rgb(11,22,33)]') + ) + + await untilUpdated(() => getColor(el), 'rgb(11, 22, 33)') + + expect(browserLogs).toMatchObject([ + '[vite] css hot updated: /index.css', + '[vite] hot updated: /src/App.vue' + ]) + + browserLogs.length = 0 + }) } diff --git a/packages/playground/tailwind/src/App.vue b/packages/playground/tailwind/src/App.vue index b032d5e0db77e3..25835fc414a06f 100644 --- a/packages/playground/tailwind/src/App.vue +++ b/packages/playground/tailwind/src/App.vue @@ -1,6 +1,6 @@