perf(vite): bypass unchanged plugin transform (#3150)

This commit is contained in:
Anthony Fu 2022-02-10 17:30:34 +08:00 committed by GitHub
parent cb663b0285
commit b2438917b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 2 deletions

View File

@ -44,5 +44,7 @@ function transform (content: string, components: Component[]) {
return full
})
if (!imports || newContent === content) { return }
return `${imports}\n${newContent}`
}

View File

@ -27,7 +27,7 @@ export const TransformMacroPlugin = createUnplugin((options: TransformMacroPlugi
}
}
if (!parseQuery(search).macro) { return code }
if (!parseQuery(search).macro) { return }
// [webpack] Re-export any imports from script blocks in the components
// with workaround for vue-loader bug: https://github.com/vuejs/vue-loader/pull/1911

View File

@ -42,7 +42,8 @@ export const DynamicBasePlugin = createUnplugin(function (options: DynamicBasePl
return null
},
enforce: 'post',
transform (code, id) {
transform (original, id) {
let code = original
if (options.globalPublicPath && id.includes('entry.ts')) {
code = 'import { joinURL } from "ufo";' +
`${options.globalPublicPath} = joinURL(NUXT_BASE, NUXT_CONFIG.app.buildAssetsDir);` + code
@ -84,6 +85,7 @@ export const DynamicBasePlugin = createUnplugin(function (options: DynamicBasePl
code = code.replace(delimiterRE, '`$1${NUXT_BASE}$2`')
}
if (code === original) { return }
return code
}
}