From 8498fcb8d8328016a913181dda8756cfda33e1eb Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 2 Jan 2024 10:55:10 +0800 Subject: [PATCH 1/4] fix(compiler-sfc): use compilerOptions when re-parsing consumed AST fixes hydration error for custom elements --- packages/compiler-sfc/src/compileTemplate.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/compiler-sfc/src/compileTemplate.ts b/packages/compiler-sfc/src/compileTemplate.ts index 019aa5b0d65..5b7fe268366 100644 --- a/packages/compiler-sfc/src/compileTemplate.ts +++ b/packages/compiler-sfc/src/compileTemplate.ts @@ -219,6 +219,7 @@ function doCompileTemplate({ // We need to parse a fresh one. Can't just use `source` here since we need // the AST location info to be relative to the entire SFC. const newAST = (ssr ? CompilerDOM : compiler).parse(inAST.source, { + ...compilerOptions, parseMode: 'sfc', onError: e => errors.push(e), }) From 5a925892ed816a6b20a30f71eca819c02066c531 Mon Sep 17 00:00:00 2001 From: Mu-Tsun Tsai <39870664+MuTsunTsai@users.noreply.github.com> Date: Tue, 2 Jan 2024 12:17:06 +0800 Subject: [PATCH 2/4] Fix SCSS sourcemap issue --- packages/compiler-sfc/src/style/preprocessors.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/compiler-sfc/src/style/preprocessors.ts b/packages/compiler-sfc/src/style/preprocessors.ts index b09c3ec98c2..f81ed17e511 100644 --- a/packages/compiler-sfc/src/style/preprocessors.ts +++ b/packages/compiler-sfc/src/style/preprocessors.ts @@ -40,7 +40,7 @@ const scss: StylePreprocessor = (source, map, options, load = require) => { code: result.css.toString(), map: merge( map, - result.map.toJSON + !(result.map instanceof Buffer) && result.map.toJSON ? result.map.toJSON() : JSON.parse(result.map.toString()), ), From 42a97879253f01018362afe49a6e362f067f6bb3 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Wed, 3 Jan 2024 09:04:12 +0000 Subject: [PATCH 3/4] [autofix.ci] apply automated fixes --- packages/sfc-playground/src/App.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/sfc-playground/src/App.vue b/packages/sfc-playground/src/App.vue index de6c24dded0..e8aeeeaef56 100644 --- a/packages/sfc-playground/src/App.vue +++ b/packages/sfc-playground/src/App.vue @@ -70,8 +70,8 @@ const sfcOptions: SFCOptions = { template: { isProd: useProdMode.value, compilerOptions: { - isCustomElement: (tag: string) => tag === 'mjx-container' - } + isCustomElement: (tag: string) => tag === 'mjx-container', + }, }, } From d4d31c0420d97989e99ddd6b6fdc7026182a10a4 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Wed, 3 Jan 2024 09:05:09 +0000 Subject: [PATCH 4/4] [autofix.ci] apply automated fixes (attempt 2/3) --- packages/sfc-playground/src/App.vue | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/sfc-playground/src/App.vue b/packages/sfc-playground/src/App.vue index e8aeeeaef56..cadd39f4baa 100644 --- a/packages/sfc-playground/src/App.vue +++ b/packages/sfc-playground/src/App.vue @@ -137,6 +137,12 @@ onMounted(() => { :autoResize="true" :sfcOptions="sfcOptions" :clearConsole="false" + :preview-options="{ + customCode: { + importCode: `import { initCustomFormatter } from 'vue'`, + useCode: `initCustomFormatter()`, + }, + }" />