提交 9240955a 编写于 作者: fxy060608's avatar fxy060608

chore(deps): bump vite from 2.6.14 to 2.7.0-beta.11

上级 96faab95
...@@ -81,7 +81,7 @@ ...@@ -81,7 +81,7 @@
"semver": "^7.3.5", "semver": "^7.3.5",
"ts-jest": "^27.0.3", "ts-jest": "^27.0.3",
"typescript": "^4.4.3", "typescript": "^4.4.3",
"vite": "^2.6.14", "vite": "^2.7.0-beta.11",
"vue": "3.2.23", "vue": "3.2.23",
"vue-router": "^4.0.12", "vue-router": "^4.0.12",
"yorkie": "^2.0.0" "yorkie": "^2.0.0"
......
...@@ -21,6 +21,6 @@ ...@@ -21,6 +21,6 @@
"compression": "^1.7.4", "compression": "^1.7.4",
"cypress": "^7.3.0", "cypress": "^7.3.0",
"serve-static": "^1.14.1", "serve-static": "^1.14.1",
"vite": "^2.6.14" "vite": "^2.7.0-beta.11"
} }
} }
...@@ -1795,6 +1795,50 @@ var serviceContext = (function (vue) { ...@@ -1795,6 +1795,50 @@ var serviceContext = (function (vue) {
useI18n().add(LOCALE_ZH_HANT, normalizeMessages(name, keys, ['取消', '從相冊選擇', '拍攝']), false); useI18n().add(LOCALE_ZH_HANT, normalizeMessages(name, keys, ['取消', '從相冊選擇', '拍攝']), false);
} }
}); });
const initI18nPreviewImageMsgsOnce = /*#__PURE__*/ once(() => {
const name = 'uni.previewImage.';
const keys = ['cancel', 'button.save', 'save.success', 'save.fail'];
{
useI18n().add(LOCALE_EN, normalizeMessages(name, keys, [
'Cancel',
'Save Image',
'Saved successfully',
'Save failed',
]), false);
}
{
useI18n().add(LOCALE_ES, normalizeMessages(name, keys, [
'Cancelar',
'Guardar imagen',
'Guardado exitosamente',
'Error al guardar',
]), false);
}
{
useI18n().add(LOCALE_FR, normalizeMessages(name, keys, [
'Annuler',
'Guardar imagen',
'Enregistré avec succès',
'Échec de la sauvegarde',
]), false);
}
{
useI18n().add(LOCALE_ZH_HANS, normalizeMessages(name, keys, [
'取消',
'保存图像',
'保存图像到相册成功',
'保存图像到相册失败',
]), false);
}
{
useI18n().add(LOCALE_ZH_HANT, normalizeMessages(name, keys, [
'取消',
'保存圖像',
'保存圖像到相冊成功',
'保存圖像到相冊失敗',
]), false);
}
});
const initI18nSetClipboardDataMsgsOnce = /*#__PURE__*/ once(() => { const initI18nSetClipboardDataMsgsOnce = /*#__PURE__*/ once(() => {
const name = 'uni.setClipboardData.'; const name = 'uni.setClipboardData.';
const keys = ['success', 'fail']; const keys = ['success', 'fail'];
...@@ -14269,7 +14313,7 @@ var serviceContext = (function (vue) { ...@@ -14269,7 +14313,7 @@ var serviceContext = (function (vue) {
}, GetVideoInfoProtocol, GetVideoInfoOptions); }, GetVideoInfoProtocol, GetVideoInfoOptions);
const previewImage = defineAsyncApi(API_PREVIEW_IMAGE, ({ current = 0, indicator = 'number', loop = false, urls, longPressActions }, { resolve, reject }) => { const previewImage = defineAsyncApi(API_PREVIEW_IMAGE, ({ current = 0, indicator = 'number', loop = false, urls, longPressActions }, { resolve, reject }) => {
initI18nChooseImageMsgsOnce(); initI18nPreviewImageMsgsOnce();
const { t } = useI18n(); const { t } = useI18n();
urls = urls.map((url) => getRealPath(url)); urls = urls.map((url) => getRealPath(url));
const index = Number(current); const index = Number(current);
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
"@vitejs/plugin-vue": "^1.10.1", "@vitejs/plugin-vue": "^1.10.1",
"debug": "^4.3.2", "debug": "^4.3.2",
"fs-extra": "^10.0.0", "fs-extra": "^10.0.0",
"rollup": "^2.57.0" "rollup": "^2.59.0"
}, },
"devDependencies": { "devDependencies": {
"@types/debug": "^4.1.7", "@types/debug": "^4.1.7",
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
"lru-cache": "^4.1.2", "lru-cache": "^4.1.2",
"merge-source-map": "^1.1.0", "merge-source-map": "^1.1.0",
"module-alias": "^2.2.2", "module-alias": "^2.2.2",
"postcss": "^8.3.8", "postcss": "^8.3.11",
"postcss-comment": "^2.0.0", "postcss-comment": "^2.0.0",
"postcss-import": "^14.0.2", "postcss-import": "^14.0.2",
"postcss-loader": "^6.1.1", "postcss-loader": "^6.1.1",
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
"compare-versions": "^3.6.0", "compare-versions": "^3.6.0",
"debug": "^4.3.2", "debug": "^4.3.2",
"es-module-lexer": "^0.9.3", "es-module-lexer": "^0.9.3",
"esbuild": "^0.13.2", "esbuild": "^0.13.12",
"estree-walker": "^2.0.2", "estree-walker": "^2.0.2",
"fast-glob": "^3.2.7", "fast-glob": "^3.2.7",
"fs-extra": "^10.0.0", "fs-extra": "^10.0.0",
......
...@@ -27,9 +27,9 @@ function createDefineJsonJsPlugin(name: 'pages.json' | 'manifest.json') { ...@@ -27,9 +27,9 @@ function createDefineJsonJsPlugin(name: 'pages.json' | 'manifest.json') {
let jsonPath = '' let jsonPath = ''
plugin.resolveId = function (id, importer, options, ssr) { plugin.resolveId = function (id, importer, options) {
const res = const res =
origResolveId && origResolveId.call(this, id, importer, options, ssr) origResolveId && origResolveId.call(this, id, importer, options)
if (res) { if (res) {
return res return res
} }
......
import path from 'path' import path from 'path'
import { defineUniMainJsPlugin, normalizePath } from '@dcloudio/uni-cli-shared' import { defineUniMainJsPlugin, normalizePath } from '@dcloudio/uni-cli-shared'
import { isSsr, isSsrManifest } from '../utils' import { isSSR, isSsr, isSsrManifest } from '../utils'
export function uniMainJsPlugin() { export function uniMainJsPlugin() {
return defineUniMainJsPlugin((opts) => { return defineUniMainJsPlugin((opts) => {
let pagesJsonJsPath = '' let pagesJsonJsPath = ''
let isSSR = false let runSSR = false
return { return {
name: 'vite:uni-h5-main-js', name: 'vite:uni-h5-main-js',
enforce: 'pre', enforce: 'pre',
...@@ -13,17 +13,19 @@ export function uniMainJsPlugin() { ...@@ -13,17 +13,19 @@ export function uniMainJsPlugin() {
pagesJsonJsPath = normalizePath( pagesJsonJsPath = normalizePath(
path.resolve(process.env.UNI_INPUT_DIR, 'pages.json.js') path.resolve(process.env.UNI_INPUT_DIR, 'pages.json.js')
) )
isSSR = runSSR =
isSsr(config.command, config) || isSsrManifest(config.command, config) isSsr(config.command, config) || isSsrManifest(config.command, config)
}, },
transform(code, id, ssr) { transform(code, id, options) {
if (opts.filter(id)) { if (opts.filter(id)) {
if (!isSSR) { if (!runSSR) {
code = code.includes('createSSRApp') code = code.includes('createSSRApp')
? createApp(code) ? createApp(code)
: createLegacyApp(code) : createLegacyApp(code)
} else { } else {
code = ssr ? createSSRServerApp(code) : createSSRClientApp(code) code = isSSR(options)
? createSSRServerApp(code)
: createSSRClientApp(code)
} }
code = `import '${pagesJsonJsPath}';${code}` code = `import '${pagesJsonJsPath}';${code}`
return { return {
......
...@@ -14,15 +14,17 @@ import { ...@@ -14,15 +14,17 @@ import {
isEnableTreeShaking, isEnableTreeShaking,
parseManifestJsonOnce, parseManifestJsonOnce,
} from '@dcloudio/uni-cli-shared' } from '@dcloudio/uni-cli-shared'
import { isSSR } from '../utils'
export function uniPagesJsonPlugin(): Plugin { export function uniPagesJsonPlugin(): Plugin {
return defineUniPagesJsonPlugin((opts) => { return defineUniPagesJsonPlugin((opts) => {
return { return {
name: 'vite:uni-h5-pages-json', name: 'vite:uni-h5-pages-json',
enforce: 'pre', enforce: 'pre',
transform(code, id, ssr) { transform(code, id, opt) {
if (opts.filter(id)) { if (opts.filter(id)) {
const { resolvedConfig } = opts const { resolvedConfig } = opts
const ssr = isSSR(opt)
return { return {
code: code:
registerGlobalCode(resolvedConfig, ssr) + registerGlobalCode(resolvedConfig, ssr) +
......
...@@ -2,7 +2,7 @@ import path from 'path' ...@@ -2,7 +2,7 @@ import path from 'path'
import debug from 'debug' import debug from 'debug'
import type { Plugin } from 'vite' import type { Plugin } from 'vite'
import { resolveBuiltIn, parseCompatConfigOnce } from '@dcloudio/uni-cli-shared' import { resolveBuiltIn } from '@dcloudio/uni-cli-shared'
import { ownerModuleName } from '../utils' import { ownerModuleName } from '../utils'
const debugResolve = debug('vite:uni:resolve') const debugResolve = debug('vite:uni:resolve')
...@@ -12,16 +12,12 @@ export function uniResolveIdPlugin(): Plugin { ...@@ -12,16 +12,12 @@ export function uniResolveIdPlugin(): Plugin {
return { return {
name: 'vite:uni-h5-resolve-id', name: 'vite:uni-h5-resolve-id',
enforce: 'pre', enforce: 'pre',
configResolved() { config() {
const { MODE } = parseCompatConfigOnce(process.env.UNI_INPUT_DIR)
resolveCache[ownerModuleName] = resolveBuiltIn( resolveCache[ownerModuleName] = resolveBuiltIn(
path.join(ownerModuleName, 'dist/uni-h5.es.js') path.join(ownerModuleName, 'dist/uni-h5.es.js')
) )
resolveCache['@dcloudio/uni-h5-vue'] = resolveBuiltIn( resolveCache['@dcloudio/uni-h5-vue'] = resolveBuiltIn(
path.join( path.join('@dcloudio/uni-h5-vue', `dist/vue.runtime.esm.js`)
'@dcloudio/uni-h5-vue',
`dist/vue.runtime.${MODE === 2 ? 'compat.' : ''}esm.js`
)
) )
}, },
resolveId(id) { resolveId(id) {
......
...@@ -3,10 +3,7 @@ import type { Plugin, ResolvedConfig } from 'vite' ...@@ -3,10 +3,7 @@ import type { Plugin, ResolvedConfig } from 'vite'
import { OutputChunk } from 'rollup' import { OutputChunk } from 'rollup'
import { import { parseRpx2UnitOnce } from '@dcloudio/uni-cli-shared'
parseCompatConfigOnce,
parseRpx2UnitOnce,
} from '@dcloudio/uni-cli-shared'
import { import {
isSsr, isSsr,
...@@ -31,10 +28,9 @@ export function uniSSRPlugin(): Plugin { ...@@ -31,10 +28,9 @@ export function uniSSRPlugin(): Plugin {
resolvedConfig = config resolvedConfig = config
entryServerJs = path.join(process.env.UNI_INPUT_DIR, ENTRY_SERVER_JS) entryServerJs = path.join(process.env.UNI_INPUT_DIR, ENTRY_SERVER_JS)
if (isSsr(resolvedConfig.command, resolvedConfig)) { if (isSsr(resolvedConfig.command, resolvedConfig)) {
const { MODE } = parseCompatConfigOnce(process.env.UNI_INPUT_DIR)
initSsrDefine(resolvedConfig) initSsrDefine(resolvedConfig)
rewriteSsrVue(MODE) rewriteSsrVue()
rewriteSsrResolve(MODE) rewriteSsrResolve()
rewriteSsrNativeTag() rewriteSsrNativeTag()
rewriteSsrRenderStyle(process.env.UNI_INPUT_DIR) rewriteSsrRenderStyle(process.env.UNI_INPUT_DIR)
} }
......
...@@ -17,6 +17,10 @@ import resolve from 'resolve' ...@@ -17,6 +17,10 @@ import resolve from 'resolve'
import { resolveComponentType } from '@vue/compiler-dom' import { resolveComponentType } from '@vue/compiler-dom'
import { transformPageHead } from '../plugin/transforms/transformPageHead' import { transformPageHead } from '../plugin/transforms/transformPageHead'
// Temporal handling for 2.7 breaking change
export const isSSR = (opt: { ssr?: boolean } | boolean | undefined) =>
opt === undefined ? false : typeof opt === 'boolean' ? opt : opt?.ssr === true
export function isSsr( export function isSsr(
command: ConfigEnv['command'], command: ConfigEnv['command'],
config: UserConfig | ResolvedConfig config: UserConfig | ResolvedConfig
...@@ -86,17 +90,12 @@ export function generateSsrEntryServerCode() { ...@@ -86,17 +90,12 @@ export function generateSsrEntryServerCode() {
) )
} }
export function rewriteSsrVue(mode?: 2 | 3) { export function rewriteSsrVue() {
// 解决 @vue/server-renderer 中引入 vue 的映射 // 解决 @vue/server-renderer 中引入 vue 的映射
let vuePath: string require('module-alias').addAlias(
if (mode === 2) { 'vue',
vuePath = resolveBuiltIn( resolveBuiltIn('@dcloudio/uni-h5-vue/dist/vue.runtime.cjs.js')
'@dcloudio/uni-h5-vue/dist/vue.runtime.compat.cjs.js' )
)
} else {
vuePath = resolveBuiltIn('@dcloudio/uni-h5-vue/dist/vue.runtime.cjs.js')
}
require('module-alias').addAlias('vue', vuePath)
} }
function initResolveSyncOpts(opts?: resolve.SyncOpts) { function initResolveSyncOpts(opts?: resolve.SyncOpts) {
...@@ -115,7 +114,7 @@ function initResolveSyncOpts(opts?: resolve.SyncOpts) { ...@@ -115,7 +114,7 @@ function initResolveSyncOpts(opts?: resolve.SyncOpts) {
return opts return opts
} }
export function rewriteSsrResolve(mode?: 2 | 3) { export function rewriteSsrResolve() {
// 解决 ssr 时 __vite_ssr_import__("vue") 的映射 // 解决 ssr 时 __vite_ssr_import__("vue") 的映射
const resolve = require(require.resolve('resolve', { const resolve = require(require.resolve('resolve', {
paths: [ paths: [
...@@ -125,11 +124,9 @@ export function rewriteSsrResolve(mode?: 2 | 3) { ...@@ -125,11 +124,9 @@ export function rewriteSsrResolve(mode?: 2 | 3) {
const oldSync = resolve.sync const oldSync = resolve.sync
resolve.sync = (id: string, opts?: resolve.SyncOpts) => { resolve.sync = (id: string, opts?: resolve.SyncOpts) => {
if (id === 'vue') { if (id === 'vue') {
return resolveBuiltIn( return resolveBuiltIn(`@dcloudio/uni-h5-vue/dist/vue.runtime.cjs.js`)
`@dcloudio/uni-h5-vue/dist/vue.runtime.${ } else if (id === 'vue/package.json') {
mode === 2 ? 'compat.' : '' return resolveBuiltIn(`@dcloudio/uni-h5-vue/package.json`)
}cjs.js`
)
} }
return oldSync(id, initResolveSyncOpts(opts)) return oldSync(id, initResolveSyncOpts(opts))
} }
......
...@@ -123,6 +123,7 @@ export function uniMiniProgramPlugin( ...@@ -123,6 +123,7 @@ export function uniMiniProgramPlugin(
'vue-i18n': path.resolve(__dirname, '../../lib/vue-i18n'), 'vue-i18n': path.resolve(__dirname, '../../lib/vue-i18n'),
...alias, ...alias,
}, },
preserveSymlinks: true,
}, },
build: buildOptions(), build: buildOptions(),
} }
......
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
"chokidar": "^3.5.2" "chokidar": "^3.5.2"
}, },
"peerDependencies": { "peerDependencies": {
"vite": "^2.6.14" "vite": "^2.7.0-beta.11"
}, },
"uni-app": { "uni-app": {
"compilerVersion": "3.3.0" "compilerVersion": "3.3.0"
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册