Skip to content

Commit 8e3a972

Browse files
[autofix.ci] apply automated fixes
1 parent b6d2033 commit 8e3a972

File tree

1 file changed

+43
-41
lines changed

1 file changed

+43
-41
lines changed

scripts/verify-treeshaking.js

+43-41
Original file line numberDiff line numberDiff line change
@@ -2,51 +2,53 @@
22
import fs from 'node:fs'
33
import { exec } from './utils.js'
44

5-
exec('pnpm', ['build', 'vue', '-f', 'global-runtime']).then(() => {
6-
const errors = []
5+
exec('pnpm', ['build', 'vue', '-f', 'global-runtime'])
6+
.then(() => {
7+
const errors = []
78

8-
const devBuild = fs.readFileSync(
9-
'packages/vue/dist/vue.runtime.global.js',
10-
'utf-8',
11-
)
12-
13-
if (devBuild.includes('__spreadValues')) {
14-
errors.push(
15-
'dev build contains unexpected esbuild object spread helper.\n' +
16-
'This means { ...obj } syntax is used in runtime code. This should be ' +
17-
'refactored to use the `extend` helper to avoid the extra code.',
9+
const devBuild = fs.readFileSync(
10+
'packages/vue/dist/vue.runtime.global.js',
11+
'utf-8',
1812
)
19-
}
2013

21-
const prodBuild = fs.readFileSync(
22-
'packages/vue/dist/vue.runtime.global.prod.js',
23-
'utf-8',
24-
)
14+
if (devBuild.includes('__spreadValues')) {
15+
errors.push(
16+
'dev build contains unexpected esbuild object spread helper.\n' +
17+
'This means { ...obj } syntax is used in runtime code. This should be ' +
18+
'refactored to use the `extend` helper to avoid the extra code.',
19+
)
20+
}
2521

26-
if (prodBuild.includes('Vue warn')) {
27-
errors.push(
28-
'prod build contains unexpected warning-related code.\n' +
29-
'This means there are calls of warn() that are not guarded by the __DEV__ condition.',
22+
const prodBuild = fs.readFileSync(
23+
'packages/vue/dist/vue.runtime.global.prod.js',
24+
'utf-8',
3025
)
31-
}
3226

33-
if (
34-
prodBuild.includes('html,body,base') ||
35-
prodBuild.includes('svg,animate,animateMotion') ||
36-
prodBuild.includes('annotation,annotation-xml,maction')
37-
) {
38-
errors.push(
39-
'prod build contains unexpected domTagConfig lists.\n' +
40-
'This means helpers like isHTMLTag() is used in runtime code paths when it should be compiler-only.',
41-
)
42-
}
27+
if (prodBuild.includes('Vue warn')) {
28+
errors.push(
29+
'prod build contains unexpected warning-related code.\n' +
30+
'This means there are calls of warn() that are not guarded by the __DEV__ condition.',
31+
)
32+
}
4333

44-
if (errors.length) {
45-
throw new Error(
46-
`Found the following treeshaking errors:\n\n- ${errors.join('\n\n- ')}`,
47-
)
48-
}
49-
}).catch(error => {
50-
console.error(`Treeshaking verification failed: ${error.message}`)
51-
process.exit(1)
52-
})
34+
if (
35+
prodBuild.includes('html,body,base') ||
36+
prodBuild.includes('svg,animate,animateMotion') ||
37+
prodBuild.includes('annotation,annotation-xml,maction')
38+
) {
39+
errors.push(
40+
'prod build contains unexpected domTagConfig lists.\n' +
41+
'This means helpers like isHTMLTag() is used in runtime code paths when it should be compiler-only.',
42+
)
43+
}
44+
45+
if (errors.length) {
46+
throw new Error(
47+
`Found the following treeshaking errors:\n\n- ${errors.join('\n\n- ')}`,
48+
)
49+
}
50+
})
51+
.catch(error => {
52+
console.error(`Treeshaking verification failed: ${error.message}`)
53+
process.exit(1)
54+
})

0 commit comments

Comments
 (0)