From e57bda45fe35a8da8c09ecf5f801f694237a3eaa Mon Sep 17 00:00:00 2001 From: shiftj18 Date: Fri, 9 Sep 2022 11:05:17 +0800 Subject: [PATCH 01/17] feat(script-loader): support platform-loader --- packages/jsx2mp-loader/src/script-loader.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/jsx2mp-loader/src/script-loader.js b/packages/jsx2mp-loader/src/script-loader.js index 3fde2066..13706694 100644 --- a/packages/jsx2mp-loader/src/script-loader.js +++ b/packages/jsx2mp-loader/src/script-loader.js @@ -53,10 +53,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( @@ -258,7 +259,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( From 65d7282e38d30a1348671ed358f9f5f525484ca5 Mon Sep 17 00:00:00 2001 From: shiftj18 Date: Tue, 13 Sep 2022 13:28:07 +0800 Subject: [PATCH 02/17] feat(script-loader): support platform-loader of npm --- packages/jsx2mp-loader/src/script-loader.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/jsx2mp-loader/src/script-loader.js b/packages/jsx2mp-loader/src/script-loader.js index 13706694..da59f61e 100644 --- a/packages/jsx2mp-loader/src/script-loader.js +++ b/packages/jsx2mp-loader/src/script-loader.js @@ -236,7 +236,8 @@ module.exports = function scriptLoader(content) { content ].join('\n'); } else { - outputFile(rawContent); + // outputFile(rawContent); + outputFile(content); } } else if (isFromConstantDir(this.resourcePath) && isThirdMiniappComponent) { const dependencies = []; From 35dcd6dbcf1eae2bb581c3e8f6f29c47f97705af Mon Sep 17 00:00:00 2001 From: shiftj18 Date: Tue, 25 Oct 2022 22:07:23 +0800 Subject: [PATCH 03/17] fix(jsx2mp-loader): script-loader exclude 'plugin://ocr/ocr-id' in usingComponents --- packages/jsx2mp-loader/src/script-loader.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/jsx2mp-loader/src/script-loader.js b/packages/jsx2mp-loader/src/script-loader.js index da59f61e..0aaab6e9 100644 --- a/packages/jsx2mp-loader/src/script-loader.js +++ b/packages/jsx2mp-loader/src/script-loader.js @@ -124,7 +124,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))); From dac632470dda87e9a7196fa3004eafcc3746179f Mon Sep 17 00:00:00 2001 From: zhongwu Date: Mon, 19 Sep 2022 11:05:35 +0800 Subject: [PATCH 04/17] feat(index): Add bytedance support --- packages/jsx-compiler/src/adapter.js | 12 ++++++++++++ packages/jsx-compiler/src/getCompiledComponents.js | 5 ++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/jsx-compiler/src/adapter.js b/packages/jsx-compiler/src/adapter.js index b0199c01..02b6af6f 100644 --- a/packages/jsx-compiler/src/adapter.js +++ b/packages/jsx-compiler/src/adapter.js @@ -103,6 +103,18 @@ const parserAdapters = { ...componentCommonProps.bytedance, className: '__rax-text' }, + icon: { + ...componentCommonProps.bytedance, + className: '' + }, + image: { + ...componentCommonProps.bytedance, + className: '' + }, + 'scroll-view': { + ...componentCommonProps.bytedance, + className: '' + }, 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' }; } }; From 4e384492873800f75922b53a509b8b514df38599 Mon Sep 17 00:00:00 2001 From: shiftj Date: Thu, 22 Sep 2022 17:23:48 +0800 Subject: [PATCH 05/17] feat(jsx-compiler): scroll-view event map of bytedance --- packages/jsx-compiler/src/adapter.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/jsx-compiler/src/adapter.js b/packages/jsx-compiler/src/adapter.js index 02b6af6f..6d7e6110 100644 --- a/packages/jsx-compiler/src/adapter.js +++ b/packages/jsx-compiler/src/adapter.js @@ -113,7 +113,13 @@ const parserAdapters = { }, 'scroll-view': { ...componentCommonProps.bytedance, - className: '' + className: '', + onEndReached: 'bindscrolltolower', + onScroll: 'bindscroll', + onTouchStart: 'binddragstart', + onTouchMove: 'binddragging', + onTouchEnd: 'binddragend', + // onTouchCancel: '' }, styleKeyword: true, slotScope: false, From 92fe395aa028f46b5ffe8e3385fa8a3831502473 Mon Sep 17 00:00:00 2001 From: "jiangmiao.yjj" Date: Wed, 30 Nov 2022 10:57:19 +0800 Subject: [PATCH 06/17] feat: support page-container --- packages/miniapp-render/CHANGELOG.md | 5 ++-- .../src/builtInComponents/index.js | 4 ++- .../src/builtInComponents/page-container.js | 3 ++ packages/miniapp-render/src/constants.js | 2 +- .../CHANGELOG.md | 3 +- .../src/platforms/wechat.js | 29 +++++++++++++++++-- 6 files changed, 39 insertions(+), 7 deletions(-) create mode 100644 packages/miniapp-render/src/builtInComponents/page-container.js diff --git a/packages/miniapp-render/CHANGELOG.md b/packages/miniapp-render/CHANGELOG.md index 710711a2..c9b46b63 100644 --- a/packages/miniapp-render/CHANGELOG.md +++ b/packages/miniapp-render/CHANGELOG.md @@ -2,9 +2,10 @@ ## [2.8.10] - 2023-08-23 -- Support onChooseAvatar event in buton in wechat +### Added -### Fixed +- Support onChooseAvatar event in buton in wechat +- Support `page-container` native component in wechat-miniprogram ## [2.8.9] - 2022-03-23 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..469323d4 100644 --- a/packages/rax-miniapp-runtime-webpack-plugin/CHANGELOG.md +++ b/packages/rax-miniapp-runtime-webpack-plugin/CHANGELOG.md @@ -2,9 +2,10 @@ ## [5.0.5] - 2023-08-23 -### Fixed +### Added - Support onChooseAvatar event in buton in wechat +- Support `page-container` native component in wechat-miniprogram ## [5.0.4] - 2022-08-30 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([ From 0cfafb2040a7cd607c293927953f5f690c5b5910 Mon Sep 17 00:00:00 2001 From: shiftj18 Date: Fri, 2 Dec 2022 01:06:35 +0800 Subject: [PATCH 07/17] feat(jsx-compiler): compat props-default-to-true in WeChat --- packages/jsx-compiler/src/adapter.js | 2 ++ packages/jsx-compiler/src/modules/attribute.js | 3 +++ 2 files changed, 5 insertions(+) diff --git a/packages/jsx-compiler/src/adapter.js b/packages/jsx-compiler/src/adapter.js index 6d7e6110..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', diff --git a/packages/jsx-compiler/src/modules/attribute.js b/packages/jsx-compiler/src/modules/attribute.js index b1a0460d..d93365e6 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) { + node.value = t.jsxExpressionContainer(t.booleanLiteral(true)); + } path.skip(); } } From dcf60a7fbdb5a67ebf80d77e54c7ac62b52d65fe Mon Sep 17 00:00:00 2001 From: shiftj18 Date: Mon, 5 Dec 2022 23:00:29 +0800 Subject: [PATCH 08/17] feat(miniapp-compile-config): jsx2mp-runtime alias support --- .../src/plugins/CopyJsx2mpRuntime.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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'); From 66c17a298d41b4ccc7bb9148bcd05aae7494b122 Mon Sep 17 00:00:00 2001 From: shiftj18 Date: Mon, 10 Apr 2023 22:30:03 +0800 Subject: [PATCH 09/17] feat(jsx2mp-loader): hackRegeneratorRuntimeFunction in ali miniapp of copyNpm --- .../babel-plugin-handle-regeneratorRuntime.js | 48 +++++++++++++++++++ packages/jsx2mp-loader/src/script-loader.js | 10 ++-- 2 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 packages/jsx2mp-loader/src/babel-plugin-handle-regeneratorRuntime.js 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..607d6950 --- /dev/null +++ b/packages/jsx2mp-loader/src/babel-plugin-handle-regeneratorRuntime.js @@ -0,0 +1,48 @@ +/** + * @Author 阿劭 tianjie.stj@alibaba-inc.com + * @Date 2023-04-10 18:21:49 + * @LastEditors 阿劭 tianjie.stj@alibaba-inc.com + * @LastEditTime 2023-04-10 21:33:21 + * @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 0aaab6e9..522aaab1 100644 --- a/packages/jsx2mp-loader/src/script-loader.js +++ b/packages/jsx2mp-loader/src/script-loader.js @@ -3,7 +3,7 @@ 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'); @@ -70,6 +70,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: { @@ -87,8 +90,9 @@ module.exports = function scriptLoader(content) { platform, aliasEntries } - ] - ], + ], + needHackRegeneratorRuntimeFunction ? require('./babel-plugin-handle-regeneratorRuntime') : null + ].filter(t => t), platform, isTypescriptFile: isTypescriptFile(this.resourcePath), rootDir, From 4113153b3239af9f8acd038a5cd08e40bf95b93e Mon Sep 17 00:00:00 2001 From: feisun Date: Thu, 3 Aug 2023 19:59:10 +0800 Subject: [PATCH 10/17] =?UTF-8?q?fix(jsx2mp-loader):=20=E6=97=A0=E6=B3=95r?= =?UTF-8?q?esolve=E7=9A=84main=E5=AD=97=E6=AE=B5=E4=B8=8D=E5=81=9A?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/jsx2mp-loader/src/script-loader.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/jsx2mp-loader/src/script-loader.js b/packages/jsx2mp-loader/src/script-loader.js index 522aaab1..41b8b61f 100644 --- a/packages/jsx2mp-loader/src/script-loader.js +++ b/packages/jsx2mp-loader/src/script-loader.js @@ -174,8 +174,13 @@ 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 || ''); - + 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 + } const isUsingMainMiniappComponent = pkg.hasOwnProperty(MINIAPP_CONFIG_FIELD) && this.resourcePath === npmMainPath; // Is miniapp compatible component. if (isUsingMainMiniappComponent || isRelativeMiniappComponent || isThirdMiniappComponent) { From 76f35a2fa258fb9d6349853ff32f152aefe6213e Mon Sep 17 00:00:00 2001 From: shiftj18 Date: Tue, 8 Aug 2023 12:04:56 +0800 Subject: [PATCH 11/17] =?UTF-8?q?feat:=20miniappConfig=E5=A4=84=E7=90=86?= =?UTF-8?q?=E5=85=BC=E5=AE=B9=E7=BB=84=E4=BB=B6=E5=85=A5=E5=8F=A3=E5=88=86?= =?UTF-8?q?=E7=AB=AF=E7=9A=84=E5=9C=BA=E6=99=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/jsx2mp-loader/src/script-loader.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/jsx2mp-loader/src/script-loader.js b/packages/jsx2mp-loader/src/script-loader.js index 41b8b61f..4607d846 100644 --- a/packages/jsx2mp-loader/src/script-loader.js +++ b/packages/jsx2mp-loader/src/script-loader.js @@ -181,7 +181,10 @@ module.exports = function scriptLoader(content) { } catch (e) { // can't resolve npmMainPath } - const isUsingMainMiniappComponent = pkg.hasOwnProperty(MINIAPP_CONFIG_FIELD) && this.resourcePath === 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}`; From a9dd7a754b93787e6d431e9411a054f8fa586f5d Mon Sep 17 00:00:00 2001 From: shiftj18 Date: Mon, 14 Oct 2024 16:06:11 +0800 Subject: [PATCH 12/17] feat(jsx2mp-loader): support remove unused import and require --- packages/jsx2mp-loader/CHANGELOG.md | 7 +++++++ packages/jsx2mp-loader/package.json | 4 ++-- packages/jsx2mp-loader/src/script-loader.js | 2 ++ packages/jsx2mp-loader/src/utils/dce.js | 20 +++++++++++++++++++- 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/packages/jsx2mp-loader/CHANGELOG.md b/packages/jsx2mp-loader/CHANGELOG.md index 1fdb6b3a..e158d48e 100644 --- a/packages/jsx2mp-loader/CHANGELOG.md +++ b/packages/jsx2mp-loader/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [0.4.37] UnRelease + +- 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 +- Fix: support platform-loader +- Fix: script-loader exclude 'plugin://xx/comp' in usingComponents ## [0.4.36] - 2022-06-22 diff --git a/packages/jsx2mp-loader/package.json b/packages/jsx2mp-loader/package.json index 35016672..efc13746 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-7", "description": "", "files": [ "src" @@ -17,7 +17,7 @@ "@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-transform-define": "^1.3.1", "chalk": "^2.4.2", diff --git a/packages/jsx2mp-loader/src/script-loader.js b/packages/jsx2mp-loader/src/script-loader.js index 4607d846..5a9233f5 100644 --- a/packages/jsx2mp-loader/src/script-loader.js +++ b/packages/jsx2mp-loader/src/script-loader.js @@ -10,6 +10,7 @@ const { isNpmModule, isJSONFile, isTypescriptFile } = require('./utils/judgeModu const isMiniappComponent = require('./utils/isMiniappComponent'); const parse = require('./utils/parseRequest'); const { output, transformCode } = require('./output'); +const eliminateDeadCode = require('./utils/dce'); const ScriptLoader = __filename; @@ -250,6 +251,7 @@ module.exports = function scriptLoader(content) { content ].join('\n'); } else { + content = eliminateDeadCode(content); // outputFile(rawContent); outputFile(content); } diff --git a/packages/jsx2mp-loader/src/utils/dce.js b/packages/jsx2mp-loader/src/utils/dce.js index 909f290c..ca1467f3 100644 --- a/packages/jsx2mp-loader/src/utils/dce.js +++ b/packages/jsx2mp-loader/src/utils/dce.js @@ -15,12 +15,29 @@ const parserOpts = { ], // support all plugins }; +function removeDeadCode(source) { + // 按需 + // if (!source?.includes('import ')) { + // return source; + // } + return transformSync(source, { + parserOpts, + plugins: [ + 'babel-plugin-minify-dead-code-elimination-while-loop-fixed' + ] + }).code; +} + function removeUnusedImport(source) { + // 按需 + // if (!source?.includes('import ')) { + // return source; + // } return transformSync(source, { parserOpts, plugins: [ [ - require('babel-plugin-danger-remove-unused-import'), + require('babel-plugin-danger-remove-unused-imports'), { ignore: 'rax' } @@ -38,6 +55,7 @@ const codeProcessor = (processors = [], sourceCode) => processors function eliminateDeadCode(source) { const processors = [ + removeDeadCode, removeUnusedImport, ]; From 0155bb77ed7152faf6a8a846cb27d3cf1acde225 Mon Sep 17 00:00:00 2001 From: shiftj18 Date: Thu, 24 Oct 2024 11:49:41 +0800 Subject: [PATCH 13/17] fix: jsx2mp-loader getHighestPriorityPackage() --- packages/jsx2mp-loader/CHANGELOG.md | 1 + packages/jsx2mp-loader/package.json | 2 +- .../jsx2mp-loader/src/utils/pathHelper.js | 26 ++++++++++++++----- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/packages/jsx2mp-loader/CHANGELOG.md b/packages/jsx2mp-loader/CHANGELOG.md index e158d48e..d13489cc 100644 --- a/packages/jsx2mp-loader/CHANGELOG.md +++ b/packages/jsx2mp-loader/CHANGELOG.md @@ -5,6 +5,7 @@ - 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 +- Fix: getHighestPriorityPackageJSON() 逻辑修正,增加项目直接依赖该包的校验,通过时才会去尝试查找项目依赖、优先启用 - Fix: support platform-loader - Fix: script-loader exclude 'plugin://xx/comp' in usingComponents diff --git a/packages/jsx2mp-loader/package.json b/packages/jsx2mp-loader/package.json index efc13746..0ae85a2a 100644 --- a/packages/jsx2mp-loader/package.json +++ b/packages/jsx2mp-loader/package.json @@ -1,6 +1,6 @@ { "name": "jsx2mp-loader", - "version": "0.4.37-7", + "version": "0.4.37-8", "description": "", "files": [ "src" 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 = { From 8b384c084ddbea183a84296c048c2503e9cf502c Mon Sep 17 00:00:00 2001 From: shiftj18 Date: Fri, 25 Oct 2024 15:09:43 +0800 Subject: [PATCH 14/17] fix: use babel-plugin-remove-unused-reference, for dce before removeUnusedImports --- packages/jsx-compiler/CHANGELOG.md | 7 +++++++ packages/jsx-compiler/package.json | 2 +- packages/jsx-compiler/src/modules/attribute.js | 2 +- packages/jsx2mp-loader/package.json | 6 ++++-- packages/jsx2mp-loader/src/utils/dce.js | 12 ++---------- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/packages/jsx-compiler/CHANGELOG.md b/packages/jsx-compiler/CHANGELOG.md index 4918af0d..54b5002d 100644 --- a/packages/jsx-compiler/CHANGELOG.md +++ b/packages/jsx-compiler/CHANGELOG.md @@ -1,4 +1,11 @@ # Changelog + +## 【0.4.38-x] Unreleased + +- Feat: compat props-default-to-true in WeChat +- Feat: add scroll-view event map of bytedance, like onScroll -> bindscroll +- 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. + ## [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..e5edee7f 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": [ diff --git a/packages/jsx-compiler/src/modules/attribute.js b/packages/jsx-compiler/src/modules/attribute.js index d93365e6..d80dcadd 100644 --- a/packages/jsx-compiler/src/modules/attribute.js +++ b/packages/jsx-compiler/src/modules/attribute.js @@ -74,7 +74,7 @@ function transformAttribute(ast, code, adapter) { } break; default: - if (node.value === null && adapter.needPropsDefaultToTrue) { + 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/package.json b/packages/jsx2mp-loader/package.json index 0ae85a2a..4ceb2555 100644 --- a/packages/jsx2mp-loader/package.json +++ b/packages/jsx2mp-loader/package.json @@ -19,13 +19,14 @@ "@babel/preset-env": "^7.5.5", "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-2", "less": "^4.0.0", "loader-utils": "^1.2.3", "miniapp-builder-shared": "^0.3.0", @@ -35,5 +36,6 @@ "stylesheet-loader": "^0.9.0", "stylus": "^0.54.7", "terser": "^4.3.8" - } + }, + "repository": "git@github.com:raxjs/miniapp.git" } diff --git a/packages/jsx2mp-loader/src/utils/dce.js b/packages/jsx2mp-loader/src/utils/dce.js index ca1467f3..4a928a26 100644 --- a/packages/jsx2mp-loader/src/utils/dce.js +++ b/packages/jsx2mp-loader/src/utils/dce.js @@ -16,28 +16,20 @@ const parserOpts = { }; function removeDeadCode(source) { - // 按需 - // if (!source?.includes('import ')) { - // return source; - // } return transformSync(source, { parserOpts, plugins: [ - 'babel-plugin-minify-dead-code-elimination-while-loop-fixed' + 'babel-plugin-remove-unused-reference' ] }).code; } function removeUnusedImport(source) { - // 按需 - // if (!source?.includes('import ')) { - // return source; - // } return transformSync(source, { parserOpts, plugins: [ [ - require('babel-plugin-danger-remove-unused-imports'), + 'babel-plugin-danger-remove-unused-imports', { ignore: 'rax' } From b0fd3046034ed08daf91e28c7547edaf6936a683 Mon Sep 17 00:00:00 2001 From: shiftj18 Date: Fri, 25 Oct 2024 15:16:45 +0800 Subject: [PATCH 15/17] chore: update version of fliggy beta --- packages/miniapp-compile-config/CHANGELOG.md | 4 ++++ packages/miniapp-compile-config/package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/miniapp-compile-config/CHANGELOG.md b/packages/miniapp-compile-config/CHANGELOG.md index 7933022c..acdbc5fc 100644 --- a/packages/miniapp-compile-config/CHANGELOG.md +++ b/packages/miniapp-compile-config/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## [0.3.4] Unreleased + +- 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..a37522d6 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", From faf54cfc7d92eb80854cf3cf7e0794f393f0a6a1 Mon Sep 17 00:00:00 2001 From: shiftj18 Date: Fri, 25 Oct 2024 16:12:35 +0800 Subject: [PATCH 16/17] chore: pub beta --- packages/jsx-compiler/CHANGELOG.md | 9 +++++++-- packages/jsx-compiler/package.json | 7 +++++++ packages/jsx2mp-loader/CHANGELOG.md | 13 +++++++++---- packages/jsx2mp-loader/package.json | 10 ++++++++-- .../src/babel-plugin-handle-regeneratorRuntime.js | 3 --- packages/miniapp-compile-config/CHANGELOG.md | 4 +++- packages/miniapp-compile-config/package.json | 3 +++ packages/miniapp-render/CHANGELOG.md | 10 ++++++++-- packages/miniapp-render/package.json | 8 ++++++-- packages/miniapp-render/rollup.config.js | 2 +- .../rax-miniapp-runtime-webpack-plugin/CHANGELOG.md | 9 +++++++-- .../rax-miniapp-runtime-webpack-plugin/package.json | 9 ++++++++- 12 files changed, 67 insertions(+), 20 deletions(-) diff --git a/packages/jsx-compiler/CHANGELOG.md b/packages/jsx-compiler/CHANGELOG.md index 54b5002d..0747a041 100644 --- a/packages/jsx-compiler/CHANGELOG.md +++ b/packages/jsx-compiler/CHANGELOG.md @@ -1,10 +1,15 @@ # Changelog -## 【0.4.38-x] Unreleased +## [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 -- 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. ## [0.4.37] diff --git a/packages/jsx-compiler/package.json b/packages/jsx-compiler/package.json index e5edee7f..df940ee7 100644 --- a/packages/jsx-compiler/package.json +++ b/packages/jsx-compiler/package.json @@ -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/jsx2mp-loader/CHANGELOG.md b/packages/jsx2mp-loader/CHANGELOG.md index d13489cc..bc7908a1 100644 --- a/packages/jsx2mp-loader/CHANGELOG.md +++ b/packages/jsx2mp-loader/CHANGELOG.md @@ -1,13 +1,18 @@ # Changelog -## [0.4.37] UnRelease +## [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 -- Fix: getHighestPriorityPackageJSON() 逻辑修正,增加项目直接依赖该包的校验,通过时才会去尝试查找项目依赖、优先启用 -- Fix: support platform-loader -- Fix: script-loader exclude 'plugin://xx/comp' in usingComponents ## [0.4.36] - 2022-06-22 diff --git a/packages/jsx2mp-loader/package.json b/packages/jsx2mp-loader/package.json index 4ceb2555..469e6f83 100644 --- a/packages/jsx2mp-loader/package.json +++ b/packages/jsx2mp-loader/package.json @@ -26,7 +26,7 @@ "csso": "^3.5.1", "enhanced-resolve": "^4.1.1", "fs-extra": "^8.1.0", - "jsx-compiler": "^0.4.38-2", + "jsx-compiler": "0.4.38-3", "less": "^4.0.0", "loader-utils": "^1.2.3", "miniapp-builder-shared": "^0.3.0", @@ -37,5 +37,11 @@ "stylus": "^0.54.7", "terser": "^4.3.8" }, - "repository": "git@github.com:raxjs/miniapp.git" + "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 index 607d6950..fee29703 100644 --- a/packages/jsx2mp-loader/src/babel-plugin-handle-regeneratorRuntime.js +++ b/packages/jsx2mp-loader/src/babel-plugin-handle-regeneratorRuntime.js @@ -1,8 +1,5 @@ /** * @Author 阿劭 tianjie.stj@alibaba-inc.com - * @Date 2023-04-10 18:21:49 - * @LastEditors 阿劭 tianjie.stj@alibaba-inc.com - * @LastEditTime 2023-04-10 21:33:21 * @Description 小程序严格模式下报错 `Function(...) is not function` 兼容 * https://aliyuque.antfin.com/tianjie.stj/nivfgf/wi0gk43l6otk3lam?singleDoc#tnMFv */ diff --git a/packages/miniapp-compile-config/CHANGELOG.md b/packages/miniapp-compile-config/CHANGELOG.md index acdbc5fc..2befca08 100644 --- a/packages/miniapp-compile-config/CHANGELOG.md +++ b/packages/miniapp-compile-config/CHANGELOG.md @@ -1,6 +1,8 @@ # Changelog -## [0.3.4] Unreleased +## [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 diff --git a/packages/miniapp-compile-config/package.json b/packages/miniapp-compile-config/package.json index a37522d6..323a86f9 100644 --- a/packages/miniapp-compile-config/package.json +++ b/packages/miniapp-compile-config/package.json @@ -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-render/CHANGELOG.md b/packages/miniapp-render/CHANGELOG.md index c9b46b63..3bcb657e 100644 --- a/packages/miniapp-render/CHANGELOG.md +++ b/packages/miniapp-render/CHANGELOG.md @@ -1,11 +1,17 @@ # Changelog -## [2.8.10] - 2023-08-23 +## [2.8.11] Beta ### Added +- [2.8.10-1] Support `page-container` native component in wechat-miniprogram + + +## [2.8.10] - 2023-08-23 + +### Fixed + - Support onChooseAvatar event in buton in wechat -- Support `page-container` native component in wechat-miniprogram ## [2.8.9] - 2022-03-23 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/rax-miniapp-runtime-webpack-plugin/CHANGELOG.md b/packages/rax-miniapp-runtime-webpack-plugin/CHANGELOG.md index 469323d4..15f9cdea 100644 --- a/packages/rax-miniapp-runtime-webpack-plugin/CHANGELOG.md +++ b/packages/rax-miniapp-runtime-webpack-plugin/CHANGELOG.md @@ -1,11 +1,16 @@ # Changelog -## [5.0.5] - 2023-08-23 +## [5.0.6] Beta ### Added +- [5.0.5-0] Support `page-container` native component in wechat-miniprogram + +## [5.0.5] - 2023-08-23 + +### Fixed + - Support onChooseAvatar event in buton in wechat -- Support `page-container` native component in wechat-miniprogram ## [5.0.4] - 2022-08-30 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" } } From 782abe0576d121ed3bf9f09b457efd505f004628 Mon Sep 17 00:00:00 2001 From: shiftj18 Date: Mon, 28 Oct 2024 15:05:03 +0800 Subject: [PATCH 17/17] fix: eliminateDeadCode require plugin --- packages/jsx2mp-loader/package.json | 2 +- packages/jsx2mp-loader/src/utils/dce.js | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/jsx2mp-loader/package.json b/packages/jsx2mp-loader/package.json index 469e6f83..d3d71a3c 100644 --- a/packages/jsx2mp-loader/package.json +++ b/packages/jsx2mp-loader/package.json @@ -1,6 +1,6 @@ { "name": "jsx2mp-loader", - "version": "0.4.37-8", + "version": "0.4.37-9", "description": "", "files": [ "src" diff --git a/packages/jsx2mp-loader/src/utils/dce.js b/packages/jsx2mp-loader/src/utils/dce.js index 4a928a26..e54b9d85 100644 --- a/packages/jsx2mp-loader/src/utils/dce.js +++ b/packages/jsx2mp-loader/src/utils/dce.js @@ -19,7 +19,10 @@ function removeDeadCode(source) { return transformSync(source, { parserOpts, plugins: [ - 'babel-plugin-remove-unused-reference' + // 只传入插件名称时,云构建运行异常,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; } @@ -29,7 +32,7 @@ function removeUnusedImport(source) { parserOpts, plugins: [ [ - 'babel-plugin-danger-remove-unused-imports', + require('babel-plugin-danger-remove-unused-imports'), { ignore: 'rax' }