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

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

上级 96faab95
......@@ -21,6 +21,6 @@
"compression": "^1.7.4",
"cypress": "^7.3.0",
"serve-static": "^1.14.1",
"vite": "^2.6.14"
"vite": "^2.7.0-beta.11"
}
}
......@@ -1795,6 +1795,50 @@ var serviceContext = (function (vue) {
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 name = 'uni.setClipboardData.';
const keys = ['success', 'fail'];
......@@ -14269,7 +14313,7 @@ var serviceContext = (function (vue) {
}, GetVideoInfoProtocol, GetVideoInfoOptions);
const previewImage = defineAsyncApi(API_PREVIEW_IMAGE, ({ current = 0, indicator = 'number', loop = false, urls, longPressActions }, { resolve, reject }) => {
initI18nChooseImageMsgsOnce();
initI18nPreviewImageMsgsOnce();
const { t } = useI18n();
urls = urls.map((url) => getRealPath(url));
const index = Number(current);
......
......@@ -27,7 +27,7 @@
"@vitejs/plugin-vue": "^1.10.1",
"debug": "^4.3.2",
"fs-extra": "^10.0.0",
"rollup": "^2.57.0"
"rollup": "^2.59.0"
},
"devDependencies": {
"@types/debug": "^4.1.7",
......
......@@ -40,7 +40,7 @@
"lru-cache": "^4.1.2",
"merge-source-map": "^1.1.0",
"module-alias": "^2.2.2",
"postcss": "^8.3.8",
"postcss": "^8.3.11",
"postcss-comment": "^2.0.0",
"postcss-import": "^14.0.2",
"postcss-loader": "^6.1.1",
......
......@@ -33,7 +33,7 @@
"compare-versions": "^3.6.0",
"debug": "^4.3.2",
"es-module-lexer": "^0.9.3",
"esbuild": "^0.13.2",
"esbuild": "^0.13.12",
"estree-walker": "^2.0.2",
"fast-glob": "^3.2.7",
"fs-extra": "^10.0.0",
......
......@@ -27,9 +27,9 @@ function createDefineJsonJsPlugin(name: 'pages.json' | 'manifest.json') {
let jsonPath = ''
plugin.resolveId = function (id, importer, options, ssr) {
plugin.resolveId = function (id, importer, options) {
const res =
origResolveId && origResolveId.call(this, id, importer, options, ssr)
origResolveId && origResolveId.call(this, id, importer, options)
if (res) {
return res
}
......
import path from 'path'
import { defineUniMainJsPlugin, normalizePath } from '@dcloudio/uni-cli-shared'
import { isSsr, isSsrManifest } from '../utils'
import { isSSR, isSsr, isSsrManifest } from '../utils'
export function uniMainJsPlugin() {
return defineUniMainJsPlugin((opts) => {
let pagesJsonJsPath = ''
let isSSR = false
let runSSR = false
return {
name: 'vite:uni-h5-main-js',
enforce: 'pre',
......@@ -13,17 +13,19 @@ export function uniMainJsPlugin() {
pagesJsonJsPath = normalizePath(
path.resolve(process.env.UNI_INPUT_DIR, 'pages.json.js')
)
isSSR =
runSSR =
isSsr(config.command, config) || isSsrManifest(config.command, config)
},
transform(code, id, ssr) {
transform(code, id, options) {
if (opts.filter(id)) {
if (!isSSR) {
if (!runSSR) {
code = code.includes('createSSRApp')
? createApp(code)
: createLegacyApp(code)
} else {
code = ssr ? createSSRServerApp(code) : createSSRClientApp(code)
code = isSSR(options)
? createSSRServerApp(code)
: createSSRClientApp(code)
}
code = `import '${pagesJsonJsPath}';${code}`
return {
......
......@@ -14,15 +14,17 @@ import {
isEnableTreeShaking,
parseManifestJsonOnce,
} from '@dcloudio/uni-cli-shared'
import { isSSR } from '../utils'
export function uniPagesJsonPlugin(): Plugin {
return defineUniPagesJsonPlugin((opts) => {
return {
name: 'vite:uni-h5-pages-json',
enforce: 'pre',
transform(code, id, ssr) {
transform(code, id, opt) {
if (opts.filter(id)) {
const { resolvedConfig } = opts
const ssr = isSSR(opt)
return {
code:
registerGlobalCode(resolvedConfig, ssr) +
......
......@@ -2,7 +2,7 @@ import path from 'path'
import debug from 'debug'
import type { Plugin } from 'vite'
import { resolveBuiltIn, parseCompatConfigOnce } from '@dcloudio/uni-cli-shared'
import { resolveBuiltIn } from '@dcloudio/uni-cli-shared'
import { ownerModuleName } from '../utils'
const debugResolve = debug('vite:uni:resolve')
......@@ -12,16 +12,12 @@ export function uniResolveIdPlugin(): Plugin {
return {
name: 'vite:uni-h5-resolve-id',
enforce: 'pre',
configResolved() {
const { MODE } = parseCompatConfigOnce(process.env.UNI_INPUT_DIR)
config() {
resolveCache[ownerModuleName] = resolveBuiltIn(
path.join(ownerModuleName, 'dist/uni-h5.es.js')
)
resolveCache['@dcloudio/uni-h5-vue'] = resolveBuiltIn(
path.join(
'@dcloudio/uni-h5-vue',
`dist/vue.runtime.${MODE === 2 ? 'compat.' : ''}esm.js`
)
path.join('@dcloudio/uni-h5-vue', `dist/vue.runtime.esm.js`)
)
},
resolveId(id) {
......
......@@ -3,10 +3,7 @@ import type { Plugin, ResolvedConfig } from 'vite'
import { OutputChunk } from 'rollup'
import {
parseCompatConfigOnce,
parseRpx2UnitOnce,
} from '@dcloudio/uni-cli-shared'
import { parseRpx2UnitOnce } from '@dcloudio/uni-cli-shared'
import {
isSsr,
......@@ -31,10 +28,9 @@ export function uniSSRPlugin(): Plugin {
resolvedConfig = config
entryServerJs = path.join(process.env.UNI_INPUT_DIR, ENTRY_SERVER_JS)
if (isSsr(resolvedConfig.command, resolvedConfig)) {
const { MODE } = parseCompatConfigOnce(process.env.UNI_INPUT_DIR)
initSsrDefine(resolvedConfig)
rewriteSsrVue(MODE)
rewriteSsrResolve(MODE)
rewriteSsrVue()
rewriteSsrResolve()
rewriteSsrNativeTag()
rewriteSsrRenderStyle(process.env.UNI_INPUT_DIR)
}
......
......@@ -17,6 +17,10 @@ import resolve from 'resolve'
import { resolveComponentType } from '@vue/compiler-dom'
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(
command: ConfigEnv['command'],
config: UserConfig | ResolvedConfig
......@@ -86,17 +90,12 @@ export function generateSsrEntryServerCode() {
)
}
export function rewriteSsrVue(mode?: 2 | 3) {
export function rewriteSsrVue() {
// 解决 @vue/server-renderer 中引入 vue 的映射
let vuePath: string
if (mode === 2) {
vuePath = resolveBuiltIn(
'@dcloudio/uni-h5-vue/dist/vue.runtime.compat.cjs.js'
require('module-alias').addAlias(
'vue',
resolveBuiltIn('@dcloudio/uni-h5-vue/dist/vue.runtime.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) {
......@@ -115,7 +114,7 @@ function initResolveSyncOpts(opts?: resolve.SyncOpts) {
return opts
}
export function rewriteSsrResolve(mode?: 2 | 3) {
export function rewriteSsrResolve() {
// 解决 ssr 时 __vite_ssr_import__("vue") 的映射
const resolve = require(require.resolve('resolve', {
paths: [
......@@ -125,11 +124,9 @@ export function rewriteSsrResolve(mode?: 2 | 3) {
const oldSync = resolve.sync
resolve.sync = (id: string, opts?: resolve.SyncOpts) => {
if (id === 'vue') {
return resolveBuiltIn(
`@dcloudio/uni-h5-vue/dist/vue.runtime.${
mode === 2 ? 'compat.' : ''
}cjs.js`
)
return resolveBuiltIn(`@dcloudio/uni-h5-vue/dist/vue.runtime.cjs.js`)
} else if (id === 'vue/package.json') {
return resolveBuiltIn(`@dcloudio/uni-h5-vue/package.json`)
}
return oldSync(id, initResolveSyncOpts(opts))
}
......
......@@ -123,6 +123,7 @@ export function uniMiniProgramPlugin(
'vue-i18n': path.resolve(__dirname, '../../lib/vue-i18n'),
...alias,
},
preserveSymlinks: true,
},
build: buildOptions(),
}
......
......@@ -53,7 +53,7 @@
"chokidar": "^3.5.2"
},
"peerDependencies": {
"vite": "^2.6.14"
"vite": "^2.7.0-beta.11"
},
"uni-app": {
"compilerVersion": "3.3.0"
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册