diff --git a/packages/size-check/package.json b/packages/size-check/package.json index e13f5ab24fef44cdc36f6dd08057fb5ce2385b16..46dbeb06cdca81cbbfd165d13a2bed3fd83777a8 100644 --- a/packages/size-check/package.json +++ b/packages/size-check/package.json @@ -2,9 +2,6 @@ "private": true, "name": "@dcloudio/size-check", "version": "3.0.0-alpha-3000020210611006", - "buildOptions": { - "bundler": "vite" - }, "dependencies": { "vue-router": "^4.0.8" } diff --git a/packages/uni-app/dist/uni-app.d.ts b/packages/uni-app/dist/uni-app.d.ts deleted file mode 100644 index a04a7bcf3f5459a0601389c3a23644ebc78d0437..0000000000000000000000000000000000000000 --- a/packages/uni-app/dist/uni-app.d.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { ComponentInternalInstance } from 'vue'; -import { ref } from 'vue'; -import { shallowRef } from 'vue'; - -export declare function getSsrGlobalData(): any; - -export declare const onAddToFavorites: (hook: () => any, target?: ComponentInternalInstance | null) => any; - -export declare const onBackPress: (hook: () => any, target?: ComponentInternalInstance | null) => any; - -export declare const onError: (hook: () => any, target?: ComponentInternalInstance | null) => any; - -export declare const onHide: (hook: () => any, target?: ComponentInternalInstance | null) => any; - -export declare const onLaunch: (hook: () => any, target?: ComponentInternalInstance | null) => any; - -export declare const onNavigationBarButtonTap: (hook: () => any, target?: ComponentInternalInstance | null) => any; - -export declare const onNavigationBarSearchInputChanged: (hook: () => any, target?: ComponentInternalInstance | null) => any; - -export declare const onNavigationBarSearchInputClicked: (hook: () => any, target?: ComponentInternalInstance | null) => any; - -export declare const onNavigationBarSearchInputConfirmed: (hook: () => any, target?: ComponentInternalInstance | null) => any; - -export declare const onNavigationBarSearchInputFocusChanged: (hook: () => any, target?: ComponentInternalInstance | null) => any; - -export declare const onPageNotFound: (hook: () => any, target?: ComponentInternalInstance | null) => any; - -export declare const onPageScroll: (hook: () => any, target?: ComponentInternalInstance | null) => any; - -export declare const onPullDownRefresh: (hook: () => any, target?: ComponentInternalInstance | null) => any; - -export declare const onReachBottom: (hook: () => any, target?: ComponentInternalInstance | null) => any; - -export declare const onReady: (hook: () => any, target?: ComponentInternalInstance | null) => any; - -export declare const onResize: (hook: () => any, target?: ComponentInternalInstance | null) => any; - -export declare const onShareAppMessage: (hook: () => any, target?: ComponentInternalInstance | null) => any; - -export declare const onShareTimeline: (hook: () => any, target?: ComponentInternalInstance | null) => any; - -export declare const onShow: (hook: () => any, target?: ComponentInternalInstance | null) => any; - -export declare const onTabItemTap: (hook: () => any, target?: ComponentInternalInstance | null) => any; - -export declare const onThemeChange: (hook: () => any, target?: ComponentInternalInstance | null) => any; - -export declare const onUnhandledRejection: (hook: () => any, target?: ComponentInternalInstance | null) => any; - -export declare const onUnload: (hook: () => any, target?: ComponentInternalInstance | null) => any; - -export declare function resolveEasycom(component: unknown, easycom: unknown): unknown; - -export declare const shallowSsrRef: SSRRef; - -declare type SSRRef = (value: unknown, key?: string, shallow?: boolean) => ReturnType | ReturnType; - -export declare const ssrRef: SSRRef; - -export { } diff --git a/packages/uni-cli-shared/package.json b/packages/uni-cli-shared/package.json index d9f93ce720808243446d257e052a2298880bca6e..6209feb58a1ee381ecedfbe309709b1c605ae785 100644 --- a/packages/uni-cli-shared/package.json +++ b/packages/uni-cli-shared/package.json @@ -9,9 +9,6 @@ "dist/**/*.d.ts", "lib" ], - "buildOptions": { - "bundler": "tsc" - }, "repository": { "type": "git", "url": "git+https://github.com/dcloudio/uni-app.git", diff --git a/packages/uni-h5-vite/package.json b/packages/uni-h5-vite/package.json index 9563f911117513d3e35ffe6ac61f066113faa64e..7e0196d38a403e7efe7b32c9e5d65650bf16c534 100644 --- a/packages/uni-h5-vite/package.json +++ b/packages/uni-h5-vite/package.json @@ -8,9 +8,6 @@ "dist/**/*.js", "dist/**/*.d.ts" ], - "buildOptions": { - "bundler": "tsc" - }, "repository": { "type": "git", "url": "git+https://github.com/dcloudio/uni-app.git", diff --git a/packages/uni-h5/package.json b/packages/uni-h5/package.json index 958dee2dd86a9b29035c70832fb007918524849d..5c5efd56b2a72ea1c0072f686382ad56a966be63 100644 --- a/packages/uni-h5/package.json +++ b/packages/uni-h5/package.json @@ -10,9 +10,6 @@ "style" ], "sideEffects": false, - "buildOptions": { - "bundler": "vite" - }, "repository": { "type": "git", "url": "git+https://github.com/dcloudio/uni-app.git", diff --git a/packages/uni-i18n/dist/uni-i18n.d.ts b/packages/uni-i18n/dist/uni-i18n.d.ts deleted file mode 100644 index 68ce2d50c213da553d5ab0c8fa5af60919cd0f74..0000000000000000000000000000000000000000 --- a/packages/uni-i18n/dist/uni-i18n.d.ts +++ /dev/null @@ -1,56 +0,0 @@ - -export declare type BuiltInLocale = typeof LOCALE_ZH_HANS | typeof LOCALE_ZH_HANT | typeof LOCALE_EN | typeof LOCALE_FR | typeof LOCALE_ES; - -export declare interface Formatter { - interpolate: (message: string, values?: Record | Array) => Array; -} - -export declare class I18n { - private locale; - private fallbackLocale; - private message; - private messages; - private watchers; - private formater; - constructor({ locale, fallbackLocale, messages, watcher, formater, }: I18nOptions); - setLocale(locale: string): void; - getLocale(): BuiltInLocale; - watchLocale(fn: LocaleWatcher): () => void; - add(locale: BuiltInLocale, message: Record): void; - t(key: string, values?: Record | Array | BuiltInLocale): string; - t(key: string, locale?: BuiltInLocale, values?: Record | Array): string; -} - -export declare interface I18nOptions { - locale: BuiltInLocale; - fallbackLocale?: BuiltInLocale; - messages?: LocaleMessages; - formater?: Formatter; - watcher?: LocaleWatcher; -} - -export declare function initVueI18n(locale?: BuiltInLocale, messages?: LocaleMessages, fallbackLocale?: BuiltInLocale): { - i18n: I18n; - t(key: string, values?: Record | unknown[] | undefined): string; - add(locale: BuiltInLocale, message: Record): void; - getLocale(): BuiltInLocale; - setLocale(newLocale: BuiltInLocale): void; -}; - -export declare const LOCALE_EN = "en"; - -export declare const LOCALE_ES = "es"; - -export declare const LOCALE_FR = "fr"; - -export declare const LOCALE_ZH_HANS = "zh-Hans"; - -export declare const LOCALE_ZH_HANT = "zh-Hant"; - -export declare type LocaleMessages = { - [name in BuiltInLocale]?: Record; -}; - -export declare type LocaleWatcher = (newLocale: BuiltInLocale, oldLocale: BuiltInLocale) => void; - -export { } diff --git a/packages/uni-mp-vue/package.json b/packages/uni-mp-vue/package.json index f3cec6e6237973e646442f69fb24bfbe37e79300..8bd29009e1bb52e9c942af189180dcf6e0fb06d5 100644 --- a/packages/uni-mp-vue/package.json +++ b/packages/uni-mp-vue/package.json @@ -7,12 +7,6 @@ "files": [ "dist" ], - "buildOptions": { - "name": "Vue", - "formats": [ - "esm-bundler-vue" - ] - }, "sideEffects": false, "repository": { "type": "git", diff --git a/packages/vite-plugin-uni/package.json b/packages/vite-plugin-uni/package.json index 75d686d1af690394d942faa51a3a77ff1ae1cc27..6e8a547f68ac4d7e765b0782187acda783dfb2db 100644 --- a/packages/vite-plugin-uni/package.json +++ b/packages/vite-plugin-uni/package.json @@ -12,9 +12,6 @@ "dist/**/*.d.ts", "lib" ], - "buildOptions": { - "bundler": "tsc" - }, "repository": { "type": "git", "url": "git+https://github.com/dcloudio/uni-app.git", diff --git a/scripts/build.js b/scripts/build.js index 8c80c87a6daf8ede9ac63de1e28bd9bebe41647d..6b1a5a60fa124d71026dbbef2b252bbbb9488642 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -9,7 +9,7 @@ const { targets: allTargets, fuzzyMatchTarget } = require('./utils') const args = require('minimist')(process.argv.slice(2)) const targets = args._ -const formats = args.formats || args.f +// const formats = args.formats || args.f const devOnly = args.devOnly || args.d const isRelease = args.release const buildTypes = args.t || args.types || isRelease @@ -40,22 +40,29 @@ async function build(target) { if (isRelease && pkg.private) { return } + const tsconfigJsonPath = path.resolve(pkgDir, 'tsconfig.json') + let hasTscBundler = false + const hasViteBundler = fs.existsSync(path.resolve(pkgDir, 'vite.config.ts')) + if (fs.existsSync(tsconfigJsonPath)) { + const tsconfigJson = require(tsconfigJsonPath) + if ( + tsconfigJson.extends && + tsconfigJson.extends.includes('tsconfig.node.json') + ) { + hasTscBundler = true + } + } + const hasRollupBundler = fs.existsSync(path.resolve(pkgDir, 'build.json')) - const bundler = pkg.buildOptions && pkg.buildOptions.bundler - const types = - target === 'uni-shared' || - target === 'uni-i18n' || - target === 'uni-app' || - target === 'uni-cli-shared' || - (buildTypes && pkg.types) + const types = target.endsWith('-shared') || (buildTypes && pkg.types) // if building a specific format, do not remove dist. - if (!formats && bundler !== 'vite') { - await fs.remove(`${pkgDir}/dist`) - } + // if (!formats && bundler !== 'vite') { + await fs.remove(`${pkgDir}/dist`) + // } const env = devOnly ? 'development' : 'production' - if (bundler === 'vite') { + if (hasViteBundler) { await execa( 'vite', ['build', '--config', path.resolve(pkgDir, 'vite.config.ts')], @@ -64,18 +71,18 @@ async function build(target) { env: Object.assign({ FORMAT: 'es' }, process.env), } ) - if (target === 'size-check') { - return + if (target === 'uni-h5') { + await execa( + 'vite', + ['build', '--config', path.resolve(pkgDir, 'vite.config.ts')], + { + stdio: 'inherit', + env: Object.assign({ FORMAT: 'cjs' }, process.env), + } + ) } - return await execa( - 'vite', - ['build', '--config', path.resolve(pkgDir, 'vite.config.ts')], - { - stdio: 'inherit', - env: Object.assign({ FORMAT: 'cjs' }, process.env), - } - ) - } else if (bundler === 'tsc') { + } + if (hasTscBundler) { const args = [ '--listEmittedFiles', '-p', @@ -84,23 +91,24 @@ async function build(target) { if (types) { args.push('--declaration') } - return await execa('tsc', args, { + await execa('tsc', args, { stdio: 'inherit', }) } - - await execa( - 'rollup', - [ - '-c', - '--environment', - [`NODE_ENV:${env}`, types ? `TYPES:true` : ``, `TARGET:${target}`] - .filter(Boolean) - .join(','), - ], - { stdio: 'inherit' } - ) - if (types) { - await extract(target) + if (hasRollupBundler) { + await execa( + 'rollup', + [ + '-c', + '--environment', + [`NODE_ENV:${env}`, types ? `TYPES:true` : ``, `TARGET:${target}`] + .filter(Boolean) + .join(','), + ], + { stdio: 'inherit' } + ) + if (types) { + await extract(target) + } } } diff --git a/scripts/utils.js b/scripts/utils.js index cd712d02821dea6e8d781aa1bdb6200d9e4271f1..12786ccfdbf54c0c899e9c6180b9ac9ab98a62f0 100644 --- a/scripts/utils.js +++ b/scripts/utils.js @@ -15,8 +15,8 @@ const priority = { 'uni-quickapp-webview': 70, 'uni-cli-shared': 60, 'uni-h5': 50, - 'uni-h5-vue': 40, 'uni-h5-vite': 40, + 'uni-app-vue': 35, 'uni-app-plus': 30, 'uni-app-vite': 30, 'vite-plugin-uni': 20, @@ -30,9 +30,10 @@ const targets = (exports.targets = fs.readdirSync('packages').filter((f) => { try { return ( fs.existsSync(path.resolve(__dirname, `../packages/${f}/build.json`)) || - fs.existsSync(path.resolve(__dirname, `../packages/${f}/build.js`)) || - !!require(path.resolve(__dirname, `../packages/${f}/package.json`)) - .buildOptions + fs.existsSync( + path.resolve(__dirname, `../packages/${f}/vite.config.ts`) + ) || + fs.existsSync(path.resolve(__dirname, `../packages/${f}/tsconfig.json`)) ) } catch (e) {} return false