From b6d203333fa1d914663e97cd9ff13b6fb51e0c9e Mon Sep 17 00:00:00 2001 From: starle Date: Sat, 12 Apr 2025 14:00:08 +0800 Subject: [PATCH 1/2] fix(scripts): add error handling to verify-treeshaking script --- scripts/verify-treeshaking.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/verify-treeshaking.js b/scripts/verify-treeshaking.js index 381fc5dda84..14079a51d79 100644 --- a/scripts/verify-treeshaking.js +++ b/scripts/verify-treeshaking.js @@ -46,4 +46,7 @@ exec('pnpm', ['build', 'vue', '-f', 'global-runtime']).then(() => { `Found the following treeshaking errors:\n\n- ${errors.join('\n\n- ')}`, ) } +}).catch(error => { + console.error(`Treeshaking verification failed: ${error.message}`) + process.exit(1) }) From 8e3a9728533478b237af554f027436e95c317bb0 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Mon, 14 Apr 2025 00:14:01 +0000 Subject: [PATCH 2/2] [autofix.ci] apply automated fixes --- scripts/verify-treeshaking.js | 84 ++++++++++++++++++----------------- 1 file changed, 43 insertions(+), 41 deletions(-) diff --git a/scripts/verify-treeshaking.js b/scripts/verify-treeshaking.js index 14079a51d79..3bed45ddcd9 100644 --- a/scripts/verify-treeshaking.js +++ b/scripts/verify-treeshaking.js @@ -2,51 +2,53 @@ import fs from 'node:fs' import { exec } from './utils.js' -exec('pnpm', ['build', 'vue', '-f', 'global-runtime']).then(() => { - const errors = [] +exec('pnpm', ['build', '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 ' + - 'refactored to use the `extend` helper to avoid the extra code.', + const devBuild = fs.readFileSync( + 'packages/vue/dist/vue.runtime.global.js', + 'utf-8', ) - } - const prodBuild = fs.readFileSync( - 'packages/vue/dist/vue.runtime.global.prod.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 ' + + 'refactored to use the `extend` helper to avoid the extra code.', + ) + } - 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.', + const prodBuild = fs.readFileSync( + 'packages/vue/dist/vue.runtime.global.prod.js', + 'utf-8', ) - } - if ( - prodBuild.includes('html,body,base') || - prodBuild.includes('svg,animate,animateMotion') || - prodBuild.includes('annotation,annotation-xml,maction') - ) { - errors.push( - 'prod build contains unexpected domTagConfig lists.\n' + - 'This means helpers like isHTMLTag() is used in runtime code paths when it should be compiler-only.', - ) - } + 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 (errors.length) { - throw new Error( - `Found the following treeshaking errors:\n\n- ${errors.join('\n\n- ')}`, - ) - } -}).catch(error => { - console.error(`Treeshaking verification failed: ${error.message}`) - process.exit(1) -}) + if ( + prodBuild.includes('html,body,base') || + prodBuild.includes('svg,animate,animateMotion') || + prodBuild.includes('annotation,annotation-xml,maction') + ) { + errors.push( + 'prod build contains unexpected domTagConfig 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- ')}`, + ) + } + }) + .catch(error => { + console.error(`Treeshaking verification failed: ${error.message}`) + process.exit(1) + })