fix(bridge): use vue server build (#3515)

* fix(bridge): use vue server build

* fix: remove unused import

* refactor: resolve cjs version once

Co-authored-by: Pooya Parsa <pyapar@gmail.com>
This commit is contained in:
Daniel Roe 2022-03-08 17:40:20 +00:00 committed by GitHub
parent 91256f5e76
commit a5e19b1c57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 3 deletions

View File

@ -1,4 +1,4 @@
import { useNuxt, resolveModule, addTemplate, resolveAlias } from '@nuxt/kit'
import { useNuxt, resolveModule, addTemplate, resolveAlias, extendWebpackConfig } from '@nuxt/kit'
import { NuxtModule } from '@nuxt/schema'
import { resolve } from 'pathe'
import { componentsTypeTemplate } from '../../nuxt3/src/components/templates'
@ -22,9 +22,20 @@ export function setupAppBridge (_options: any) {
}
// Resolve vue2 builds
nuxt.options.alias.vue2 = resolveModule('vue/dist/vue.runtime.esm.js', { paths: nuxt.options.modulesDir })
const vue2ESM = resolveModule('vue/dist/vue.runtime.esm.js', { paths: nuxt.options.modulesDir })
const vue2CJS = resolveModule('vue/dist/vue.runtime.common.js', { paths: nuxt.options.modulesDir })
nuxt.options.alias.vue2 = vue2ESM
nuxt.options.build.transpile.push('vue')
extendWebpackConfig((config) => {
(config.resolve.alias as any).vue2 = vue2CJS
}, { client: false })
nuxt.hook('vite:extendConfig', (config, { isServer }) => {
if (isServer && !nuxt.options.dev) {
(config.resolve.alias as any).vue2 = vue2CJS
}
})
// Disable legacy fetch polyfills
nuxt.options.fetch.server = false
nuxt.options.fetch.client = false

View File

@ -165,7 +165,9 @@ export const getRollupConfig = (nitroContext: NitroContext) => {
'process.env.NUXT_FULL_STATIC': nitroContext._nuxt.fullStatic as unknown as string,
'process.env.NITRO_PRESET': JSON.stringify(nitroContext.preset),
'process.env.RUNTIME_CONFIG': devalue(nitroContext._nuxt.runtimeConfig),
'process.env.DEBUG': JSON.stringify(nitroContext._nuxt.dev)
'process.env.DEBUG': JSON.stringify(nitroContext._nuxt.dev),
// Needed for vue 2 server build
'commonjsGlobal.process.env.VUE_ENV': '"server"'
}
}))