diff --git a/package.json b/package.json index 93e44429500f..dd721059eb8b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "taro", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "开放式跨端跨框架开发解决方案", "homepage": "https://github.com/NervJS/taro#readme", "author": "O2Team", diff --git a/packages/babel-plugin-transform-react-jsx-to-rn-stylesheet/package.json b/packages/babel-plugin-transform-react-jsx-to-rn-stylesheet/package.json index 43de99556707..a8e9ecf8a58e 100644 --- a/packages/babel-plugin-transform-react-jsx-to-rn-stylesheet/package.json +++ b/packages/babel-plugin-transform-react-jsx-to-rn-stylesheet/package.json @@ -1,6 +1,6 @@ { "name": "babel-plugin-transform-react-jsx-to-rn-stylesheet", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "Transform stylesheet selector to style in JSX Elements.", "license": "MIT", "main": "dist/index.js", diff --git a/packages/babel-plugin-transform-taroapi/package.json b/packages/babel-plugin-transform-taroapi/package.json index 7de7d5b9596e..266c8e12dae6 100644 --- a/packages/babel-plugin-transform-taroapi/package.json +++ b/packages/babel-plugin-transform-taroapi/package.json @@ -1,6 +1,6 @@ { "name": "babel-plugin-transform-taroapi", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "main": "dist/index.js", "scripts": { "build": "tsc", diff --git a/packages/babel-preset-taro/package.json b/packages/babel-preset-taro/package.json index 70a3ece15965..3beb4aafda06 100644 --- a/packages/babel-preset-taro/package.json +++ b/packages/babel-preset-taro/package.json @@ -1,6 +1,6 @@ { "name": "babel-preset-taro", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "Taro babel preset", "author": "yuche ", "homepage": "https://github.com/nervjs/taro/tree/master/packages/babel-preset-taro#readme", diff --git a/packages/create-app/package.json b/packages/create-app/package.json index 28453c370e95..2fdb19bbd2bb 100644 --- a/packages/create-app/package.json +++ b/packages/create-app/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/create-app", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "create taro app with one command", "author": "VincentW ", "homepage": "https://github.com/nervjs/taro/tree/master/packages/create-app#readme", diff --git a/packages/css-to-react-native/package.json b/packages/css-to-react-native/package.json index b5b6235dc749..6fd4cf69b64f 100644 --- a/packages/css-to-react-native/package.json +++ b/packages/css-to-react-native/package.json @@ -1,7 +1,7 @@ { "name": "taro-css-to-react-native", "description": "Convert CSS text to a React Native stylesheet object", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "main": "dist/index.js", "license": "MIT", "files": [ diff --git a/packages/eslint-config-taro/package.json b/packages/eslint-config-taro/package.json index d386ac005697..10740a05b273 100644 --- a/packages/eslint-config-taro/package.json +++ b/packages/eslint-config-taro/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-taro", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "Taro specific linting rules for ESLint", "main": "index.js", "files": [ diff --git a/packages/postcss-html-transform/package.json b/packages/postcss-html-transform/package.json index 8d93cf05b460..b7484aadfa5e 100644 --- a/packages/postcss-html-transform/package.json +++ b/packages/postcss-html-transform/package.json @@ -1,6 +1,6 @@ { "name": "postcss-html-transform", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "transform html tag name selector", "main": "index.js", "author": "drchan", diff --git a/packages/postcss-plugin-constparse/package.json b/packages/postcss-plugin-constparse/package.json index ca2cb8c78606..082de1a49ede 100644 --- a/packages/postcss-plugin-constparse/package.json +++ b/packages/postcss-plugin-constparse/package.json @@ -1,6 +1,6 @@ { "name": "postcss-plugin-constparse", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "parse constants defined in config", "main": "index.js", "author": "Simba", diff --git a/packages/postcss-pxtransform/package.json b/packages/postcss-pxtransform/package.json index 867a0ecc22f6..273deb48d395 100644 --- a/packages/postcss-pxtransform/package.json +++ b/packages/postcss-pxtransform/package.json @@ -1,6 +1,6 @@ { "name": "postcss-pxtransform", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "PostCSS plugin px 转小程序 rpx及h5 rem 单位", "main": "index.js", "keywords": [ diff --git a/packages/shared/package.json b/packages/shared/package.json index c42213176989..4aa77ee80a97 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/shared", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "Taro utils internal use.", "author": "yuche ", "homepage": "https://github.com/nervjs/taro/tree/master/packages/shared#readme", diff --git a/packages/stylelint-config-taro-rn/package.json b/packages/stylelint-config-taro-rn/package.json index 3ba1428cb80c..1150f409c006 100644 --- a/packages/stylelint-config-taro-rn/package.json +++ b/packages/stylelint-config-taro-rn/package.json @@ -1,6 +1,6 @@ { "name": "stylelint-config-taro-rn", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "Shareable stylelint config for React Native CSS modules", "main": "index.js", "files": [ diff --git a/packages/stylelint-taro-rn/package.json b/packages/stylelint-taro-rn/package.json index c0ae677ad77d..6c8c6c6c4fdd 100644 --- a/packages/stylelint-taro-rn/package.json +++ b/packages/stylelint-taro-rn/package.json @@ -1,7 +1,7 @@ { "name": "stylelint-taro-rn", "description": "A collection of React Native specific rules for stylelint", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "main": "dist/index.js", "files": [ "dist", diff --git a/packages/taro-alipay/package.json b/packages/taro-alipay/package.json index 69e40f1a1e1b..9821b189b0a9 100644 --- a/packages/taro-alipay/package.json +++ b/packages/taro-alipay/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/plugin-platform-alipay", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "支付宝小程序平台插件", "author": "Chen-jj", "homepage": "https://github.com/nervjs/taro/tree/master/packages/taro-alipay#readme", diff --git a/packages/taro-api/package.json b/packages/taro-api/package.json index 9aab5499e163..d932bceafe69 100644 --- a/packages/taro-api/package.json +++ b/packages/taro-api/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/api", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "Taro common API", "author": "yuche ", "homepage": "https://github.com/nervjs/taro/tree/master/packages/api#readme", diff --git a/packages/taro-cli-convertor/package.json b/packages/taro-cli-convertor/package.json index fdc87f100457..d3104b3829d0 100644 --- a/packages/taro-cli-convertor/package.json +++ b/packages/taro-cli-convertor/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/cli-convertor", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "cli tool for taro-convert", "main": "index.js", "scripts": { diff --git a/packages/taro-cli/package.json b/packages/taro-cli/package.json index 6fc5b1edfc76..70e5b742b552 100644 --- a/packages/taro-cli/package.json +++ b/packages/taro-cli/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/cli", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "cli tool for taro", "main": "index.js", "types": "dist/index.d.ts", diff --git a/packages/taro-cli/src/__tests__/build-config.spec.ts b/packages/taro-cli/src/__tests__/build-config.spec.ts new file mode 100644 index 000000000000..4cdeaebf49e7 --- /dev/null +++ b/packages/taro-cli/src/__tests__/build-config.spec.ts @@ -0,0 +1,98 @@ +import { emptyDirectory } from '@tarojs/helper' +import * as path from 'path' + +import { run } from './utils' + +const runBuild = run('build', [ + 'commands/build', + require.resolve('@tarojs/plugin-platform-weapp'), + require.resolve('@tarojs/plugin-platform-h5') +]) + +jest.mock('@tarojs/helper', () => { + const helper = jest.requireActual('@tarojs/helper') + const fs = helper.fs + return { + __esModule: true, + ...helper, + emptyDirectory: jest.fn(), + fs: { + ...fs + }, + } +}) + +const APP_PATH = path.join(__dirname, 'fixtures/default') +const OUTPUT_PATH = path.join(__dirname, 'fixtures/default/dist') + +describe('构建配置测试', () => { + const emptyDirectoryMocked = emptyDirectory as jest.Mock + + beforeEach(() => { + emptyDirectoryMocked.mockReset() + process.argv = [] + }) + + afterEach(() => { + process.argv = [] + emptyDirectoryMocked.mockReset() + }) + + describe('小程序', () => { + it(`项目 output.clean = clean: { keep: ['project.config.json'] } ==> 清空dist文件夹但保留指定文件`, async () => { + const exitSpy = jest.spyOn(process, 'exit') as jest.SpyInstance + const logSpy = jest.spyOn(console, 'log') + const errorSpy = jest.spyOn(console, 'error') + logSpy.mockImplementation(() => {}) + errorSpy.mockImplementation(() => {}) + exitSpy.mockImplementation(() => { + throw new Error() + }) + + try { + await runBuild(APP_PATH, { + options: { + type: 'weapp', + platform: 'weapp' + } + }) + } catch (error) { + // no handler + } + expect(emptyDirectoryMocked).toBeCalledWith(OUTPUT_PATH, { excludes: ['project.config.json'] }) + + exitSpy.mockRestore() + logSpy.mockRestore() + errorSpy.mockRestore() + }) + }) + + describe('h5', () => { + it('output.clean = false ==> 保留dist文件夹', async () => { + const exitSpy = jest.spyOn(process, 'exit') as jest.SpyInstance + const logSpy = jest.spyOn(console, 'log') + const errorSpy = jest.spyOn(console, 'error') + logSpy.mockImplementation(() => {}) + errorSpy.mockImplementation(() => {}) + exitSpy.mockImplementation(() => { + throw new Error() + }) + + try { + await runBuild(APP_PATH, { + options: { + type: 'h5', + platform: 'h5' + } + }) + } catch (error) { + // no handler + } + expect(emptyDirectoryMocked).toBeCalledTimes(0) + + exitSpy.mockRestore() + logSpy.mockRestore() + errorSpy.mockRestore() + }) + }) +}) diff --git a/packages/taro-cli/src/__tests__/dotenv-parse.spec.ts b/packages/taro-cli/src/__tests__/dotenv-parse.spec.ts new file mode 100644 index 000000000000..927a22562675 --- /dev/null +++ b/packages/taro-cli/src/__tests__/dotenv-parse.spec.ts @@ -0,0 +1,105 @@ +import { Kernel } from '@tarojs/service' +import * as path from 'path' + +import CLI from '../cli' +import { dotenvParse } from '../util/index' + +jest.mock('@tarojs/service') +const MockedKernel = Kernel as unknown as jest.Mock +const APP_PATH = path.join(__dirname, 'fixtures/default') + +function setProcessArgv (cmd: string) { + // @ts-ignore + process.argv = [null, ...cmd.split(' ')] +} + +describe('inspect', () => { + let cli: CLI + + beforeAll(() => { + cli = new CLI(APP_PATH) + }) + + beforeEach(() => { + MockedKernel.mockClear() + process.argv = [] + delete process.env.NODE_ENV + delete process.env.TARO_ENV + delete process.env.TARO_APP_TEST + delete process.env.TARO_APP_ID + delete process.env.JD_APP_TEST + delete process.env.TARO_APP_DEFAULT + delete process.env.TARO_APP_FOO + }) + + afterEach(() => { + MockedKernel.mockClear() + process.argv = [] + delete process.env.NODE_ENV + delete process.env.TARO_ENV + delete process.env.TARO_APP_TEST + delete process.env.TARO_APP_ID + delete process.env.JD_APP_TEST + delete process.env.TARO_APP_DEFAULT + delete process.env.TARO_APP_FOO + }) + + describe('cli mode env', () => { + + it('dotenvParse .env .env.dev should success', async () => { + expect(process.env.TARO_test).toBeUndefined() + dotenvParse(path.resolve(__dirname, 'env'), 'TARO_', 'dev') + expect(process.env.TARO_test).toBe('123') + expect(process.env._TARO_test).toBeUndefined() + }) + + it('--watch true => 默认加载 .env.development', async () => { + setProcessArgv('taro build --watch --type weapp') + await cli.run() + expect(process.env.TARO_APP_TEST).toEqual('env-development') + expect(process.env.TARO_APP_DEFAULT).toEqual('default') + }) + + it('--watch false => 默认加载 .env.production', async () => { + setProcessArgv('taro build --type weapp') + await cli.run() + expect(process.env.TARO_APP_TEST).toEqual('env-production') + expect(process.env.TARO_APP_DEFAULT).toEqual('default') + }) + + it('指定加载 .env.pre', async () => { + setProcessArgv('taro build --type weapp --mode pre') + await cli.run() + expect(process.env.TARO_APP_TEST).toEqual('env-pre') + expect(process.env.TARO_APP_DEFAULT).toEqual('default') + }) + + it('env.local 比 .env 优先级更高', async () => { + setProcessArgv('taro build --type weapp --mode find404') + await cli.run() + expect(process.env.TARO_APP_TEST).toEqual('env-local') + expect(process.env.TARO_APP_DEFAULT).toEqual('default') + }) + + it('env.uat.local 比 .env.uat 优先级更高', async () => { + setProcessArgv('taro build --type weapp --mode uat') + await cli.run() + expect(process.env.TARO_APP_TEST).toEqual('env-uat-local') + expect(process.env.TARO_APP_DEFAULT).toEqual('default') + }) + + it('自定义前缀: JD_APP_', async () => { + setProcessArgv('taro build --type weapp --mode uat --env-prefix JD_APP_') + await cli.run() + expect(process.env.JD_APP_TEST).toEqual('env-uat') + expect(process.env.TARO_APP_TEST).toEqual(undefined) + expect(process.env.TARO_APP_ID).toEqual('特殊变量appid') + }) + + it('环境变量可以相互引用', async () => { + setProcessArgv('taro build --type weapp --mode pre') + await cli.run() + expect(process.env.TARO_APP_FOO).toEqual('env-pre-foo') + }) + }) +}) diff --git a/packages/taro-cli/src/__tests__/dotenvParse.spec.ts b/packages/taro-cli/src/__tests__/dotenvParse.spec.ts deleted file mode 100644 index 7d9ecd8734c6..000000000000 --- a/packages/taro-cli/src/__tests__/dotenvParse.spec.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { resolve } from 'path' - -import { dotenvParse } from '../util/index' - - -describe('dotenvParse', () => { - it('dotenvParse .env .env.dev should success', async () => { - expect(process.env.TARO_test).toBeUndefined() - dotenvParse(resolve(__dirname, 'env'), 'TARO_', 'dev') - expect(process.env.TARO_test).toBe('123') - expect(process.env._TARO_test).toBeUndefined() - }) -}) diff --git a/packages/taro-cli/src/__tests__/fixtures/default/.env b/packages/taro-cli/src/__tests__/fixtures/default/.env new file mode 100644 index 000000000000..76bb7901e115 --- /dev/null +++ b/packages/taro-cli/src/__tests__/fixtures/default/.env @@ -0,0 +1,3 @@ +TARO_APP_TEST=env + +TARO_APP_DEFAULT=default \ No newline at end of file diff --git a/packages/taro-cli/src/__tests__/fixtures/default/.env.development b/packages/taro-cli/src/__tests__/fixtures/default/.env.development new file mode 100644 index 000000000000..36bcd02cf475 --- /dev/null +++ b/packages/taro-cli/src/__tests__/fixtures/default/.env.development @@ -0,0 +1 @@ +TARO_APP_TEST=env-development \ No newline at end of file diff --git a/packages/taro-cli/src/__tests__/fixtures/default/.env.local b/packages/taro-cli/src/__tests__/fixtures/default/.env.local new file mode 100644 index 000000000000..2acb5bd7b177 --- /dev/null +++ b/packages/taro-cli/src/__tests__/fixtures/default/.env.local @@ -0,0 +1 @@ +TARO_APP_TEST=env-local \ No newline at end of file diff --git a/packages/taro-cli/src/__tests__/fixtures/default/.env.pre b/packages/taro-cli/src/__tests__/fixtures/default/.env.pre new file mode 100644 index 000000000000..ec139f2c5960 --- /dev/null +++ b/packages/taro-cli/src/__tests__/fixtures/default/.env.pre @@ -0,0 +1,3 @@ +TARO_APP_TEST=env-pre + +TARO_APP_FOO=${TARO_APP_TEST}-foo \ No newline at end of file diff --git a/packages/taro-cli/src/__tests__/fixtures/default/.env.production b/packages/taro-cli/src/__tests__/fixtures/default/.env.production new file mode 100644 index 000000000000..499f0896e082 --- /dev/null +++ b/packages/taro-cli/src/__tests__/fixtures/default/.env.production @@ -0,0 +1 @@ +TARO_APP_TEST=env-production \ No newline at end of file diff --git a/packages/taro-cli/src/__tests__/fixtures/default/.env.uat b/packages/taro-cli/src/__tests__/fixtures/default/.env.uat new file mode 100644 index 000000000000..3ff2c5f45108 --- /dev/null +++ b/packages/taro-cli/src/__tests__/fixtures/default/.env.uat @@ -0,0 +1,5 @@ +TARO_APP_TEST=env-uat + +JD_APP_TEST=env-uat + +TARO_APP_ID=特殊变量appid \ No newline at end of file diff --git a/packages/taro-cli/src/__tests__/fixtures/default/.env.uat.local b/packages/taro-cli/src/__tests__/fixtures/default/.env.uat.local new file mode 100644 index 000000000000..e5819429e8d4 --- /dev/null +++ b/packages/taro-cli/src/__tests__/fixtures/default/.env.uat.local @@ -0,0 +1 @@ +TARO_APP_TEST=env-uat-local \ No newline at end of file diff --git a/packages/taro-cli/src/__tests__/fixtures/default/config/index.js b/packages/taro-cli/src/__tests__/fixtures/default/config/index.js index 7c0c9a7ad688..ea835b8a9adf 100644 --- a/packages/taro-cli/src/__tests__/fixtures/default/config/index.js +++ b/packages/taro-cli/src/__tests__/fixtures/default/config/index.js @@ -20,6 +20,11 @@ const config = { }, framework: 'react', mini: { + output: { + clean: { + keep: ['project.config.json'] + } + }, postcss: { pxtransform: { enable: true, @@ -43,6 +48,9 @@ const config = { } }, h5: { + output: { + clean: false + }, publicPath: '/', staticDirectory: 'static', postcss: { diff --git a/packages/taro-cli/src/create/fetchTemplate.ts b/packages/taro-cli/src/create/fetchTemplate.ts index 7de115660192..f458d0b3bc9c 100644 --- a/packages/taro-cli/src/create/fetchTemplate.ts +++ b/packages/taro-cli/src/create/fetchTemplate.ts @@ -20,6 +20,7 @@ export default function fetchTemplate (templateSource: string, templateRootPath: const type = getTemplateSourceType(templateSource) const tempPath = path.join(templateRootPath, TEMP_DOWNLOAD_FOLDER) let name: string + let isFromUrl = false // eslint-disable-next-line no-async-promise-executor return new Promise(async (resolve) => { @@ -44,24 +45,18 @@ export default function fetchTemplate (templateSource: string, templateRootPath: resolve() }) } else if (type === 'url') { - const zipPath = path.join(tempPath, 'temp.zip') + // url 模板源,因为不知道来源名称,临时取名方便后续开发者从列表中选择 + name = 'from-remote-url' + isFromUrl = true + const zipPath = path.join(tempPath, name + '.zip') request .get(templateSource) .pipe(fs.createWriteStream(zipPath)) .on('close', () => { // unzip const zip = new AdmZip(zipPath) - zip.extractAllTo(tempPath, true) - const files = readDirWithFileTypes(tempPath).filter( - file => !file.name.startsWith('.') && file.isDirectory && file.name !== '__MACOSX' - ) - if (files.length !== 1) { - spinner.color = 'red' - spinner.fail(chalk.red(`拉取远程模板仓库失败!\n${new Error('远程模板源组织格式错误')}`)) - return resolve() - } - - name = files[0].name + zip.extractAllTo(path.join(tempPath, name), true) + spinner.color = 'green' spinner.succeed(`${chalk.grey('拉取远程模板仓库成功!')}`) resolve() @@ -79,7 +74,10 @@ export default function fetchTemplate (templateSource: string, templateRootPath: // 下载失败,只显示默认模板 if (!fs.existsSync(templateFolder)) return Promise.resolve([]) - const isTemplateGroup = !fs.existsSync(path.join(templateFolder, 'package.json')) + const isTemplateGroup = !( + fs.existsSync(path.join(templateFolder, 'package.json')) || + fs.existsSync(path.join(templateFolder, 'package.json.tmpl')) + ) if (isTemplateGroup) { // 模板组 @@ -114,7 +112,7 @@ export default function fetchTemplate (templateSource: string, templateRootPath: await fs.move(templateFolder, path.join(templateRootPath, name), { overwrite: true }) await fs.remove(tempPath) - let res: ITemplates = { name } + let res: ITemplates = { name, desc: isFromUrl ? templateSource : '' } const creatorFile = path.join(templateRootPath, name, TEMPLATE_CREATOR) if (fs.existsSync(creatorFile)) { @@ -123,7 +121,7 @@ export default function fetchTemplate (templateSource: string, templateRootPath: res = { name, platforms, - desc + desc: desc || templateSource } } diff --git a/packages/taro-cli/src/presets/platforms/plugin.ts b/packages/taro-cli/src/presets/platforms/plugin.ts index df0b07337965..baba4eb4a327 100644 --- a/packages/taro-cli/src/presets/platforms/plugin.ts +++ b/packages/taro-cli/src/presets/platforms/plugin.ts @@ -35,8 +35,7 @@ export default (ctx: IPluginContext) => { isBuildPlugin: true, isWatch, outputRoot: `${config.outputRoot}`, - platform, - needClearOutput: false + platform }, options: Object.assign({}, options, { platform @@ -52,8 +51,7 @@ export default (ctx: IPluginContext) => { isBuildPlugin: false, isWatch, outputRoot: `${config.outputRoot}/miniprogram`, - platform, - needClearOutput: false + platform }, options: Object.assign({}, options, { platform diff --git a/packages/taro-components-advanced/package.json b/packages/taro-components-advanced/package.json index 14284755e0cf..353eecfa645a 100644 --- a/packages/taro-components-advanced/package.json +++ b/packages/taro-components-advanced/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/components-advanced", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/packages/taro-components-library-react/package.json b/packages/taro-components-library-react/package.json index 3e84dc1b6de4..a7de3b4d45e5 100644 --- a/packages/taro-components-library-react/package.json +++ b/packages/taro-components-library-react/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/components-library-react", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "Taro 组件库 React 版本库", "private": true, "main": "index.js", diff --git a/packages/taro-components-library-vue2/package.json b/packages/taro-components-library-vue2/package.json index c5c80657e6f4..6744500edd8b 100644 --- a/packages/taro-components-library-vue2/package.json +++ b/packages/taro-components-library-vue2/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/components-library-vue2", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "Taro 组件库 Vue2 版本库", "private": true, "main": "index.js", diff --git a/packages/taro-components-library-vue3/package.json b/packages/taro-components-library-vue3/package.json index e181a3952616..048ad7914eeb 100644 --- a/packages/taro-components-library-vue3/package.json +++ b/packages/taro-components-library-vue3/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/components-library-vue3", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "Taro 组件库 Vue3 版本库", "private": true, "main": "index.js", diff --git a/packages/taro-components-react/package.json b/packages/taro-components-react/package.json index 913c2babb9bb..f615caa0e44e 100644 --- a/packages/taro-components-react/package.json +++ b/packages/taro-components-react/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/components-react", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "", "main:h5": "src/index.js", "main": "dist/index.js", diff --git a/packages/taro-components-rn/package.json b/packages/taro-components-rn/package.json index 894a84fe7167..97d4f55fca8d 100644 --- a/packages/taro-components-rn/package.json +++ b/packages/taro-components-rn/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/components-rn", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "多端解决方案基础组件(RN)", "main": "./dist/index.js", "scripts": { diff --git a/packages/taro-components/package.json b/packages/taro-components/package.json index 247507bd3705..b95eba686171 100644 --- a/packages/taro-components/package.json +++ b/packages/taro-components/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/components", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "Taro 组件库", "browser": "dist/index.js", "main:h5": "dist/index.js", diff --git a/packages/taro-extend/package.json b/packages/taro-extend/package.json index bec879a962b1..bc85b96c3032 100644 --- a/packages/taro-extend/package.json +++ b/packages/taro-extend/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/extend", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "Taro extend functionality", "author": "yuche ", "homepage": "https://github.com/nervjs/taro/tree/master/packages/taro-extend#readme", diff --git a/packages/taro-h5/package.json b/packages/taro-h5/package.json index b8b945bc5d92..e265261a9ce5 100644 --- a/packages/taro-h5/package.json +++ b/packages/taro-h5/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/taro-h5", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "Taro h5 framework", "browser": "dist/index.esm.js", "main:h5": "dist/index.js", diff --git a/packages/taro-helper/package.json b/packages/taro-helper/package.json index 4eddc12d5b6b..2e0488cc5bc6 100644 --- a/packages/taro-helper/package.json +++ b/packages/taro-helper/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/helper", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "Taro Helper", "main": "index.js", "types": "dist/index.d.ts", diff --git a/packages/taro-helper/src/utils.ts b/packages/taro-helper/src/utils.ts index 3bac016cbb28..5c39a2e5a22f 100644 --- a/packages/taro-helper/src/utils.ts +++ b/packages/taro-helper/src/utils.ts @@ -283,7 +283,7 @@ export function cssImports (content: string): string[] { /*eslint-disable*/ const retries = (process.platform === 'win32') ? 100 : 1 -export function emptyDirectory (dirPath: string, opts: { excludes: string[] } = { excludes: [] }) { +export function emptyDirectory (dirPath: string, opts: { excludes: Array | string | RegExp } = { excludes: [] }) { if (fs.existsSync(dirPath)) { fs.readdirSync(dirPath).forEach(file => { const curPath = path.join(dirPath, file) @@ -292,7 +292,13 @@ export function emptyDirectory (dirPath: string, opts: { excludes: string[] } = let i = 0 // retry counter do { try { - if (!opts.excludes.length || !opts.excludes.some(item => curPath.indexOf(item) >= 0)) { + const excludes = Array.isArray(opts.excludes) ? opts.excludes : [opts.excludes] + const canRemove = + !excludes.length || + !excludes.some((item) => + typeof item === 'string' ? curPath.indexOf(item) >= 0 : item.test(curPath) + ) + if (canRemove) { emptyDirectory(curPath) fs.rmdirSync(curPath) } diff --git a/packages/taro-jd/package.json b/packages/taro-jd/package.json index cff1c3df18fa..18bd0bc1f028 100644 --- a/packages/taro-jd/package.json +++ b/packages/taro-jd/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/plugin-platform-jd", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "京东小程序平台插件", "author": "Chen-jj", "homepage": "https://github.com/nervjs/taro/tree/master/packages/taro-jd#readme", diff --git a/packages/taro-loader/package.json b/packages/taro-loader/package.json index a4cf7cc0b6b9..c16791dc7673 100644 --- a/packages/taro-loader/package.json +++ b/packages/taro-loader/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/taro-loader", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "Taro runner use webpack loader", "author": "yuche ", "homepage": "https://github.com/nervjs/taro/tree/master/packages/taro-loader#readme", diff --git a/packages/taro-mini-runner/package.json b/packages/taro-mini-runner/package.json index 198a6facbb51..f594040965a8 100644 --- a/packages/taro-mini-runner/package.json +++ b/packages/taro-mini-runner/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/mini-runner", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "Mini app runner for taro", "main": "index.js", "scripts": { diff --git a/packages/taro-mini-runner/src/webpack/chain.ts b/packages/taro-mini-runner/src/webpack/chain.ts index c654c65e158e..5e469eb2c3e0 100644 --- a/packages/taro-mini-runner/src/webpack/chain.ts +++ b/packages/taro-mini-runner/src/webpack/chain.ts @@ -60,6 +60,10 @@ interface IRule { } export const makeConfig = async (buildConfig: IBuildConfig) => { + // 过滤原因:webpack4 不支持 output.clean 选项, 且 packages/taro-service/src/platform-plugin-base/web.ts 中实现了 output.clean + if (buildConfig.output && 'clean' in buildConfig.output) { + delete buildConfig.output.clean + } const sassLoaderOption = await getSassLoaderOption(buildConfig) return { ...buildConfig, diff --git a/packages/taro-platform-h5/package.json b/packages/taro-platform-h5/package.json index f700487f576f..2faebd364164 100644 --- a/packages/taro-platform-h5/package.json +++ b/packages/taro-platform-h5/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/plugin-platform-h5", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "Web 端平台插件", "author": "ZakaryCode", "license": "MIT", diff --git a/packages/taro-plugin-html/package.json b/packages/taro-plugin-html/package.json index 57da2f9fa7d0..6416efbf3ea5 100644 --- a/packages/taro-plugin-html/package.json +++ b/packages/taro-plugin-html/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/plugin-html", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "Taro 小程序端支持使用 HTML 标签的插件", "main": "index.js", "scripts": { diff --git a/packages/taro-plugin-http/package.json b/packages/taro-plugin-http/package.json index 59899076b894..c8f837f860a9 100644 --- a/packages/taro-plugin-http/package.json +++ b/packages/taro-plugin-http/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/plugin-http", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "Taro 小程序端支持使用 web 请求 的插件", "main": "index.js", "scripts": { diff --git a/packages/taro-plugin-inject/package.json b/packages/taro-plugin-inject/package.json index 4a9a291382c6..3b49ef955588 100644 --- a/packages/taro-plugin-inject/package.json +++ b/packages/taro-plugin-inject/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/plugin-inject", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "Taro 小程序端平台中间层插件", "author": "luckyadam", "homepage": "https://github.com/nervjs/taro", diff --git a/packages/taro-plugin-mini-ci/package.json b/packages/taro-plugin-mini-ci/package.json index 21ac39cd7d5b..fb5c55e1c31d 100644 --- a/packages/taro-plugin-mini-ci/package.json +++ b/packages/taro-plugin-mini-ci/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/plugin-mini-ci", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "Taro 小程序端构建后支持CI(持续集成)的插件", "keywords": [ "Taro", diff --git a/packages/taro-plugin-react-devtools/package.json b/packages/taro-plugin-react-devtools/package.json index 220533f771c8..bbcc4d245732 100644 --- a/packages/taro-plugin-react-devtools/package.json +++ b/packages/taro-plugin-react-devtools/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/plugin-react-devtools", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "Taro 小程序端支持使用 React DevTools 的插件", "main": "index.js", "scripts": { diff --git a/packages/taro-plugin-react/package.json b/packages/taro-plugin-react/package.json index 46e00ce65db0..5b89bde9af7d 100644 --- a/packages/taro-plugin-react/package.json +++ b/packages/taro-plugin-react/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/plugin-framework-react", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "React/Preact/Nerv 框架插件", "author": "drchan", "homepage": "https://github.com/nervjs/taro", diff --git a/packages/taro-plugin-vue-devtools/package.json b/packages/taro-plugin-vue-devtools/package.json index 57d55ff1b78f..7d1f2b90b009 100644 --- a/packages/taro-plugin-vue-devtools/package.json +++ b/packages/taro-plugin-vue-devtools/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/plugin-vue-devtools", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "Taro 小程序端支持使用 Vue DevTools 的插件", "main": "index.js", "scripts": { diff --git a/packages/taro-plugin-vue2/package.json b/packages/taro-plugin-vue2/package.json index 99f805d07d5e..68a53c232be7 100644 --- a/packages/taro-plugin-vue2/package.json +++ b/packages/taro-plugin-vue2/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/plugin-framework-vue2", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "Vue2 框架插件", "author": "drchan", "homepage": "https://github.com/nervjs/taro", diff --git a/packages/taro-plugin-vue3/package.json b/packages/taro-plugin-vue3/package.json index 5ac614583516..a80d5be0343e 100644 --- a/packages/taro-plugin-vue3/package.json +++ b/packages/taro-plugin-vue3/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/plugin-framework-vue3", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "Vue3 框架插件", "author": "drchan", "homepage": "https://github.com/nervjs/taro", diff --git a/packages/taro-qq/package.json b/packages/taro-qq/package.json index b775da1a7b54..0f1cf36c1a4a 100644 --- a/packages/taro-qq/package.json +++ b/packages/taro-qq/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/plugin-platform-qq", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "QQ 小程序平台插件", "author": "Chen-jj", "homepage": "https://github.com/nervjs/taro/tree/master/packages/taro-qq#readme", diff --git a/packages/taro-react/package.json b/packages/taro-react/package.json index 6310fb63e7f2..41d750b3c672 100644 --- a/packages/taro-react/package.json +++ b/packages/taro-react/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/react", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "like react-dom, but for mini apps.", "author": "yuche ", "homepage": "https://github.com/nervjs/taro/tree/master/packages/taro-react#readme", diff --git a/packages/taro-rn-runner/package.json b/packages/taro-rn-runner/package.json index 35006fbafdaf..5aab35898820 100644 --- a/packages/taro-rn-runner/package.json +++ b/packages/taro-rn-runner/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/rn-runner", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "ReactNative build tool for taro", "main": "index.js", "repository": { diff --git a/packages/taro-rn-style-transformer/package.json b/packages/taro-rn-style-transformer/package.json index 2b5fc198fd54..6d1172db2017 100644 --- a/packages/taro-rn-style-transformer/package.json +++ b/packages/taro-rn-style-transformer/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/rn-style-transformer", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "提供Taro RN 统一处理样式文件能力", "main": "dist/index.js", "scripts": { diff --git a/packages/taro-rn-supporter/package.json b/packages/taro-rn-supporter/package.json index 0073cdd15654..d1301e2fe964 100644 --- a/packages/taro-rn-supporter/package.json +++ b/packages/taro-rn-supporter/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/rn-supporter", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "Taro rn supporter", "main": "dist/index.js", "scripts": { diff --git a/packages/taro-rn-transformer/package.json b/packages/taro-rn-transformer/package.json index cd6a4aa15dec..af73ad068359 100644 --- a/packages/taro-rn-transformer/package.json +++ b/packages/taro-rn-transformer/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/rn-transformer", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "Taro RN 入口文件处理", "main": "dist/index.js", "types": "./src/types/index.d.ts", diff --git a/packages/taro-rn/package.json b/packages/taro-rn/package.json index 724a580c829d..d7ba85439ba2 100644 --- a/packages/taro-rn/package.json +++ b/packages/taro-rn/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/taro-rn", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "Taro RN framework", "main": "dist/index.js", "typings": "types/index.d.ts", diff --git a/packages/taro-router-rn/package.json b/packages/taro-router-rn/package.json index f67fea58a7a9..d01776a11402 100644 --- a/packages/taro-router-rn/package.json +++ b/packages/taro-router-rn/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/router-rn", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "Taro-router-rn", "main": "dist/index.js", "typings": "src/index.ts", diff --git a/packages/taro-router/package.json b/packages/taro-router/package.json index 0c536cdb0308..d5de58a94594 100644 --- a/packages/taro-router/package.json +++ b/packages/taro-router/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/router", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "Taro-router", "browser": "dist/index.esm.js", "main:h5": "dist/index.js", diff --git a/packages/taro-runner-utils/package.json b/packages/taro-runner-utils/package.json index de728336fe34..f53cb1e673e8 100644 --- a/packages/taro-runner-utils/package.json +++ b/packages/taro-runner-utils/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/runner-utils", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "Taro runner utilities.", "main": "dist/index.js", "types": "types/index.d.ts", diff --git a/packages/taro-runtime-rn/package.json b/packages/taro-runtime-rn/package.json index e9dab0e0e922..8947777ad09e 100644 --- a/packages/taro-runtime-rn/package.json +++ b/packages/taro-runtime-rn/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/runtime-rn", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "taro-runtime-rn", "main": "dist/index.js", "types": "./src/index.ts", diff --git a/packages/taro-runtime-rn/src/page.ts b/packages/taro-runtime-rn/src/page.ts index d29f2bd18c7c..ad3551be0413 100644 --- a/packages/taro-runtime-rn/src/page.ts +++ b/packages/taro-runtime-rn/src/page.ts @@ -441,7 +441,8 @@ export function createPageConfig (Page: any, pageConfig: PageConfig): any { scrollEventThrottle: 8, ...refresh, onScroll: (e) => this.onPageScroll(e), - onMomentumScrollEnd: (e) => this.onReachBottom(e) + onMomentumScrollEnd: (e) => this.onReachBottom(e), + nestedScrollEnabled: true, }, this.createPage()) } diff --git a/packages/taro-runtime/package.json b/packages/taro-runtime/package.json index be735163567a..7f8ada4518e7 100644 --- a/packages/taro-runtime/package.json +++ b/packages/taro-runtime/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/runtime", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "taro runtime for mini apps.", "main": "dist/runtime.esm.js", "module": "dist/runtime.esm.js", diff --git a/packages/taro-service/package.json b/packages/taro-service/package.json index b65aa3660dd6..9ca0a1f6ebe9 100644 --- a/packages/taro-service/package.json +++ b/packages/taro-service/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/service", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "Taro Service", "main": "index.js", "types": "types/index.d.ts", diff --git a/packages/taro-service/src/platform-plugin-base/mini.ts b/packages/taro-service/src/platform-plugin-base/mini.ts index 69af104e920e..ef48e03e0852 100644 --- a/packages/taro-service/src/platform-plugin-base/mini.ts +++ b/packages/taro-service/src/platform-plugin-base/mini.ts @@ -1,5 +1,5 @@ import { recursiveMerge } from '@tarojs/helper' -import { PLATFORM_TYPE } from '@tarojs/shared' +import { isObject, PLATFORM_TYPE } from '@tarojs/shared' import { getPkgVersion } from '../utils/package' import TaroPlatform from './platform' @@ -35,9 +35,15 @@ export abstract class TaroPlatformBase extends Taro } private setupImpl () { - const { needClearOutput } = this.config - if (typeof needClearOutput === 'undefined' || !!needClearOutput) { + const { output } = this.config + // webpack5 原生支持 output.clean 选项,但是 webpack4 不支持, 为统一行为,这里做一下兼容 + // (在 packages/taro-mini-runner/src/webpack/chain.ts 和 packages/taro-webpack-runner/src/utils/chain.ts 的 makeConfig 中对 clean 选项做了过滤) + // 仅 output.clean 为 false 时不清空输出目录 + // eslint-disable-next-line eqeqeq + if (output == undefined || output.clean == undefined || output.clean === true) { this.emptyOutputDir() + } else if (isObject(output.clean)) { + this.emptyOutputDir(output.clean.keep || []) } this.printDevelopmentTip(this.platform) if (this.projectConfigJson) { @@ -136,10 +142,15 @@ ${exampleCommand}`)) private async buildImpl (extraOptions = {}) { const runner = await this.getRunner() - const options = this.getOptions(Object.assign({ - runtimePath: this.runtimePath, - taroComponentsPath: this.taroComponentsPath - }, extraOptions)) + const options = this.getOptions( + Object.assign( + { + runtimePath: this.runtimePath, + taroComponentsPath: this.taroComponentsPath + }, + extraOptions + ) + ) await runner(options) } @@ -160,7 +171,7 @@ ${exampleCommand}`)) * 递归替换对象的 key 值 */ protected recursiveReplaceObjectKeys (obj, keyMap) { - Object.keys(obj).forEach(key => { + Object.keys(obj).forEach((key) => { if (keyMap[key]) { obj[keyMap[key]] = obj[key] if (typeof obj[key] === 'object') { diff --git a/packages/taro-service/src/platform-plugin-base/platform.ts b/packages/taro-service/src/platform-plugin-base/platform.ts index 31a858129102..bdd940e5252a 100644 --- a/packages/taro-service/src/platform-plugin-base/platform.ts +++ b/packages/taro-service/src/platform-plugin-base/platform.ts @@ -53,9 +53,9 @@ export default abstract class TaroPlatform { this.compiler = typeof _compiler === 'object' ? _compiler.type : _compiler } - protected emptyOutputDir () { + protected emptyOutputDir (excludes: Array = []) { const { outputPath } = this.ctx.paths - this.helper.emptyDirectory(outputPath) + this.helper.emptyDirectory(outputPath, { excludes }) } /** diff --git a/packages/taro-service/src/platform-plugin-base/web.ts b/packages/taro-service/src/platform-plugin-base/web.ts index 2c87618e4111..65b3dec490b4 100644 --- a/packages/taro-service/src/platform-plugin-base/web.ts +++ b/packages/taro-service/src/platform-plugin-base/web.ts @@ -1,4 +1,4 @@ -import { PLATFORM_TYPE } from '@tarojs/shared' +import { isObject, PLATFORM_TYPE } from '@tarojs/shared' import { get, merge } from 'lodash' import * as path from 'path' @@ -20,9 +20,14 @@ export abstract class TaroPlatformWeb extends TaroP } private setupWebApp () { - const { needClearOutput } = this.config - if (typeof needClearOutput === 'undefined' || !!needClearOutput) { + const { output } = this.config + // webpack5 原生支持 output.clean 选项,但是 webpack4 不支持, 为统一行为,这里做一下兼容 + // (在 packages/taro-mini-runner/src/webpack/chain.ts 和 packages/taro-webpack-runner/src/utils/chain.ts 的 makeConfig 中对 clean 选项做了过滤) + // eslint-disable-next-line eqeqeq + if (output == undefined || output.clean == undefined || output.clean === true) { this.emptyOutputDir() + } else if (isObject(output.clean)) { + this.emptyOutputDir(output.clean.keep || []) } this.printDevelopmentTip() } diff --git a/packages/taro-swan/package.json b/packages/taro-swan/package.json index cc3950549a30..68d179ab874c 100644 --- a/packages/taro-swan/package.json +++ b/packages/taro-swan/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/plugin-platform-swan", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "百度小程序平台插件", "author": "Chen-jj", "homepage": "https://github.com/nervjs/taro/tree/master/packages/taro-swan#readme", diff --git a/packages/taro-tt/package.json b/packages/taro-tt/package.json index f282f3ec147d..33286a7a519a 100644 --- a/packages/taro-tt/package.json +++ b/packages/taro-tt/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/plugin-platform-tt", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "头条小程序平台插件", "author": "Chen-jj", "homepage": "https://github.com/nervjs/taro/tree/master/packages/taro-tt#readme", diff --git a/packages/taro-weapp/package.json b/packages/taro-weapp/package.json index 45b8e391b5c7..d77d2530c4d1 100644 --- a/packages/taro-weapp/package.json +++ b/packages/taro-weapp/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/plugin-platform-weapp", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "微信小程序平台插件", "author": "drchan", "homepage": "https://github.com/nervjs/taro/tree/master/packages/taro-weapp#readme", diff --git a/packages/taro-webpack-runner/package.json b/packages/taro-webpack-runner/package.json index 5e5e43225483..22b37dd4d498 100644 --- a/packages/taro-webpack-runner/package.json +++ b/packages/taro-webpack-runner/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/webpack-runner", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "webpack runner for taro", "main": "index.js", "scripts": { diff --git a/packages/taro-webpack-runner/src/utils/chain.ts b/packages/taro-webpack-runner/src/utils/chain.ts index de4019f3c09d..953def5e4e13 100644 --- a/packages/taro-webpack-runner/src/utils/chain.ts +++ b/packages/taro-webpack-runner/src/utils/chain.ts @@ -18,6 +18,10 @@ import type { ICopyOptions, IPostcssOption, PostcssOption } from '@tarojs/taro/t import type { BuildConfig, Option } from './types' export const makeConfig = async (buildConfig: BuildConfig) => { + // 过滤原因:webpack4 不支持 output.clean 选项, 且 packages/taro-service/src/platform-plugin-base/web.ts 中实现了 output.clean + if (buildConfig.output && 'clean' in buildConfig.output) { + delete buildConfig.output.clean + } const sassLoaderOption = await getSassLoaderOption(buildConfig) return { ...buildConfig, diff --git a/packages/taro-webpack5-prebundle/package.json b/packages/taro-webpack5-prebundle/package.json index 5884d5a51477..74b13c54cb82 100644 --- a/packages/taro-webpack5-prebundle/package.json +++ b/packages/taro-webpack5-prebundle/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/webpack5-prebundle", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "Taro app webpack5 prebundle", "main": "dist/index.js", "scripts": { diff --git a/packages/taro-webpack5-runner/package.json b/packages/taro-webpack5-runner/package.json index b75c2349a1e5..7c6dd6f2ead0 100644 --- a/packages/taro-webpack5-runner/package.json +++ b/packages/taro-webpack5-runner/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/webpack5-runner", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "Taro app runner", "main": "index.js", "scripts": { diff --git a/packages/taro-with-weapp/package.json b/packages/taro-with-weapp/package.json index 9663a8c609aa..e2cc917269c2 100644 --- a/packages/taro-with-weapp/package.json +++ b/packages/taro-with-weapp/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/with-weapp", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "taroize 之后的运行时", "main": "index.js", "files": [ diff --git a/packages/taro/package.json b/packages/taro/package.json index 407fefa0659e..47f2c63e273f 100644 --- a/packages/taro/package.json +++ b/packages/taro/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/taro", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "Taro framework", "homepage": "https://github.com/nervjs/taro/tree/master/packages/taro#readme", "main": "index.js", diff --git a/packages/taro/types/compile/config/mini.d.ts b/packages/taro/types/compile/config/mini.d.ts index 8fb24a4c0c2f..0d1890d2f072 100644 --- a/packages/taro/types/compile/config/mini.d.ts +++ b/packages/taro/types/compile/config/mini.d.ts @@ -35,7 +35,20 @@ export interface IMiniAppConfig { webpackChain?: (chain: Chain, webpack: typeof Webpack, PARSE_AST_TYPE: any) => void /** 可用于修改、拓展 Webpack 的 [output](https://webpack.js.org/configuration/output/) 选项 */ - output?: Webpack.Configuration['output'] + output?: Webpack.Configuration['output'] & { + /** + * 编译前清空输出目录 + * @since Taro v3.6.9 + * @description + * - 默认清空输出目录,可设置 clean: false 不清空 + * - 可设置 clean: { keep: ['project.config.json'] } 保留指定文件 + * - 注意 clean.keep 不支持函数 + */ + clean?: boolean | { + /** 保留指定文件不删除 */ + keep?: Array | string | RegExp + } + } /** 配置 postcss 相关插件 */ postcss?: IPostcssOption diff --git a/packages/taroize/package.json b/packages/taroize/package.json index 7ef63f8fcf37..2e1d9804f9ff 100644 --- a/packages/taroize/package.json +++ b/packages/taroize/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/taroize", - "version": "3.6.9-alpha.5", + "version": "3.6.9-alpha.7", "description": "转换原生微信小程序代码为 Taro 代码", "main": "index.js", "files": [