feat(vite): replace global with globalThis (#4958)

This commit is contained in:
Daniel Roe 2022-05-13 11:49:30 +01:00 committed by GitHub
parent 8767b7e3e1
commit 17f9c54a79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 0 deletions

View File

@ -20,6 +20,7 @@
},
"dependencies": {
"@nuxt/kit": "^3.0.0-rc.3",
"@rollup/plugin-replace": "^4.0.0",
"@vitejs/plugin-vue": "^2.3.3",
"@vitejs/plugin-vue-jsx": "^1.3.10",
"autoprefixer": "^10.4.7",

View File

@ -4,6 +4,7 @@ import type { Nuxt } from '@nuxt/schema'
import type { InlineConfig, SSROptions } from 'vite'
import { logger, isIgnored } from '@nuxt/kit'
import type { Options } from '@vitejs/plugin-vue'
import replace from '@rollup/plugin-replace'
import { sanitizeFilePath } from 'mlly'
import { getPort } from 'get-port-please'
import { buildClient } from './client'
@ -64,6 +65,10 @@ export async function bundle (nuxt: Nuxt) {
}
},
plugins: [
replace({
...Object.fromEntries([';', '(', '{', '}', ' ', '\t', '\n'].map(d => [`${d}global.`, `${d}globalThis.`])),
preventAssignment: true
}),
virtual(nuxt.vfs),
DynamicBasePlugin.vite({ sourcemap: nuxt.options.sourcemap })
],

View File

@ -1628,6 +1628,7 @@ __metadata:
dependencies:
"@nuxt/kit": ^3.0.0-rc.3
"@nuxt/schema": ^3.0.0-rc.3
"@rollup/plugin-replace": ^4.0.0
"@types/cssnano": ^5
"@vitejs/plugin-vue": ^2.3.3
"@vitejs/plugin-vue-jsx": ^1.3.10