diff --git a/packages/jsx-compiler/CHANGELOG.md b/packages/jsx-compiler/CHANGELOG.md index 4918af0d..0747a041 100644 --- a/packages/jsx-compiler/CHANGELOG.md +++ b/packages/jsx-compiler/CHANGELOG.md @@ -1,4 +1,16 @@ # Changelog + +## [0.4.38] Beta + +### Fixed + +- Fix: Solve the problem that the bytedance microapp can't pass through the className property by replace the native miniapp component tag in the compiler. image, icon, scroll-view. + +### Added + +- Feat: compat props-default-to-true in WeChat +- Feat: add scroll-view event map of bytedance, like onScroll -> bindscroll + ## [0.4.37] - Fix(bytedance-microapp): componentTag don't support the name start with '_'. Remove the `_` in bytedance. diff --git a/packages/jsx-compiler/package.json b/packages/jsx-compiler/package.json index 7b5d1cc5..df940ee7 100644 --- a/packages/jsx-compiler/package.json +++ b/packages/jsx-compiler/package.json @@ -1,6 +1,6 @@ { "name": "jsx-compiler", - "version": "0.4.37", + "version": "0.4.38-3", "license": "BSD-3-Clause", "description": "Parser for Rax JSX Statements.", "files": [ @@ -32,5 +32,12 @@ "devDependencies": { "handlebars": "^4.5.0", "jest": "^24.5.0" + }, + "repository": { + "type": "git", + "url": "git@github.com:raxjs/miniapp.git" + }, + "publishConfig": { + "registry": "https://registry.npmjs.org" } } diff --git a/packages/jsx-compiler/src/adapter.js b/packages/jsx-compiler/src/adapter.js index b0199c01..31f884f2 100644 --- a/packages/jsx-compiler/src/adapter.js +++ b/packages/jsx-compiler/src/adapter.js @@ -83,6 +83,8 @@ const parserAdapters = { // Handle rax-slider and rax-swiper insertSwiperSlot: true, needRegisterProps: true, + // https://reactjs.org/docs/jsx-in-depth.html#props-default-to-true compat for WeChatMiniProgram + needPropsDefaultToTrue: true, }, 'bytedance': { platform: 'bytedance', @@ -103,6 +105,24 @@ const parserAdapters = { ...componentCommonProps.bytedance, className: '__rax-text' }, + icon: { + ...componentCommonProps.bytedance, + className: '' + }, + image: { + ...componentCommonProps.bytedance, + className: '' + }, + 'scroll-view': { + ...componentCommonProps.bytedance, + className: '', + onEndReached: 'bindscrolltolower', + onScroll: 'bindscroll', + onTouchStart: 'binddragstart', + onTouchMove: 'binddragging', + onTouchEnd: 'binddragend', + // onTouchCancel: '' + }, styleKeyword: true, slotScope: false, // Need transform onClick -> bindonclick diff --git a/packages/jsx-compiler/src/getCompiledComponents.js b/packages/jsx-compiler/src/getCompiledComponents.js index c4a21585..154e39e0 100644 --- a/packages/jsx-compiler/src/getCompiledComponents.js +++ b/packages/jsx-compiler/src/getCompiledComponents.js @@ -12,7 +12,10 @@ module.exports = function(platform) { case 'bytedance': return { 'rax-view': 'view', - 'rax-text': 'text' + 'rax-text': 'text', + 'rax-image': 'image', + 'rax-icon': 'icon', + 'rax-scrollview': 'scroll-view' }; } }; diff --git a/packages/jsx-compiler/src/modules/attribute.js b/packages/jsx-compiler/src/modules/attribute.js index b1a0460d..d80dcadd 100644 --- a/packages/jsx-compiler/src/modules/attribute.js +++ b/packages/jsx-compiler/src/modules/attribute.js @@ -74,6 +74,9 @@ function transformAttribute(ast, code, adapter) { } break; default: + if (node.value === null && adapter.needPropsDefaultToTrue && !/:else|x-memo/.test(node.name.name)) { + node.value = t.jsxExpressionContainer(t.booleanLiteral(true)); + } path.skip(); } } diff --git a/packages/jsx2mp-loader/CHANGELOG.md b/packages/jsx2mp-loader/CHANGELOG.md index 1fdb6b3a..bc7908a1 100644 --- a/packages/jsx2mp-loader/CHANGELOG.md +++ b/packages/jsx2mp-loader/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +## [0.4.37] Beta + +### Fixed + +- Fix: getHighestPriorityPackage() 逻辑修正,增加项目直接依赖该包的校验,通过时才会去尝试查找项目依赖、优先启用 +- Fix: support platform-loader +- Fix: script-loader exclude 'plugin://xx/comp' in usingComponents + +### Added + +- Feat: support remove unused import and require of App、Page、Component、Npm package +- Feat: miniappConfig compat the case where the entry of component use multiple platform like index.wechat.js, index.ali.js. And don't change the filed main that can't be resolved +- Feat: hackRegeneratorRuntimeFunction in ali miniapp of copyNpm ## [0.4.36] - 2022-06-22 diff --git a/packages/jsx2mp-loader/package.json b/packages/jsx2mp-loader/package.json index 35016672..d3d71a3c 100644 --- a/packages/jsx2mp-loader/package.json +++ b/packages/jsx2mp-loader/package.json @@ -1,6 +1,6 @@ { "name": "jsx2mp-loader", - "version": "0.4.36", + "version": "0.4.37-9", "description": "", "files": [ "src" @@ -17,15 +17,16 @@ "@babel/plugin-proposal-export-default-from": "^7.5.2", "@babel/plugin-transform-typescript": "^7.7.4", "@babel/preset-env": "^7.5.5", - "babel-plugin-danger-remove-unused-import": "^2.0.0", + "babel-plugin-danger-remove-unused-imports": "^2.1.1", "babel-plugin-minify-dead-code-elimination-while-loop-fixed": "^0.3.0", + "babel-plugin-remove-unused-reference": "^1.0.0", "babel-plugin-transform-define": "^1.3.1", "chalk": "^2.4.2", "convert-source-map": "^1.6.0", "csso": "^3.5.1", "enhanced-resolve": "^4.1.1", "fs-extra": "^8.1.0", - "jsx-compiler": "^0.4.27", + "jsx-compiler": "0.4.38-3", "less": "^4.0.0", "loader-utils": "^1.2.3", "miniapp-builder-shared": "^0.3.0", @@ -35,5 +36,12 @@ "stylesheet-loader": "^0.9.0", "stylus": "^0.54.7", "terser": "^4.3.8" + }, + "repository": { + "type": "git", + "url": "git@github.com:raxjs/miniapp.git" + }, + "publishConfig": { + "registry": "https://registry.npmjs.org" } } diff --git a/packages/jsx2mp-loader/src/babel-plugin-handle-regeneratorRuntime.js b/packages/jsx2mp-loader/src/babel-plugin-handle-regeneratorRuntime.js new file mode 100644 index 00000000..fee29703 --- /dev/null +++ b/packages/jsx2mp-loader/src/babel-plugin-handle-regeneratorRuntime.js @@ -0,0 +1,45 @@ +/** + * @Author 阿劭 tianjie.stj@alibaba-inc.com + * @Description 小程序严格模式下报错 `Function(...) is not function` 兼容 + * https://aliyuque.antfin.com/tianjie.stj/nivfgf/wi0gk43l6otk3lam?singleDoc#tnMFv + */ + +module.exports = function visitor({ types: t }) { + + /** + * 判断节点是否是 Function("r", "regeneratorRuntime = r")(runtime); + * @param {*} node + */ + function isFunctionRegeneratorRuntime (node) { + return ( + t.isCallExpression(node.callee) && + node.callee.callee.name === 'Function' && + node.callee.arguments.length === 2 && + t.isStringLiteral(node.callee.arguments[0]) && + node.callee.arguments[0].value === 'r' && + t.isStringLiteral(node.callee.arguments[1]) && + node.callee.arguments[1].value === 'regeneratorRuntime = r' && + node.arguments.length === 1 && + t.isIdentifier(node.arguments[0]) && + node.arguments[0].name === 'runtime' + ); + } + + return { + visitor: { + CallExpression(path, state) { + const { node } = path; + if ( + t.isCallExpression(node.callee) && + node.callee.callee.name === 'Function' + ) { + if (isFunctionRegeneratorRuntime(node)) { + if (path.parentPath.node && t.isExpressionStatement(path.parentPath.node)) { + path.parentPath.remove(); + } + } + } + }, + } + }; +}; diff --git a/packages/jsx2mp-loader/src/script-loader.js b/packages/jsx2mp-loader/src/script-loader.js index 3fde2066..5a9233f5 100644 --- a/packages/jsx2mp-loader/src/script-loader.js +++ b/packages/jsx2mp-loader/src/script-loader.js @@ -3,13 +3,14 @@ const { join, dirname, relative, resolve, sep, extname } = require('path'); const { copySync, existsSync, mkdirpSync, ensureFileSync, writeJSONSync, readFileSync, readJSONSync } = require('fs-extra'); const { getOptions } = require('loader-utils'); const resolveModule = require('resolve'); -const { constants: { QUICKAPP }} = require('miniapp-builder-shared'); +const { constants: { QUICKAPP, MINIAPP }, platformMap } = require('miniapp-builder-shared'); const cached = require('./cached'); const { removeExt, doubleBackslash, normalizeOutputFilePath, addRelativePathPrefix, isFromTargetDirs } = require('./utils/pathHelper'); const { isNpmModule, isJSONFile, isTypescriptFile } = require('./utils/judgeModule'); const isMiniappComponent = require('./utils/isMiniappComponent'); const parse = require('./utils/parseRequest'); const { output, transformCode } = require('./output'); +const eliminateDeadCode = require('./utils/dce'); const ScriptLoader = __filename; @@ -53,10 +54,11 @@ module.exports = function scriptLoader(content) { const outputFile = (rawContent, isFromNpm = true) => { let distSourcePath; if (isFromNpm) { - const relativeNpmPath = relative(currentNodeModulePath, this.resourcePath); - const splitedNpmPath = relativeNpmPath.split(sep); - if (/^_?@/.test(relativeNpmPath)) splitedNpmPath.shift(); // Extra shift for scoped npm. - splitedNpmPath.shift(); // Skip npm module package, for cnpm/tnpm will rewrite this. + // 以下四行开销测下来用不到,故注释 + // const relativeNpmPath = relative(currentNodeModulePath, this.resourcePath); + // const splitedNpmPath = relativeNpmPath.split(sep); + // if (/^_?@/.test(relativeNpmPath)) splitedNpmPath.shift(); // Extra shift for scoped npm. + // splitedNpmPath.shift(); // Skip npm module package, for cnpm/tnpm will rewrite this. distSourcePath = normalizeNpmFileName(join(outputPath, 'npm', relative(rootNodeModulePath, this.resourcePath))); } else { const relativeFilePath = relative( @@ -69,6 +71,9 @@ module.exports = function scriptLoader(content) { let outputContent = {}; let outputOption = {}; + // 支付宝小程序 copyNpm 模式下对 @babel/runtime/regenerator/index.js 中的 `Function("r", "regeneratorRuntime=r")(runtime);` 进行处理 + const needHackRegeneratorRuntimeFunction = platform.type === platformMap[MINIAPP].type && !disableCopyNpm && this.resourcePath.indexOf('@babel/runtime/regenerator/index.js') > -1; + outputContent = { code: rawContent }; outputOption = { outputPath: { @@ -86,8 +91,9 @@ module.exports = function scriptLoader(content) { platform, aliasEntries } - ] - ], + ], + needHackRegeneratorRuntimeFunction ? require('./babel-plugin-handle-regeneratorRuntime') : null + ].filter(t => t), platform, isTypescriptFile: isTypescriptFile(this.resourcePath), rootDir, @@ -123,7 +129,9 @@ module.exports = function scriptLoader(content) { for (let key in componentConfig.usingComponents) { if (componentConfig.usingComponents.hasOwnProperty(key)) { const componentPath = componentConfig.usingComponents[key]; - if (isNpmModule(componentPath)) { + if (componentPath.indexOf('plugin://') === 0) { + // exclude plugin. eg usingComponents { "c-xxxx": "plugin://ocr/ocr-id" } + } else if (isNpmModule(componentPath)) { // component from node module const realComponentPath = resolveModule.sync(componentPath, { basedir: this.resourcePath, paths: [this.resourcePath], preserveSymlinks: false }); const relativeComponentPath = normalizeNpmFileName(addRelativePathPrefix(relative(dirname(sourceNativeMiniappScriptFile), realComponentPath))); @@ -167,9 +175,17 @@ module.exports = function scriptLoader(content) { const pkg = readJSONSync(sourcePackageJSONPath); const npmName = pkg.name; // Update to real npm name, for that tnpm will create like `_rax-view@1.0.2@rax-view` folders. - const npmMainPath = join(sourcePackagePath, pkg.main || ''); - - const isUsingMainMiniappComponent = pkg.hasOwnProperty(MINIAPP_CONFIG_FIELD) && this.resourcePath === npmMainPath; + let npmMainPath = join(sourcePackagePath, pkg.main || ''); + try { + // compat pkg.main without suffix like `lib/index` + npmMainPath = require.resolve(npmMainPath); + } catch (e) { + // can't resolve npmMainPath + } + // 兼容组件入口分端的场景 + // this.resourcePath 是 lib/index.wechat.js, npmMainPath 是 lib/index.js + const isSamePath = removeExt(this.resourcePath, platform.type) === removeExt(npmMainPath, platform.type); + const isUsingMainMiniappComponent = pkg.hasOwnProperty(MINIAPP_CONFIG_FIELD) && isSamePath; // Is miniapp compatible component. if (isUsingMainMiniappComponent || isRelativeMiniappComponent || isThirdMiniappComponent) { const mainName = platform.type === 'ali' ? 'main' : `main:${platform.type}`; @@ -235,7 +251,9 @@ module.exports = function scriptLoader(content) { content ].join('\n'); } else { - outputFile(rawContent); + content = eliminateDeadCode(content); + // outputFile(rawContent); + outputFile(content); } } else if (isFromConstantDir(this.resourcePath) && isThirdMiniappComponent) { const dependencies = []; @@ -258,7 +276,10 @@ module.exports = function scriptLoader(content) { content ].join('\n'); } else if (!isAppJSon) { - outputFile(rawContent, false); + // outputFile(rawContent, false); + // content 是过了 rax-platform-loader 的(会包含 env 变量转换为布尔常量化),而 rawContent 是没有这个转换的; + // 后续的 babel-plugin-minify-dead-code-elimination-while-loop-fixed 依赖布尔常量来 tree-shaking. + outputFile(content, false); } return isJSON ? '{}' : transformCode( diff --git a/packages/jsx2mp-loader/src/utils/dce.js b/packages/jsx2mp-loader/src/utils/dce.js index 909f290c..e54b9d85 100644 --- a/packages/jsx2mp-loader/src/utils/dce.js +++ b/packages/jsx2mp-loader/src/utils/dce.js @@ -15,12 +15,24 @@ const parserOpts = { ], // support all plugins }; +function removeDeadCode(source) { + return transformSync(source, { + parserOpts, + plugins: [ + // 只传入插件名称时,云构建运行异常,babel 加载插件出错。所以必须增加 require() + // Error: Cannot find module 'babel-plugin-remove-unused-reference' + // Make sure that all the Babel plugins and presets you are using are defined as dependencies or devDependencies in your package.json file. + require('babel-plugin-remove-unused-reference') + ] + }).code; +} + function removeUnusedImport(source) { return transformSync(source, { parserOpts, plugins: [ [ - require('babel-plugin-danger-remove-unused-import'), + require('babel-plugin-danger-remove-unused-imports'), { ignore: 'rax' } @@ -38,6 +50,7 @@ const codeProcessor = (processors = [], sourceCode) => processors function eliminateDeadCode(source) { const processors = [ + removeDeadCode, removeUnusedImport, ]; diff --git a/packages/jsx2mp-loader/src/utils/pathHelper.js b/packages/jsx2mp-loader/src/utils/pathHelper.js index e1ffb0df..bffc0494 100644 --- a/packages/jsx2mp-loader/src/utils/pathHelper.js +++ b/packages/jsx2mp-loader/src/utils/pathHelper.js @@ -98,12 +98,26 @@ function addRelativePathPrefix(filepath) { * @param {string} rootDir */ function getHighestPriorityPackage(packageName, rootDir) { - const resolvePaths = require.resolve.paths(packageName); - resolvePaths.unshift(join(rootDir, 'node_modules')); - const packagePath = require.resolve(packageName, { - paths: resolvePaths - }); - return require.resolve(packagePath); + // 无脑将 rootDir 的 node_modules 加入 resolve paths 的实现方式,存在因为项目间接依赖抬升 packageName 导致也会被命中,存在不稳定性 + // 修正为项目必须直接引入了对应包时,才会尝试查找项目依赖 & 优先启用 + try { + const pkgJSON = require(join(rootDir, 'package.json')); + const isDirectDeps = (pkgJSON.dependencies && pkgJSON.dependencies[packageName]) || (pkgJSON.devDependencies && pkgJSON.devDependencies[packageName]); + if (isDirectDeps) { + const rootDirResolved = require.resolve(packageName, { + paths: [join(rootDir, 'node_modules')] + }); + if (rootDirResolved) { + return rootDirResolved; + } + } + } catch(error) { + if (process.env.DEBUG === 'true') { + const chalk = require('chalk'); + console.log(chalk.magenta(`getHighestPriorityPackage(${packageName}, ${rootDir}) exception catched: ${error && error.message}`)); + } + } + return require.resolve(packageName); } module.exports = { diff --git a/packages/miniapp-compile-config/CHANGELOG.md b/packages/miniapp-compile-config/CHANGELOG.md index 7933022c..2befca08 100644 --- a/packages/miniapp-compile-config/CHANGELOG.md +++ b/packages/miniapp-compile-config/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## [0.3.4] Beta + +### Added + +- Feat: support USE_FLI_RAX and RAX_RUNTIME_ALIAS, for `clam` internally change rax to FMini, especially for the @ali/fli-jsx2mp-runtime + ## [0.3.3] - 2022-09-15 - Fix: native routes in `pages/` build error: `needCopyList[i].to error in setEntry()` diff --git a/packages/miniapp-compile-config/package.json b/packages/miniapp-compile-config/package.json index 9ce31e68..323a86f9 100644 --- a/packages/miniapp-compile-config/package.json +++ b/packages/miniapp-compile-config/package.json @@ -1,6 +1,6 @@ { "name": "miniapp-compile-config", - "version": "0.3.3", + "version": "0.3.4-1", "description": "miniapp compile project config", "author": "Rax Team", "homepage": "https://github.com/raxjs/miniapp#readme", @@ -36,5 +36,8 @@ "terser": "^4.8.0", "jsx2mp-runtime": "^0.4.18", "ts-loader": "^8.0.0" + }, + "publishConfig": { + "registry": "https://registry.npmjs.org" } } diff --git a/packages/miniapp-compile-config/src/plugins/CopyJsx2mpRuntime.js b/packages/miniapp-compile-config/src/plugins/CopyJsx2mpRuntime.js index a6df7181..1a536d5b 100644 --- a/packages/miniapp-compile-config/src/plugins/CopyJsx2mpRuntime.js +++ b/packages/miniapp-compile-config/src/plugins/CopyJsx2mpRuntime.js @@ -37,12 +37,17 @@ module.exports = class JSX2MPRuntimePlugin { compiler.hooks.emit.tapAsync( 'JSX2MPRuntimePlugin', (compilation, callback) => { + let runtimeName = runtime; if (!runtimePackageJSONPath) { - runtimePackageJSONPath = getHighestPriorityPackageJSON(runtime, this.rootDir); + const rootDirPackageJSON = readJSONSync(join(this.rootDir, 'package.json')); + if (rootDirPackageJSON.clam && rootDirPackageJSON.clam.raxJsLibAlias && rootDirPackageJSON.clam.raxJsLibAlias[runtime]) { + runtimeName = rootDirPackageJSON.clam.raxJsLibAlias[runtime]; + } + runtimePackageJSONPath = getHighestPriorityPackageJSON(runtimeName, this.rootDir); runtimePackageJSON = readJSONSync(runtimePackageJSONPath); runtimePackagePath = join(runtimePackageJSONPath, '..'); } - const runtimeTargetPath = `dist/jsx2mp-runtime.${this.platform}.esm.js`; + const runtimeTargetPath = `dist/${runtimeName}.${this.platform}.esm.js`; const sourceFile = require.resolve(join(runtimePackagePath, runtimeTargetPath)); const targetFile = join(this.outputPath, 'npm', runtime + '.js'); diff --git a/packages/miniapp-render/CHANGELOG.md b/packages/miniapp-render/CHANGELOG.md index 710711a2..3bcb657e 100644 --- a/packages/miniapp-render/CHANGELOG.md +++ b/packages/miniapp-render/CHANGELOG.md @@ -1,11 +1,18 @@ # Changelog -## [2.8.10] - 2023-08-23 +## [2.8.11] Beta + +### Added + +- [2.8.10-1] Support `page-container` native component in wechat-miniprogram -- Support onChooseAvatar event in buton in wechat + +## [2.8.10] - 2023-08-23 ### Fixed +- Support onChooseAvatar event in buton in wechat + ## [2.8.9] - 2022-03-23 ### Fixed diff --git a/packages/miniapp-render/package.json b/packages/miniapp-render/package.json index 2f60fdd6..2ce7e1db 100644 --- a/packages/miniapp-render/package.json +++ b/packages/miniapp-render/package.json @@ -1,6 +1,6 @@ { "name": "miniapp-render", - "version": "2.8.10", + "version": "2.8.11-0", "description": "DOM simulator for MiniApp", "files": [ "dist" @@ -29,13 +29,14 @@ "miniprogram": "dist/wechat", "repository": { "type": "git", - "url": "https://github.com/alibaba/rax.git" + "url": "git@github.com:raxjs/miniapp.git" }, "author": "Rax Team", "license": "MIT", "devDependencies": { "@babel/core": "^7.4.5", "@babel/plugin-proposal-class-properties": "^7.7.4", + "@babel/plugin-proposal-private-property-in-object": "^7.21.11", "@babel/plugin-transform-runtime": "^7.7.6", "@babel/preset-env": "^7.4.5", "@babel/runtime": "^7.7.7", @@ -54,5 +55,8 @@ "rollup-plugin-replace": "^2.2.0", "rollup-plugin-terser": "^5.3.0", "universal-env": "^3.2.0" + }, + "publishConfig": { + "registry": "https://registry.npmjs.org" } } diff --git a/packages/miniapp-render/rollup.config.js b/packages/miniapp-render/rollup.config.js index ba879bcd..84b37760 100644 --- a/packages/miniapp-render/rollup.config.js +++ b/packages/miniapp-render/rollup.config.js @@ -27,7 +27,7 @@ function getBabelConfig(platform) { ], plugins: [ '@babel/plugin-proposal-class-properties', - ['@babel/plugin-proposal-private-methods', { 'loose': false }], + ['@babel/plugin-transform-private-methods', { 'loose': false }], ['@babel/plugin-proposal-private-property-in-object', { 'loose': false }], ['./scripts/platform-plugin', { platform }] ] diff --git a/packages/miniapp-render/src/builtInComponents/index.js b/packages/miniapp-render/src/builtInComponents/index.js index 9f0e7749..03747d47 100644 --- a/packages/miniapp-render/src/builtInComponents/index.js +++ b/packages/miniapp-render/src/builtInComponents/index.js @@ -40,6 +40,7 @@ import contactButton from './contact-button'; // WeChat only import adCustom from './ad-custom'; +import pageContainer from './page-container'; // Alibaba MiniApp only import lifestyle from './lifestyle'; @@ -88,7 +89,8 @@ let components = [ swiperItem, pickerViewColumn, officialAccount, - contactButton + contactButton, + pageContainer ]; if (isWeChatMiniProgram) { diff --git a/packages/miniapp-render/src/builtInComponents/page-container.js b/packages/miniapp-render/src/builtInComponents/page-container.js new file mode 100644 index 00000000..25813438 --- /dev/null +++ b/packages/miniapp-render/src/builtInComponents/page-container.js @@ -0,0 +1,3 @@ +export default { + name: 'page-container' +}; \ No newline at end of file diff --git a/packages/miniapp-render/src/constants.js b/packages/miniapp-render/src/constants.js index 3b8e77c8..cba1548a 100644 --- a/packages/miniapp-render/src/constants.js +++ b/packages/miniapp-render/src/constants.js @@ -30,7 +30,7 @@ const BUILTIN_COMPONENT_LIST = new Set([ if (isMiniApp) { BUILTIN_COMPONENT_LIST.add('lifestyle').add('life-follow'); } else if (isWeChatMiniProgram) { - BUILTIN_COMPONENT_LIST.add('ad-custom'); + BUILTIN_COMPONENT_LIST.add('ad-custom').add('page-container'); } export { BUILTIN_COMPONENT_LIST }; diff --git a/packages/rax-miniapp-runtime-webpack-plugin/CHANGELOG.md b/packages/rax-miniapp-runtime-webpack-plugin/CHANGELOG.md index 20b5bc3c..15f9cdea 100644 --- a/packages/rax-miniapp-runtime-webpack-plugin/CHANGELOG.md +++ b/packages/rax-miniapp-runtime-webpack-plugin/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## [5.0.6] Beta + +### Added + +- [5.0.5-0] Support `page-container` native component in wechat-miniprogram + ## [5.0.5] - 2023-08-23 ### Fixed diff --git a/packages/rax-miniapp-runtime-webpack-plugin/package.json b/packages/rax-miniapp-runtime-webpack-plugin/package.json index 5763c8fa..ec3fd5b3 100644 --- a/packages/rax-miniapp-runtime-webpack-plugin/package.json +++ b/packages/rax-miniapp-runtime-webpack-plugin/package.json @@ -1,6 +1,6 @@ { "name": "rax-miniapp-runtime-webpack-plugin", - "version": "5.0.5", + "version": "5.0.6-0", "description": "A webpack plugin for miniapp runtime build", "main": "src/index.js", "files": [ @@ -30,5 +30,12 @@ }, "devDependencies": { "webpack": ">=4.0.0" + }, + "repository": { + "type": "git", + "url": "git@github.com:raxjs/miniapp.git" + }, + "publishConfig": { + "registry": "https://registry.npmjs.org" } } diff --git a/packages/rax-miniapp-runtime-webpack-plugin/src/platforms/wechat.js b/packages/rax-miniapp-runtime-webpack-plugin/src/platforms/wechat.js index 7b9c2a32..fc204b1a 100644 --- a/packages/rax-miniapp-runtime-webpack-plugin/src/platforms/wechat.js +++ b/packages/rax-miniapp-runtime-webpack-plugin/src/platforms/wechat.js @@ -884,6 +884,29 @@ const AdCustom = { } }; +const PageContainer = { + props: { + 'show': 'false', + 'duration': '300', + 'z-index': '100', + 'overlay': 'true', + 'position': addSingleQuote('bottom'), + 'round': 'false', + 'close-on-slide-down': 'false', + 'overlay-style': '', + 'custom-style': '', + }, + events: { + BeforeEnter: '', + Enter: '', + AfterEnter: '', + BeforeLeave: '', + Leave: '', + AfterLeave: '', + ClickOverlay: '', + } +}; + exports.internalComponents = { View, CatchView, @@ -936,7 +959,8 @@ exports.internalComponents = { CatchHElement, PureHElement, NoTouchHElement, - HComment + HComment, + PageContainer }; exports.derivedComponents = new Map([ @@ -1007,7 +1031,8 @@ exports.nestElements = new Map([ ['Form', 4], ['ScrollView', 4], ['Swiper', 4], - ['SwiperItem', 4] + ['SwiperItem', 4], + ['PageContainer', 4], ]); exports.shouldNotGenerateTemplateComponents = new Set([