提交 7dfd02b1 编写于 作者: fxy060608's avatar fxy060608

chore(h5): build target

上级 2731f062
......@@ -18,7 +18,7 @@
"@dcloudio/uni-shared": "../../uni-shared",
"@vue/shared": "^3.1.1",
"vue": "^3.1.1",
"vue-router": "^4.0.8",
"vue-router": "^4.0.9",
"vuex": "^4.0.1"
},
"devDependencies": {
......
......@@ -1819,9 +1819,9 @@ postcss-value-parser@^4.1.0:
integrity sha512-97DXOFbQJhk71ne5/Mt6cOu6yxsSfM0QGQyl0L25Gca4yGWEGJaig7l7gbCX623VqTBNGLRLaVUCnNkcedlRSQ==
postcss@^8.1.10, postcss@^8.3.0:
version "8.3.4"
resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.3.4.tgz#41ece1c43f2f7c74dc7d90144047ce052757b822"
integrity sha512-/tZY0PXExXXnNhKv3TOvZAOUYRyuqcCbBm2c17YMDK0PlVII3K7/LKdt3ScHL+hhouddjUWi+1sKDf9xXW+8YA==
version "8.3.5"
resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.3.5.tgz#982216b113412bc20a86289e91eb994952a5b709"
integrity sha512-NxTuJocUhYGsMiMFHDUkmjSKT3EdH4/WbGF6GCi1NDGk+vbcUTun4fpbOqaPtD8IIsztA2ilZm2DhYCuyN58gA==
dependencies:
colorette "^1.2.2"
nanoid "^3.1.23"
......@@ -1958,9 +1958,9 @@ rollup-plugin-copy@^3.4.0:
is-plain-object "^3.0.0"
rollup@^2.38.5:
version "2.52.0"
resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.52.0.tgz#9df3de6028fae79569a985942b81110205a5a411"
integrity sha512-lSkBDGsVoXjqaBf7dsHwxBJz+p+hJEP72P+LOitA0yVs+Nzxj76FidkZE2thrmhjwGqLYiJo39opi7mAfaQ/Vg==
version "2.52.1"
resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.52.1.tgz#dd1cc178d70cf35c48d943fc06fdc32d546e6876"
integrity sha512-/SPqz8UGnp4P1hq6wc9gdTqA2bXQXGx13TtoL03GBm6qGRI6Hm3p4Io7GeiHNLl0BsQAne1JNYY+q/apcY933w==
optionalDependencies:
fsevents "~2.3.2"
......@@ -2312,7 +2312,7 @@ vite@^2.3.7:
optionalDependencies:
fsevents "~2.3.1"
vue-router@^4.0.8:
vue-router@^4.0.9:
version "4.0.9"
resolved "https://registry.yarnpkg.com/vue-router/-/vue-router-4.0.9.tgz#248496941b79c4c1010f6ebfcf235cd4267d85da"
integrity sha512-i3IaZJ57YeMbRHQlqKyXdUMr5NzTCcJkn3f8u38TsZjYWtGcd3IX2zRd3389SCOwuRf11mgfHAyngR6FVDE9og==
......
......@@ -3,6 +3,6 @@
"name": "@dcloudio/size-check",
"version": "3.0.0-alpha-3000020210611006",
"dependencies": {
"vue-router": "^4.0.8"
"vue-router": "^4.0.9"
}
}
......@@ -10719,7 +10719,10 @@ function useProvideRadioGroup(props2, trigger) {
onMounted(() => {
_resetRadioGroupValue(fields2.length - 1);
});
const getFieldsValue = () => fields2.find((field) => field.value.radioChecked)?.value.value;
const getFieldsValue = () => {
var _a;
return (_a = fields2.find((field) => field.value.radioChecked)) == null ? void 0 : _a.value.value;
};
provide(uniRadioGroupKey, {
addField(field) {
fields2.push(field);
......@@ -18372,7 +18375,8 @@ function useState() {
});
const props2 = ["topWindow", "leftWindow", "rightWindow"];
props2.forEach((prop) => {
const matchMedia = __uniConfig[prop]?.matchMedia;
var _a;
const matchMedia = (_a = __uniConfig[prop]) == null ? void 0 : _a.matchMedia;
let topWindowMinWidth = RESPONSIVE_MIN_WIDTH;
if (matchMedia && hasOwn(matchMedia, "minWidth")) {
const minWidth = matchMedia.minWidth;
......
......@@ -8,6 +8,8 @@ import replace from '@rollup/plugin-replace'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import { OutputChunk } from 'rollup'
import { stripOptions } from '@dcloudio/uni-cli-shared'
import { isCustomElement } from '@dcloudio/uni-shared'
......@@ -25,10 +27,7 @@ const rollupPlugins = [
defineTaskApi: `/*#__PURE__*/ defineTaskApi`,
defineSyncApi: `/*#__PURE__*/ defineSyncApi`,
defineAsyncApi: `/*#__PURE__*/ defineAsyncApi`,
__IMPORT_META_ENV_BASE_URL__:
FORMAT === 'cjs'
? '__IMPORT_META_ENV_BASE_URL__'
: 'import.meta.env.BASE_URL', //直接使用import.meta.env.BASE_URL会被vite替换成'/'
__IMPORT_META_ENV_BASE_URL__: '__IMPORT_META_ENV_BASE_URL__', //直接使用import.meta.env.BASE_URL会被vite替换成'/'
},
preventAssignment: true,
}),
......@@ -45,6 +44,22 @@ const rollupPlugins = [
if (FORMAT === 'cjs') {
rollupPlugins.push(strip(stripOptions))
}
if (FORMAT === 'es') {
// 解决import.meta被转换为import_meta的问题
rollupPlugins.push({
name: 'import-meta',
generateBundle(_options, bundle) {
const esBundle = bundle['uni-h5.es.js'] as unknown as OutputChunk
if (esBundle) {
esBundle.code = esBundle.code.replace(
'__IMPORT_META_ENV_BASE_URL__',
'import.meta.env.BASE_URL'
)
}
},
})
}
export default defineConfig({
root: __dirname,
define: {
......@@ -89,7 +104,7 @@ export default defineConfig({
vueJsx({ optimize: true, isCustomElement }),
],
build: {
target: FORMAT === 'cjs' ? 'modules' : 'es2020', // keep import.meta...
target: 'modules', // keep import.meta...
emptyOutDir: FORMAT === 'es',
minify: false,
lib: {
......
......@@ -20,25 +20,32 @@ let hasTSChecked = false
const configs = []
const buildOptions = require(resolve(`build.json`))
function normalizeOutput(file, output = {}) {
return Object.assign(
{
file,
format: file.includes('.cjs.') ? 'cjs' : 'es',
exports: 'auto',
},
output
)
}
Object.keys(buildOptions.input).forEach((name) => {
const files = buildOptions.input[name]
if (Array.isArray(files)) {
files.forEach((file) => {
configs.push(
createConfig(name, {
file: resolve(file),
format: file.includes('.cjs.') ? 'cjs' : 'es',
exports: 'auto',
})
createConfig(name, normalizeOutput(resolve(file), buildOptions.output))
)
})
} else {
configs.push(
createConfig(name, {
file: resolve(buildOptions.input[name]),
format: (buildOptions.output && buildOptions.output.format) || `es`,
exports: 'auto',
})
createConfig(
name,
normalizeOutput(resolve(buildOptions.input[name]), buildOptions.output)
)
)
}
})
......@@ -46,7 +53,6 @@ export default configs
function createConfig(entryFile, output, plugins = []) {
const shouldEmitDeclarations = process.env.TYPES != null && !hasTSChecked
const tsPlugin = ts({
check:
!process.env.CI && process.env.NODE_ENV === 'production' && !hasTSChecked,
......@@ -67,13 +73,16 @@ function createConfig(entryFile, output, plugins = []) {
// during a single build.
hasTSChecked = true
const external = [
'vue',
'@vue/shared',
...Object.keys(pkg.dependencies || {}),
...Object.keys(pkg.peerDependencies || {}),
...(buildOptions.external || []),
]
const external =
buildOptions.external === false
? []
: [
'vue',
'@vue/shared',
...Object.keys(pkg.dependencies || {}),
...Object.keys(pkg.peerDependencies || {}),
...(buildOptions.external || []),
]
return {
input: resolve(entryFile),
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册