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

chore(h5): build target

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