mirror of https://github.com/vuejs/core.git
Merge 714f35f26e
into ba391f5fdf
This commit is contained in:
commit
9ab971dd9a
|
@ -2,48 +2,53 @@
|
||||||
import fs from 'node:fs'
|
import fs from 'node:fs'
|
||||||
import { exec } from './utils.js'
|
import { exec } from './utils.js'
|
||||||
|
|
||||||
exec('pnpm', ['build', 'vue', '-f', 'global-runtime']).then(() => {
|
exec('pnpm', ['build', 'vue', '-f', 'global-runtime'])
|
||||||
const errors = []
|
.then(() => {
|
||||||
|
const errors = []
|
||||||
|
|
||||||
const devBuild = fs.readFileSync(
|
const devBuild = fs.readFileSync(
|
||||||
'packages/vue/dist/vue.runtime.global.js',
|
'packages/vue/dist/vue.runtime.global.js',
|
||||||
'utf-8',
|
'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 prodBuild = fs.readFileSync(
|
if (devBuild.includes('__spreadValues')) {
|
||||||
'packages/vue/dist/vue.runtime.global.prod.js',
|
errors.push(
|
||||||
'utf-8',
|
'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')) {
|
const prodBuild = fs.readFileSync(
|
||||||
errors.push(
|
'packages/vue/dist/vue.runtime.global.prod.js',
|
||||||
'prod build contains unexpected warning-related code.\n' +
|
'utf-8',
|
||||||
'This means there are calls of warn() that are not guarded by the __DEV__ condition.',
|
|
||||||
)
|
)
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
if (prodBuild.includes('Vue warn')) {
|
||||||
prodBuild.includes('html,body,base') ||
|
errors.push(
|
||||||
prodBuild.includes('svg,animate,animateMotion') ||
|
'prod build contains unexpected warning-related code.\n' +
|
||||||
prodBuild.includes('annotation,annotation-xml,maction')
|
'This means there are calls of warn() that are not guarded by the __DEV__ condition.',
|
||||||
) {
|
)
|
||||||
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) {
|
if (
|
||||||
throw new Error(
|
prodBuild.includes('html,body,base') ||
|
||||||
`Found the following treeshaking errors:\n\n- ${errors.join('\n\n- ')}`,
|
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)
|
||||||
|
})
|
||||||
|
|
Loading…
Reference in New Issue