From b4ebe7ae8b904f28cdda33caf87bc05718d3a08a Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 26 Dec 2023 10:52:45 +0800 Subject: [PATCH 01/18] fix(warning): ensure prod hydration warnings actually work --- packages/runtime-core/src/warning.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/runtime-core/src/warning.ts b/packages/runtime-core/src/warning.ts index 8e93d9efe59..67e4ee31255 100644 --- a/packages/runtime-core/src/warning.ts +++ b/packages/runtime-core/src/warning.ts @@ -31,7 +31,7 @@ export function popWarningContext() { } export function warn(msg: string, ...args: any[]) { - if (!__DEV__) return + if (!__DEV__ && !__FEATURE_PROD_HYDRATION_MISMATCH_DETAILS__) return // avoid props formatting or warn handler tracking deps that might be mutated // during patch, leading to infinite recursion. From ee68c525f06e02c78655ade680a579e4cf85a314 Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 26 Dec 2023 11:03:45 +0800 Subject: [PATCH 02/18] build: avoid exporting setDevTools in global prod build --- packages/runtime-core/src/devtools.ts | 2 +- packages/runtime-core/src/index.ts | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/runtime-core/src/devtools.ts b/packages/runtime-core/src/devtools.ts index 240a4aa04a7..bf6f09f3267 100644 --- a/packages/runtime-core/src/devtools.ts +++ b/packages/runtime-core/src/devtools.ts @@ -21,7 +21,7 @@ enum DevtoolsHooks { PERFORMANCE_END = 'perf:end' } -interface DevtoolsHook { +export interface DevtoolsHook { enabled?: boolean emit: (event: string, ...payload: any[]) => void on: (event: string, handler: Function) => void diff --git a/packages/runtime-core/src/index.ts b/packages/runtime-core/src/index.ts index 06300cbf68f..232afba46f1 100644 --- a/packages/runtime-core/src/index.ts +++ b/packages/runtime-core/src/index.ts @@ -150,7 +150,18 @@ export const ErrorTypeStrings = ( ) as typeof _ErrorTypeStrings // For devtools -export { devtools, setDevtoolsHook } from './devtools' +import { + devtools as _devtools, + setDevtoolsHook as _setDevtoolsHook, + DevtoolsHook +} from './devtools' + +export const devtools = ( + __DEV__ || __FEATURE_PROD_DEVTOOLS__ ? _devtools : undefined +) as DevtoolsHook +export const setDevtoolsHook = ( + __DEV__ || __FEATURE_PROD_DEVTOOLS__ ? _setDevtoolsHook : NOOP +) as typeof _setDevtoolsHook // Types ------------------------------------------------------------------------- @@ -377,6 +388,7 @@ import { softAssertCompatEnabled } from './compat/compatConfig' import { resolveFilter as _resolveFilter } from './helpers/resolveAssets' +import { NOOP } from '@vue/shared' /** * @internal only exposed in compat builds From 176302c01e678238840bd3c2a8d7851876ce61bb Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 26 Dec 2023 11:29:06 +0800 Subject: [PATCH 03/18] chore(deps): update autofix-ci/action digest to ea32e3a (#9910) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/autofix.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/autofix.yml b/.github/workflows/autofix.yml index 5e7bb63c22f..d7f11b0d220 100644 --- a/.github/workflows/autofix.yml +++ b/.github/workflows/autofix.yml @@ -30,4 +30,4 @@ jobs: - name: Run prettier run: pnpm run format - - uses: autofix-ci/action@bee19d72e71787c12ca0f29de72f2833e437e4c9 + - uses: autofix-ci/action@ea32e3a12414e6d3183163c3424a7d7a8631ad84 From f96c413e8ef2f24cacda5bb499492922f62c6e8b Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 26 Dec 2023 11:29:22 +0800 Subject: [PATCH 04/18] fix(deps): update dependency @vue/repl to ^3.1.0 (#9911) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- packages/sfc-playground/package.json | 2 +- pnpm-lock.yaml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/sfc-playground/package.json b/packages/sfc-playground/package.json index 6900eaf78f0..0755c46fb04 100644 --- a/packages/sfc-playground/package.json +++ b/packages/sfc-playground/package.json @@ -13,7 +13,7 @@ "vite": "^5.0.5" }, "dependencies": { - "@vue/repl": "^3.0.0", + "@vue/repl": "^3.1.0", "file-saver": "^2.0.5", "jszip": "^3.10.1", "vue": "workspace:*" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 60a01d9826f..d0fadc5e0c4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -357,8 +357,8 @@ importers: packages/sfc-playground: dependencies: '@vue/repl': - specifier: ^3.0.0 - version: 3.0.0 + specifier: ^3.1.0 + version: 3.1.0 file-saver: specifier: ^2.0.5 version: 2.0.5 @@ -1780,8 +1780,8 @@ packages: engines: {node: '>= 0.12.0'} dev: true - /@vue/repl@3.0.0: - resolution: {integrity: sha512-tGYibiftMo5yEuIKPWVsNuuNDejjJk0JQmvKtTm12KNLFqtGD7fWoGv1qUzcN9EAxwVeDgnT9ljRgqGVgZkyEg==} + /@vue/repl@3.1.0: + resolution: {integrity: sha512-lnR010NTkysg71Z0TVsFCTfiF5ARZbyohqymGpOxOrSuSI4o9RlSvWH6YmJdv9OHm5j69HKLVVUhXlCScMCQrg==} dev: false /@zeit/schemas@2.29.0: From 0695c69e0dfaf99882a623fe75b433c9618ea648 Mon Sep 17 00:00:00 2001 From: yangxiuxiu <79584569+RicardoErii@users.noreply.github.com> Date: Tue, 26 Dec 2023 11:57:50 +0800 Subject: [PATCH 05/18] fix(types): fix distribution of union types when unwrapping setup bindings (#9909) close #9903 --- packages/dts-test/ref.test-d.ts | 8 +++++++- packages/reactivity/src/ref.ts | 10 +++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/dts-test/ref.test-d.ts b/packages/dts-test/ref.test-d.ts index 62bad77c2ee..fc3c9e65e4c 100644 --- a/packages/dts-test/ref.test-d.ts +++ b/packages/dts-test/ref.test-d.ts @@ -244,13 +244,19 @@ expectType(p1) // proxyRefs: `ShallowUnwrapRef` const r2 = { a: ref(1), + c: computed(() => 1), + u: undefined, obj: { k: ref('foo') - } + }, + union: Math.random() > 0 - 5 ? ref({ name: 'yo' }) : null } const p2 = proxyRefs(r2) expectType(p2.a) +expectType(p2.c) +expectType(p2.u) expectType>(p2.obj.k) +expectType<{ name: string } | null>(p2.union) // toRef and toRefs { diff --git a/packages/reactivity/src/ref.ts b/packages/reactivity/src/ref.ts index e156a2e1134..6a584090efc 100644 --- a/packages/reactivity/src/ref.ts +++ b/packages/reactivity/src/ref.ts @@ -477,15 +477,11 @@ type BaseTypes = string | number | boolean export interface RefUnwrapBailTypes {} export type ShallowUnwrapRef = { - [K in keyof T]: T[K] extends Ref - ? V // if `V` is `unknown` that means it does not extend `Ref` and is undefined - : T[K] extends Ref | undefined - ? unknown extends V - ? undefined - : V | undefined - : T[K] + [K in keyof T]: DistrubuteRef } +type DistrubuteRef = T extends Ref ? V : T + export type UnwrapRef = T extends ShallowRef ? V : T extends Ref From 5fa4b65a7d7a5d9fc9034d22cbdc8fad67def730 Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 26 Dec 2023 14:59:34 +0800 Subject: [PATCH 06/18] chore: use consistent file names for scripts --- .github/contributing.md | 2 +- package.json | 2 +- scripts/{setupVitest.ts => setup-vitest.ts} | 0 scripts/{verifyCommit.js => verify-commit.js} | 0 vitest.config.ts | 2 +- 5 files changed, 3 insertions(+), 3 deletions(-) rename scripts/{setupVitest.ts => setup-vitest.ts} (100%) rename scripts/{verifyCommit.js => verify-commit.js} (100%) diff --git a/.github/contributing.md b/.github/contributing.md index 5e386fec2e5..da1bd5ec453 100644 --- a/.github/contributing.md +++ b/.github/contributing.md @@ -86,7 +86,7 @@ The project uses [simple-git-hooks](https://github.com/toplenboren/simple-git-ho - Type check the entire project - Automatically format changed files using Prettier -- Verify commit message format (logic in `scripts/verifyCommit.js`) +- Verify commit message format (logic in `scripts/verify-commit.js`) ## Scripts diff --git a/package.json b/package.json index 3371d00a6e2..7c5e14746e8 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ }, "simple-git-hooks": { "pre-commit": "pnpm lint-staged && pnpm check", - "commit-msg": "node scripts/verifyCommit.js" + "commit-msg": "node scripts/verify-commit.js" }, "lint-staged": { "*.{js,json}": [ diff --git a/scripts/setupVitest.ts b/scripts/setup-vitest.ts similarity index 100% rename from scripts/setupVitest.ts rename to scripts/setup-vitest.ts diff --git a/scripts/verifyCommit.js b/scripts/verify-commit.js similarity index 100% rename from scripts/verifyCommit.js rename to scripts/verify-commit.js diff --git a/vitest.config.ts b/vitest.config.ts index 53842ae327a..e6839a09eed 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -25,7 +25,7 @@ export default defineConfig({ plugins: [codspeedPlugin()], test: { globals: true, - setupFiles: 'scripts/setupVitest.ts', + setupFiles: 'scripts/setup-vitest.ts', environmentMatchGlobs: [ ['packages/{vue,vue-compat,runtime-dom}/**', 'jsdom'] ], From 25c726eca81fc384b41fafbeba5e8dfcda1f030f Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 26 Dec 2023 15:06:56 +0800 Subject: [PATCH 07/18] feat(compiler-sfc): export aggregated error messages for compiler-core and compiler-dom --- packages/compiler-sfc/src/index.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/compiler-sfc/src/index.ts b/packages/compiler-sfc/src/index.ts index 7297acbed76..98b01c4bec1 100644 --- a/packages/compiler-sfc/src/index.ts +++ b/packages/compiler-sfc/src/index.ts @@ -12,6 +12,17 @@ import { SFCParseResult, parseCache as _parseCache } from './parse' // #9521 export parseCache as a simple map to avoid exposing LRU types export const parseCache = _parseCache as Map +// error messages +import { + errorMessages as coreErrorMessages, + DOMErrorMessages +} from '@vue/compiler-dom' + +export const errorMessages = { + ...coreErrorMessages, + ...DOMErrorMessages +} + // Utilities export { parse as babelParse } from '@babel/parser' import MagicString from 'magic-string' From 73ae6adbb1de7bb19722071c3129257849ee3947 Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 26 Dec 2023 15:26:29 +0800 Subject: [PATCH 08/18] refactor: adjust warn method treeshaking --- packages/runtime-core/src/index.ts | 4 +++- packages/runtime-core/src/warning.ts | 2 -- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/runtime-core/src/index.ts b/packages/runtime-core/src/index.ts index 232afba46f1..422d7e772a7 100644 --- a/packages/runtime-core/src/index.ts +++ b/packages/runtime-core/src/index.ts @@ -116,7 +116,9 @@ export { useSSRContext, ssrContextKey } from './helpers/useSsrContext' export { createRenderer, createHydrationRenderer } from './renderer' export { queuePostFlushCb } from './scheduler' -export { warn } from './warning' +import { warn as _warn } from './warning' +export const warn = (__DEV__ ? _warn : NOOP) as typeof _warn + /** @internal */ export { assertNumber } from './warning' export { diff --git a/packages/runtime-core/src/warning.ts b/packages/runtime-core/src/warning.ts index 67e4ee31255..45284fc70c7 100644 --- a/packages/runtime-core/src/warning.ts +++ b/packages/runtime-core/src/warning.ts @@ -31,8 +31,6 @@ export function popWarningContext() { } export function warn(msg: string, ...args: any[]) { - if (!__DEV__ && !__FEATURE_PROD_HYDRATION_MISMATCH_DETAILS__) return - // avoid props formatting or warn handler tracking deps that might be mutated // during patch, leading to infinite recursion. pauseTracking() From 897112abcc8c6c63208c49a28f36eeb7129d11f4 Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 26 Dec 2023 15:34:40 +0800 Subject: [PATCH 09/18] ci: verify common treeshaking issues in CI --- .github/workflows/ci.yml | 3 +++ scripts/verify-treeshaking.js | 49 +++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 scripts/verify-treeshaking.js diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 717bc1079fc..e458fbd57f3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -85,6 +85,9 @@ jobs: - name: Run e2e tests run: pnpm run test-e2e + - name: verify treeshaking + run: node scripts/verify-treeshaking.js + lint-and-test-dts: runs-on: ubuntu-latest if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository diff --git a/scripts/verify-treeshaking.js b/scripts/verify-treeshaking.js new file mode 100644 index 00000000000..e6480d20182 --- /dev/null +++ b/scripts/verify-treeshaking.js @@ -0,0 +1,49 @@ +// @ts-check +import fs from 'node:fs' +import { execa } from 'execa' + +execa('node', ['scripts/build.js', 'vue', '-f', 'global-runtime']).then(() => { + const errors = [] + + const devBuild = fs.readFileSync( + 'packages/vue/dist/vue.runtime.global.js', + 'utf-8' + ) + + if (devBuild.includes('__spreadValues')) { + errors.push( + 'dev build contains unexpected esbuild object spread helper.\n' + + 'This means { ...obj } syntax is used in runtime code. This should be ' + + 'refactoed to use the `extend` helper to avoid the extra code.' + ) + } + + const prodBuild = fs.readFileSync( + 'packages/vue/dist/vue.runtime.global.prod.js', + 'utf-8' + ) + + if (prodBuild.includes('Vue warn')) { + errors.push( + 'prod build contains unexpected warning-related code.\n' + + 'This means there are calls of warn() that are not guarded by the __DEV__ condition.' + ) + } + + if ( + prodBuild.includes('html,body,base') || + prodBuild.includes('svg,animate,animateMotion') || + prodBuild.includes('annotation,annotation-xml,maction') + ) { + errors.push( + 'prod build contains unexpected domTagConifg lists.\n' + + 'This means helpers like isHTMLTag() is used in runtime code paths when it should be compiler-only.' + ) + } + + if (errors.length) { + throw new Error( + `Found the following treeshaking errors:\n\n- ${errors.join('\n\n- ')}` + ) + } +}) From 4c88ff73b66987b3aedb20fcac962ad433482961 Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 26 Dec 2023 15:39:22 +0800 Subject: [PATCH 10/18] ci: build via pnpm in verify-treeshaking script --- scripts/verify-treeshaking.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/verify-treeshaking.js b/scripts/verify-treeshaking.js index e6480d20182..d1a7188a3d8 100644 --- a/scripts/verify-treeshaking.js +++ b/scripts/verify-treeshaking.js @@ -2,7 +2,7 @@ import fs from 'node:fs' import { execa } from 'execa' -execa('node', ['scripts/build.js', 'vue', '-f', 'global-runtime']).then(() => { +execa('pnpm', ['build', 'vue', '-f', 'global-runtime']).then(() => { const errors = [] const devBuild = fs.readFileSync( From 947aacf5eae2d08ab33b07c382f547bd2cc8a5cc Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 26 Dec 2023 15:52:53 +0800 Subject: [PATCH 11/18] release: v3.4.0-rc.2 --- CHANGELOG.md | 16 ++++++++++++++++ package.json | 2 +- packages/compiler-core/package.json | 2 +- packages/compiler-dom/package.json | 2 +- packages/compiler-sfc/package.json | 2 +- packages/compiler-ssr/package.json | 2 +- packages/reactivity/package.json | 2 +- packages/runtime-core/package.json | 2 +- packages/runtime-dom/package.json | 2 +- packages/server-renderer/package.json | 2 +- packages/shared/package.json | 2 +- packages/vue-compat/package.json | 2 +- packages/vue/package.json | 2 +- 13 files changed, 28 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f87ca03b50..d08f41e05f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,19 @@ +# [3.4.0-rc.2](https://github.com/vuejs/core/compare/v3.4.0-rc.1...v3.4.0-rc.2) (2023-12-26) + + +### Bug Fixes + +* **deps:** update dependency @vue/repl to ^3.1.0 ([#9911](https://github.com/vuejs/core/issues/9911)) ([f96c413](https://github.com/vuejs/core/commit/f96c413e8ef2f24cacda5bb499492922f62c6e8b)) +* **types:** fix distribution of union types when unwrapping setup bindings ([#9909](https://github.com/vuejs/core/issues/9909)) ([0695c69](https://github.com/vuejs/core/commit/0695c69e0dfaf99882a623fe75b433c9618ea648)), closes [#9903](https://github.com/vuejs/core/issues/9903) +* **warning:** ensure prod hydration warnings actually work ([b4ebe7a](https://github.com/vuejs/core/commit/b4ebe7ae8b904f28cdda33caf87bc05718d3a08a)) + + +### Features + +* **compiler-sfc:** export aggregated error messages for compiler-core and compiler-dom ([25c726e](https://github.com/vuejs/core/commit/25c726eca81fc384b41fafbeba5e8dfcda1f030f)) + + + # [3.4.0-rc.1](https://github.com/vuejs/core/compare/v3.4.0-beta.4...v3.4.0-rc.1) (2023-12-25) diff --git a/package.json b/package.json index 7c5e14746e8..0030ef94429 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "private": true, - "version": "3.4.0-rc.1", + "version": "3.4.0-rc.2", "packageManager": "pnpm@8.12.1", "type": "module", "scripts": { diff --git a/packages/compiler-core/package.json b/packages/compiler-core/package.json index 2e776d80500..590f4f08a3c 100644 --- a/packages/compiler-core/package.json +++ b/packages/compiler-core/package.json @@ -1,6 +1,6 @@ { "name": "@vue/compiler-core", - "version": "3.4.0-rc.1", + "version": "3.4.0-rc.2", "description": "@vue/compiler-core", "main": "index.js", "module": "dist/compiler-core.esm-bundler.js", diff --git a/packages/compiler-dom/package.json b/packages/compiler-dom/package.json index 0609bae175e..263453ad7eb 100644 --- a/packages/compiler-dom/package.json +++ b/packages/compiler-dom/package.json @@ -1,6 +1,6 @@ { "name": "@vue/compiler-dom", - "version": "3.4.0-rc.1", + "version": "3.4.0-rc.2", "description": "@vue/compiler-dom", "main": "index.js", "module": "dist/compiler-dom.esm-bundler.js", diff --git a/packages/compiler-sfc/package.json b/packages/compiler-sfc/package.json index 10c4d56ab3a..0475818f039 100644 --- a/packages/compiler-sfc/package.json +++ b/packages/compiler-sfc/package.json @@ -1,6 +1,6 @@ { "name": "@vue/compiler-sfc", - "version": "3.4.0-rc.1", + "version": "3.4.0-rc.2", "description": "@vue/compiler-sfc", "main": "dist/compiler-sfc.cjs.js", "module": "dist/compiler-sfc.esm-browser.js", diff --git a/packages/compiler-ssr/package.json b/packages/compiler-ssr/package.json index 58177dcbf1b..c97ba8768ce 100644 --- a/packages/compiler-ssr/package.json +++ b/packages/compiler-ssr/package.json @@ -1,6 +1,6 @@ { "name": "@vue/compiler-ssr", - "version": "3.4.0-rc.1", + "version": "3.4.0-rc.2", "description": "@vue/compiler-ssr", "main": "dist/compiler-ssr.cjs.js", "types": "dist/compiler-ssr.d.ts", diff --git a/packages/reactivity/package.json b/packages/reactivity/package.json index 8aaa6f4fe59..c2f383141dd 100644 --- a/packages/reactivity/package.json +++ b/packages/reactivity/package.json @@ -1,6 +1,6 @@ { "name": "@vue/reactivity", - "version": "3.4.0-rc.1", + "version": "3.4.0-rc.2", "description": "@vue/reactivity", "main": "index.js", "module": "dist/reactivity.esm-bundler.js", diff --git a/packages/runtime-core/package.json b/packages/runtime-core/package.json index e89ffe3df62..153c136844d 100644 --- a/packages/runtime-core/package.json +++ b/packages/runtime-core/package.json @@ -1,6 +1,6 @@ { "name": "@vue/runtime-core", - "version": "3.4.0-rc.1", + "version": "3.4.0-rc.2", "description": "@vue/runtime-core", "main": "index.js", "module": "dist/runtime-core.esm-bundler.js", diff --git a/packages/runtime-dom/package.json b/packages/runtime-dom/package.json index ddeb1add8fe..0f4a673731c 100644 --- a/packages/runtime-dom/package.json +++ b/packages/runtime-dom/package.json @@ -1,6 +1,6 @@ { "name": "@vue/runtime-dom", - "version": "3.4.0-rc.1", + "version": "3.4.0-rc.2", "description": "@vue/runtime-dom", "main": "index.js", "module": "dist/runtime-dom.esm-bundler.js", diff --git a/packages/server-renderer/package.json b/packages/server-renderer/package.json index 284a980b521..e7af1de4b8f 100644 --- a/packages/server-renderer/package.json +++ b/packages/server-renderer/package.json @@ -1,6 +1,6 @@ { "name": "@vue/server-renderer", - "version": "3.4.0-rc.1", + "version": "3.4.0-rc.2", "description": "@vue/server-renderer", "main": "index.js", "module": "dist/server-renderer.esm-bundler.js", diff --git a/packages/shared/package.json b/packages/shared/package.json index ad2ddd0b744..ae0007bd215 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -1,6 +1,6 @@ { "name": "@vue/shared", - "version": "3.4.0-rc.1", + "version": "3.4.0-rc.2", "description": "internal utils shared across @vue packages", "main": "index.js", "module": "dist/shared.esm-bundler.js", diff --git a/packages/vue-compat/package.json b/packages/vue-compat/package.json index ef3729aa013..03df0bdd34f 100644 --- a/packages/vue-compat/package.json +++ b/packages/vue-compat/package.json @@ -1,6 +1,6 @@ { "name": "@vue/compat", - "version": "3.4.0-rc.1", + "version": "3.4.0-rc.2", "description": "Vue 3 compatibility build for Vue 2", "main": "index.js", "module": "dist/vue.runtime.esm-bundler.js", diff --git a/packages/vue/package.json b/packages/vue/package.json index 48c7dcdef17..5231fccceb3 100644 --- a/packages/vue/package.json +++ b/packages/vue/package.json @@ -1,6 +1,6 @@ { "name": "vue", - "version": "3.4.0-rc.1", + "version": "3.4.0-rc.2", "description": "The progressive JavaScript framework for building modern web UI.", "main": "index.js", "module": "dist/vue.runtime.esm-bundler.js", From 8e727d62aba2337b091e4adde1422bf691f61029 Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 26 Dec 2023 16:15:24 +0800 Subject: [PATCH 12/18] chore: update new issue url in scheduler error message --- packages/runtime-core/src/errorHandling.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/runtime-core/src/errorHandling.ts b/packages/runtime-core/src/errorHandling.ts index aff4f5567fa..d2438ba8d56 100644 --- a/packages/runtime-core/src/errorHandling.ts +++ b/packages/runtime-core/src/errorHandling.ts @@ -55,7 +55,7 @@ export const ErrorTypeStrings: Record = { [ErrorCodes.ASYNC_COMPONENT_LOADER]: 'async component loader', [ErrorCodes.SCHEDULER]: 'scheduler flush. This is likely a Vue internals bug. ' + - 'Please open an issue at https://new-issue.vuejs.org/?repo=vuejs/core' + 'Please open an issue at https://github.com/vuejs/core .' } export type ErrorTypes = LifecycleHooks | ErrorCodes From 38706e4a1e5e5380e7df910b2a784d0a9bc9db29 Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 26 Dec 2023 16:32:53 +0800 Subject: [PATCH 13/18] fix: also export runtime error strings in all cjs builds --- packages/runtime-core/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/runtime-core/src/index.ts b/packages/runtime-core/src/index.ts index 422d7e772a7..fc20b37162d 100644 --- a/packages/runtime-core/src/index.ts +++ b/packages/runtime-core/src/index.ts @@ -148,7 +148,7 @@ import { ErrorTypeStrings as _ErrorTypeStrings } from './errorHandling' * @internal */ export const ErrorTypeStrings = ( - __ESM_BUNDLER__ || __DEV__ ? _ErrorTypeStrings : null + __ESM_BUNDLER__ || __NODE_JS__ || __DEV__ ? _ErrorTypeStrings : null ) as typeof _ErrorTypeStrings // For devtools From baf0b7664d0886e4e28ed8065852cee139597c27 Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 26 Dec 2023 17:57:18 +0800 Subject: [PATCH 14/18] refactor(sfc-playground): default to dev mode --- packages/sfc-playground/src/App.vue | 31 +++++++++++++++----------- packages/sfc-playground/src/Header.vue | 22 +++++++++--------- 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/packages/sfc-playground/src/App.vue b/packages/sfc-playground/src/App.vue index e5e52dd4268..e1a279de638 100644 --- a/packages/sfc-playground/src/App.vue +++ b/packages/sfc-playground/src/App.vue @@ -26,13 +26,17 @@ const setVH = () => { window.addEventListener('resize', setVH) setVH() -const useDevMode = ref(true) +const useProdMode = ref(false) const useSSRMode = ref(false) let hash = location.hash.slice(1) if (hash.startsWith('__DEV__')) { hash = hash.slice(7) - useDevMode.value = true + useProdMode.value = false +} +if (hash.startsWith('__PROD__')) { + hash = hash.slice(8) + useProdMode.value = true } if (hash.startsWith('__SSR__')) { hash = hash.slice(7) @@ -41,7 +45,7 @@ if (hash.startsWith('__SSR__')) { const store = new ReplStore({ serializedState: hash, - productionMode: !useDevMode.value, + productionMode: useProdMode.value, defaultVueRuntimeURL: import.meta.env.PROD ? `${location.origin}/vue.runtime.esm-browser.js` : `${location.origin}/src/vue-dev-proxy`, @@ -56,15 +60,15 @@ const store = new ReplStore({ // enable experimental features const sfcOptions: SFCOptions = { script: { - inlineTemplate: !useDevMode.value, - isProd: !useDevMode.value, + inlineTemplate: useProdMode.value, + isProd: useProdMode.value, propsDestructure: true }, style: { - isProd: !useDevMode.value + isProd: useProdMode.value }, template: { - isProd: !useDevMode.value + isProd: useProdMode.value } } @@ -73,18 +77,19 @@ watchEffect(() => { const newHash = store .serialize() .replace(/^#/, useSSRMode.value ? `#__SSR__` : `#`) - .replace(/^#/, useDevMode.value ? `#__DEV__` : `#`) + .replace(/^#/, useProdMode.value ? `#__PROD__` : `#`) history.replaceState({}, '', newHash) }) -function toggleDevMode() { - const dev = (useDevMode.value = !useDevMode.value) +function toggleProdMode() { + const isProd = (useProdMode.value = !useProdMode.value) sfcOptions.script!.inlineTemplate = sfcOptions.script!.isProd = sfcOptions.template!.isProd = sfcOptions.style!.isProd = - !dev + isProd store.toggleProduction() + store.setFiles(store.getFiles()) } function toggleSSR() { @@ -109,10 +114,10 @@ onMounted(() => { \n` +\n`, ).descriptor.template! expect(template.map).not.toBeUndefined() @@ -103,7 +103,7 @@ font-weight: bold; test('custom block', () => { const padding = Math.round(Math.random() * 10) const custom = parse( - `${'\n'.repeat(padding)}\n{\n "greeting": "hello"\n}\n\n` + `${'\n'.repeat(padding)}\n{\n "greeting": "hello"\n}\n\n`, ).descriptor.customBlocks[0] expect(custom!.map).not.toBeUndefined() @@ -138,42 +138,42 @@ h1 { color: red } const padTrue = parse(content.trim(), { pad: true }).descriptor expect(padTrue.script!.content).toBe( - Array(3 + 1).join('//\n') + '\nexport default {}\n' + Array(3 + 1).join('//\n') + '\nexport default {}\n', ) expect(padTrue.styles[0].content).toBe( - Array(6 + 1).join('\n') + '\nh1 { color: red }\n' + Array(6 + 1).join('\n') + '\nh1 { color: red }\n', ) expect(padTrue.customBlocks[0].content).toBe( - Array(9 + 1).join('\n') + '\n{ "greeting": "hello" }\n' + Array(9 + 1).join('\n') + '\n{ "greeting": "hello" }\n', ) const padLine = parse(content.trim(), { pad: 'line' }).descriptor expect(padLine.script!.content).toBe( - Array(3 + 1).join('//\n') + '\nexport default {}\n' + Array(3 + 1).join('//\n') + '\nexport default {}\n', ) expect(padLine.styles[0].content).toBe( - Array(6 + 1).join('\n') + '\nh1 { color: red }\n' + Array(6 + 1).join('\n') + '\nh1 { color: red }\n', ) expect(padLine.customBlocks[0].content).toBe( - Array(9 + 1).join('\n') + '\n{ "greeting": "hello" }\n' + Array(9 + 1).join('\n') + '\n{ "greeting": "hello" }\n', ) const padSpace = parse(content.trim(), { pad: 'space' }).descriptor expect(padSpace.script!.content).toBe( `\n\n\n`.replace( /./g, - ' ' - ) + '\n{ "greeting": "hello" }\n' + ' ', + ) + '\n{ "greeting": "hello" }\n', ) }) @@ -187,8 +187,8 @@ h1 { color: red } end: { line: 3, column: 1, - offset: 10 + content.length - } + offset: 10 + content.length, + }, }) }) @@ -198,7 +198,7 @@ h1 { color: red } expect(descriptor.template!.content).toBeFalsy() expect(descriptor.template!.loc).toMatchObject({ start: { line: 1, column: 12, offset: 11 }, - end: { line: 1, column: 12, offset: 11 } + end: { line: 1, column: 12, offset: 11 }, }) }) @@ -208,7 +208,7 @@ h1 { color: red } expect(descriptor.template!.content).toBeFalsy() expect(descriptor.template!.loc).toMatchObject({ start: { line: 1, column: 11, offset: 10 }, - end: { line: 1, column: 11, offset: 10 } + end: { line: 1, column: 11, offset: 10 }, }) }) @@ -219,7 +219,7 @@ h1 { color: red } expect(parse(``).descriptor.styles.length).toBe(0) expect(parse(``).descriptor.customBlocks.length).toBe(0) expect( - parse(` \n\t `).descriptor.customBlocks.length + parse(` \n\t `).descriptor.customBlocks.length, ).toBe(0) }) @@ -239,19 +239,19 @@ h1 { color: red } const { descriptor } = parse( `\n`, { - ignoreEmpty: false - } + ignoreEmpty: false, + }, ) expect(descriptor.script).toBeTruthy() expect(descriptor.script!.loc).toMatchObject({ start: { line: 1, column: 9, offset: 8 }, - end: { line: 1, column: 9, offset: 8 } + end: { line: 1, column: 9, offset: 8 }, }) expect(descriptor.scriptSetup).toBeTruthy() expect(descriptor.scriptSetup!.loc).toMatchObject({ start: { line: 2, column: 15, offset: 32 }, - end: { line: 3, column: 1, offset: 33 } + end: { line: 3, column: 1, offset: 33 }, }) }) @@ -267,7 +267,7 @@ h1 { color: red } test('treat empty lang attribute as the html', () => { const content = `
` const { descriptor, errors } = parse( - `` + ``, ) expect(descriptor.template!.content).toBe(content) expect(errors.length).toBe(0) @@ -277,7 +277,7 @@ h1 { color: red } test('template with preprocessor lang should be treated as plain text', () => { const content = `p(v-if="1 < 2") test
` const { descriptor, errors } = parse( - `` + ``, ) expect(errors.length).toBe(0) expect(descriptor.template!.content).toBe(content) @@ -301,17 +301,17 @@ h1 { color: red } expect(parse(``).descriptor.slotted).toBe(false) expect( parse(``).descriptor - .slotted + .slotted, ).toBe(false) expect( parse( - `` - ).descriptor.slotted + ``, + ).descriptor.slotted, ).toBe(true) expect( parse( - `` - ).descriptor.slotted + ``, + ).descriptor.slotted, ).toBe(true) }) @@ -332,8 +332,8 @@ h1 { color: red } options.onError!(new Error('foo') as any) return createRoot([]) }, - compile: baseCompile - } + compile: baseCompile, + }, }) expect(errors.length).toBe(2) // error thrown by the custom parse @@ -344,7 +344,7 @@ h1 { color: red } test('treat custom blocks as raw text', () => { const { errors, descriptor } = parse( - ` <-& ` + ` <-& `, ) expect(errors.length).toBe(0) expect(descriptor.customBlocks[0].content).toBe(` <-& `) @@ -358,7 +358,7 @@ h1 { color: red } test('should only allow single template element', () => { assertWarning( parse(``).errors, - `Single file component can contain only one