Giter Site home page Giter Site logo

eleme / morjs Goto Github PK

View Code? Open in Web Editor NEW
1.6K 1.6K 102.0 9.12 MB

基于小程序 DSL(微信、支付宝)的,可扩展的多端研发框架,支持一键将微信或支付宝小程序转换为微信、支付宝、百度、字节、QQ、快手、淘宝、钉钉等小程序 或 Web 应用。

Home Page: https://mor.ele.me/

License: MIT License

JavaScript 4.57% Shell 0.11% TypeScript 89.10% Smarty 4.29% Less 0.85% SCSS 0.84% CSS 0.25%

morjs's People

Contributors

arcturus011 avatar bboyzaki avatar charlotteforever avatar hwaphon avatar icai avatar lyfeyaj avatar shujian-cao avatar wangjunjia avatar wangyang0210 avatar yujingali avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

morjs's Issues

要如何新建morJS工程的,官方文档的操作指令对不上

执行mor init只有以下选择

mor init
? 请选择工程类型 › - Use arrow-keys. Return to submit.
❯   小程序
    小程序插件
    小程序分包
    MorJS 工程插件
    MorJS 运行时插件
    MorJS 运行时解决方案
    MorJS 多端组件库
    MorJS 自定义脚手架

官方文档(https://mor.eleme.io/web/basic/quickstart)如下,没有MorJS 标准小程序工程可以选择,是文档没更新,还是框架对小程序转web的能力暂不支持的

npm i @morjs/cli -g # 全局安装 MorJS cli(如已安装可跳过)
mor init # 选择 MorJS 标准小程序工程,然后填写信息,在填写 投放渠道 这一项时将 Web 选中
npm run dev:web # 运行项目,控制台会打印地址和二维码

安装依赖并构建报错

环境:
morjs:master 分支
操作系统windows11
nvm
node: 16.14.0
pnpm: 7.33.6
报错如下:
构建失败!错误信息如下👇🏻
错误信息: Command failed with exit code 2: tsc
src/runtime/public/component.tsx(467,17): error TS2339: Property 'props' does not exist on type 'ReactNode'.
Property 'props' does not exist on type 'string'.
src/runtime/public/component.tsx(467,28): error TS2339: Property 'props' does not exist on type 'ReactNode'.
Property 'props' does not exist on type 'string'.
src/runtime/public/component.tsx(468,22): error TS2339: Property 'props' does not exist on type 'ReactNode'.
Property 'props' does not exist on type 'string'.
错误堆栈: Error: Command failed with exit code 2: tsc
src/runtime/public/component.tsx(467,17): error TS2339: Property 'props' does not exist on type 'ReactNode'.
Property 'props' does not exist on type 'string'.
src/runtime/public/component.tsx(467,28): error TS2339: Property 'props' does not exist on type 'ReactNode'.
Property 'props' does not exist on type 'string'.
src/runtime/public/component.tsx(468,22): error TS2339: Property 'props' does not exist on type 'ReactNode'.
Property 'props' does not exist on type 'string'.
at makeError (C:\code\mini\morjs\node_modules.pnpm\[email protected]\node_modules\execa\lib\error.js:60:11)
at handlePromise (C:\code\mini\morjs\node_modules.pnpm\[email protected]\node_modules\execa\index.js:118:26)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async build (C:\code\mini\morjs\scripts\build.js:72:5)
at async Promise.all (index 1)
at async buildAll (C:\code\mini\morjs\scripts\build.js:113:5)
 ELIFECYCLE  Command failed with exit code 1.

Can't resolve '@vant/weapp/popup/index'

vant 路径解析错误

src/pages/index/index.json

{
  "usingComponents": {
    "van-popup": "@vant/weapp/popup/index",
    "wxml-to-canvas": "wxml-to-canvas",
    "van-field": "@vant/weapp/field/index",
    "select": "../../components/select/index"
  }
}

mor.config.ts

import { defineConfig } from '@morjs/cli';
import path from 'path';

export default defineConfig(
  [
    {
      name: 'wechat',
      sourceType: 'wechat',
      target: 'web',
    },
    // {
    //   name: 'wechat',
    //   sourceType: 'wechat',
    //   target: 'wechat',
    // },
  ].map(cfg => {
    return {
      ...cfg,
      alias: {
        '@vant/weapp/': path.join(
          __dirname,
          './src/miniprogram_npm/@vant/weapp/',
        ),
      },
    };
  }),
);

执行命令
mor compile -w

error :

Can't resolve '@vant/weapp/popup/index' in '/Users/u/Desktop/project/src/pages/index'

[mor] ✖ ⁃ finishWithoutResolve
node_modules/.pnpm/[email protected]/node_modules/enhanced-resolve/lib/Resolver.js:309

echart都无法集成进去,ctx = __MOR_API__.createCanvasContext(this.data.canvasId, this)ctx为undefined

Describe the bug
ctx = MOR_API.createCanvasContext(this.data.canvasId, this)ctx为undefined

To Reproduce
代码地址:https://github.com/brainee/weixin-pages-morjs/tree/main
直接运行npm run dev

Expected behavior
echart能运行

Screenshots
image

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context

After initializing the project, running dev throws an error.

When I initialize the project according to the examples on the official website, I get an error when running dev.

Steps to reproduce the behavior:

  1. pnpm create mor
  2. pnpm run dev

image

  • node version v16.16.0
  • pnpm version v8.3.1
[mor] ✖ Cannot read properties of undefined (reading 'entryName')
[mor] ✖ ⁃ anonymous
             node_modules\.pnpm\@[email protected]_@[email protected][email protected][email protected]\node_modules\@morjs\plugin-compiler-web\lib\plugins\generateJSXEntryPlugin.js:292
           ⁃ GenerateJSXEntryPlugin.generateEntryFiles
             node_modules\.pnpm\@[email protected]_@[email protected][email protected][email protected]\node_modules\@morjs\plugin-compiler-web\lib\plugins\generateJSXEntryPlugin.js:290
           ⁃ anonymous
             node_modules\.pnpm\@[email protected]_@[email protected][email protected][email protected]\node_modules\@morjs\plugin-compiler-web\lib\plugins\generateJSXEntryPlugin.js:142

不支持 model:value

Describe the bug
Namespace tags are not supported by default. React's JSX doesn't support namespace tags. You can set throwIfNamespace: false to bypass this warning.

<tiga-input class={"new-todo"} model:value={$rm.toJsonString(todoTitle, false)} placeholder={"What needs to be done?"} autofocus />

To Reproduce
如上描述

Expected behavior
可支持,因为微信官方支持:https://developers.weixin.qq.com/miniprogram/dev/framework/view/two-way-bindings.html

Screenshots
image

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context

Cannot read properties of undefined (reading 'ALIPAY')

1、processNodeModules设为true

import { defineConfig } from '@morjs/cli'

export default defineConfig([
  {
    name: 'web',
    sourceType: 'wechat',
    target: 'web',
    compileType: 'miniprogram',
    processNodeModules: true,
    compileMode: 'bundle',
    cache: false
  }
])

2、执行npm run dev:web,编译没问题,打开页面报:
Cannot read properties of undefined (reading 'ALIPAY')
image
3、关闭processNodeModules则恢复正常

Click event not responding after converting a miniprogram from Wechat type to Alipay type.

Describe the bug
Click event not responding after converting a miniprogram from Wechat type to Alipay type.

To Reproduce
Steps to reproduce the behavior:
1、Download the demo and install dependencies.
2、Run script npm run dev to convert the miniprogram to an alipay type.
3、Open converted project folder with Alipay IDE.
4、Click the button "返回" at the upper left corner.

Expected behavior
It show toast "点击返回"

Screenshots
None

Alipay IDE

  • OS: Mac OS
  • Version 3.6.3

[build] 执行`pnpm builds`时遇到了一些问题

BUG描述
拉取项目后,按着 贡献指南的操作 时,遇到了一些问题;

环境信息

node_version => v18.16.0
pnpm => 8.2.0
OS => windows 11

问题

在执行pnpm build遇到了下面两个问题

  1. packages/corepackages/runtime-minitslib版本过低导致打包失败
// 报错信息
error TS2343: This syntax requires an imported helper named '__spreadArray' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'.

// 解决方式
将tslib升级到了最新的2.5.0版本解决了该问题      
  1. packages/runtime-web报错props不存在ReactNode的类型上

不太熟悉react,所以选择最直接的方法,直接注释了相应的代码😂

// 报错信息
src/runtime/public/component.tsx(462,18): error TS2339: Property 'props' does not exist on type 'ReactNode'.
Property 'props' does not exist on type 'string'.

es6转换问题

Describe the bug
源项目是 微信,再编译后转 es5 Set的解构有问题
以及 array的entries() 迭代器转换问题

To Reproduce
Steps to reproduce the behavior:
let a = [1,2,3]
a = [...new Set(a)]
console.log(a, 'a')
// [] a为空数组

for (const [index, ele] of a.entries()) {
console.log(index, ele)
// 不触发 console
}

Expected behavior
预期期望出现 [1,2,3]

迭代器出现
0,1
1,2
2,3
myapp.zip

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

wComponent 转支付宝后 observer 执行问题

问题描述
wComponent 转支付宝后,组件接受 a, b 两个 properties 而且都有 observer,转到支付宝之后,父组件改变 a 的值的情况下,b 的 observer 也会执行。预期:应该只执行 a 的 observer

环境信息

@morjs/cli => 1.0.27
@morjs/core => 1.0.11
node_version => v16.15.1
yarn => 1.22.19
OS => MAC OS 12.4

微信DSL编译产出支付宝小程序配置不生效问题

Describe the bug
源项目是微信小程序,编译产出支付宝小程序,想禁用页面参数自动解码能力,在支付宝小程序app.son如下配置不生效

// app.json
{
  "behavior": {
    // 当设置为disable时,基础库解析全局参数、页面参数时不再对键/值做 decodeURIComponent
    "decodeQuery": "disable"
  }
}

跳转前对参数进行encodeURIComponent
image
在跳转目标页面接收参数没有做任何处理,参数还是被自动解码了
image
image

我通过支付宝小程序IDE直接创建支付宝小程序,添加配置,同样的代码,此时配置是生效的
image

[mor] ✖ 绑定表达式: { class } 不符合 JS 表达式规范

Describe the bug
页面转换后,报
[mor] ✖ 绑定表达式: { class } 不符合 JS 表达式规范
无具体日志和说明

To Reproduce
https://github.com/brainee/weixin-pages-morjs/tree/main

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

支付宝组件指定默认抽象节点配置并且同时在多个分包引入时出现报错及生命周期无法执行

Describe the bug
支付宝组件指定默认抽象节点配置并且同时在多个原生分包引入时出现报错及生命周期无法执行。报错内容 “Component() 构造器被调用多次”。

To Reproduce
Steps to reproduce the behavior:

  1. yarn create mor - 小程序分包 - 微信 DSL
  2. 创建任意一个自定义组件 user-name,以及默认抽象节点组件 default-greneric,同时 user-name 需要通过 componentGenerics 配置引入 default-greneric
  3. 通过 customEntries.components 指定 user-name 的路径,可以使其编译到产物中(这时可以移除 pages/ 和 app.ts)。也可以在 pages/index/index 引入 user-name
  4. 使用支付宝小程序开发者工具创建空白模版,并创建两个分包及对应的页面 packageA/user/index、packageC/user/index,页面需要分别引入 user-name (需要通过复制,实际中是每个分包都会安装一份 npm 包)
  5. 依次跳转到 packageA packageB 对应的页面,先跳转的分包对应的 user-name 组件一切正常,而且没有控制台报错,后跳转的分包都会在支付宝开发者工具中出现 “Component() 构造器被调用多次” 的报错,同时对应的 user-name 组件的 lifetime.attached 没有执行,截图中 "username component attached" 为 log

Expected behavior
无报错及 user-name 组件的生命周期可以正常执行

Screenshots
指定抽象节点配置.png

Desktop (please complete the following information):

  • 小程序开发者工具: 3.6.4
  • 基础库 2.8.8

Smartphone (please complete the following information):

  • Device: iPhone 11
  • OS: iOS 16.4

Additional context

  • mor.config
[
  {
    name: 'wechat-subpackage',
    sourceType: 'wechat',
    target: 'wechat',
    compileType: 'subpackage',
    compileMode: 'bundle',
    autoClean:true,
    jsMinimizer: 'esbuild',
  },
  {
    name: 'alipay-subpackage',
    sourceType: 'wechat',
    target: 'alipay',
    compileType: 'subpackage',
    compileMode: 'bundle',
    autoClean:true,
    jsMinimizer: 'esbuild',
  },
]

Mac 13.4 `pnpm dev` failed.

image

node: v18.16.0
npm: 9.8.1
1.mkdir myapp && cd myapp # 创建项目目录
2. pnpm create mor
3. next....
4. pnpm dev

示例没运行起来, 直接劝退

Describe the bug
A clear and concise description of what the bug is.

$ pnpm run dev

[email protected] dev /Users/xxx/mini-program/mor-app
mor compile --watch

[mor] ℹ 发现配置文件: mor.config.ts
[mor] ✔ 配置文件加载成功: mor.config.ts
[mor] ℹ 准备配置中, 即将开始编译 👇
配置名称: wechat-miniprogram
编译目标: 微信小程序
编译环境: development
编译类型: 小程序
编译模式: bundle
源码类型: wechat
源码目录: src
输出目录: dist/wechat
[mor] ℹ 已开启缓存, 可通过 --no-cache 关闭
[mor] ℹ 启动文件监听模式
[mor] ℹ 开始编译 ...
[mor] ℹ 依赖分析中 ...
[mor] ℹ 依赖分析完成: 耗时: 87.816729 ms
[mor] ✔ 编译完成, 耗时: 624.34235 ms

[mor] ℹ 准备配置中, 即将开始编译 👇
配置名称: alipay-miniprogram
编译目标: 支付宝小程序
编译环境: development
编译类型: 小程序
编译模式: bundle
源码类型: wechat
源码目录: src
输出目录: dist/alipay
[mor] ℹ 已开启缓存, 可通过 --no-cache 关闭
[mor] ℹ 启动文件监听模式
[mor] ℹ 开始编译 ...
[mor] ℹ 依赖分析中 ...
[mor] ℹ 依赖分析完成: 耗时: 100.650343 ms
[mor] ✔ 编译完成, 耗时: 289.723189 ms

[mor] ℹ 准备配置中, 即将开始编译 👇
配置名称: web
编译目标: Web 应用
编译环境: development
编译类型: 小程序
编译模式: bundle
源码类型: wechat
源码目录: src
输出目录: dist/web
[mor] ℹ 已开启缓存, 可通过 --no-cache 关闭
[mor] ℹ 启动文件监听模式
[mor] ℹ 开始编译 ...
[mor] ℹ 依赖分析中 ...
[mor] ℹ 依赖分析完成: 耗时: 95.986822 ms
[mor] ⠴ 正在编译, 进度: 92.44%
[mor] ℹ 浏览器中打开链接: http://192.168.0.32:8080
或通过手机扫描下方二维码预览 👇

    ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
    ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
    ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
    ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
    ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
    ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
    ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
    ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
    ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
    ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
    ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
    ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
    ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
    ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄

[mor] ✔ 编译完成, 耗时: 1409.475179 ms

[mor] ✖ 编译 ./mor-entries/pages/index/index.jsx 失败:
=> Module not found: Error: Can't resolve '@babel/runtime/helpers/classCallCheck' in '/Users/xxx/mini-program/mor-app/mor-app/src/mor-entries/pages/index'
[mor] ✖ 编译 ./mor-entries/pages/index/index.jsx 失败:
=> Module not found: Error: Can't resolve '@babel/runtime/helpers/createClass' in '/Users/xxx/mini-program/mor-app/mor-app/src/mor-entries/pages/index'
[mor] ✖ 编译 ./mor-entries/pages/index/index.jsx 失败:
=> Module not found: Error: Can't resolve '@babel/runtime/helpers/possibleConstructorReturn' in '/Users/xxx/mini-program/mor-app/mor-app/src/mor-entries/pages/index'
[mor] ✖ 编译 ./mor-entries/pages/index/index.jsx 失败:
=> Module not found: Error: Can't resolve '@babel/runtime/helpers/isNativeReflectConstruct' in '/Users/xxx/mini-program/mor-app/mor-app/src/mor-entries/pages/index'
[mor] ✖ 编译 ./mor-entries/pages/index/index.jsx 失败:
=> Module not found: Error: Can't resolve '@babel/runtime/helpers/getPrototypeOf' in '/Users/xxx/mini-program/mor-app/mor-app/src/mor-entries/pages/index'
[mor] ✖ 编译 ./mor-entries/pages/index/index.jsx 失败:
=> Module not found: Error: Can't resolve '@babel/runtime/helpers/inherits' in '/Users/xxx/mini-program/mor-app/mor-app/src/mor-entries/pages/index'
[mor] ✖ 编译 ./mor-entries/pages/logs/logs.jsx 失败:
=> Module not found: Error: Can't resolve '@babel/runtime/helpers/classCallCheck' in '/Users/xxx/mini-program/mor-app/mor-app/src/mor-entries/pages/logs'
[mor] ✖ 编译 ./mor-entries/pages/logs/logs.jsx 失败:
=> Module not found: Error: Can't resolve '@babel/runtime/helpers/createClass' in '/Users/xxx/mini-program/mor-app/mor-app/src/mor-entries/pages/logs'
[mor] ✖ 编译 ./mor-entries/pages/logs/logs.jsx 失败:
=> Module not found: Error: Can't resolve '@babel/runtime/helpers/possibleConstructorReturn' in '/Users/xxx/mini-program/mor-app/mor-app/src/mor-entries/pages/logs'
[mor] ✖ 编译 ./mor-entries/pages/logs/logs.jsx 失败:
=> Module not found: Error: Can't resolve '@babel/runtime/helpers/isNativeReflectConstruct' in '/Users/xxx/mini-program/mor-app/mor-app/src/mor-entries/pages/logs'
[mor] ✖ 编译 ./mor-entries/pages/logs/logs.jsx 失败:
=> Module not found: Error: Can't resolve '@babel/runtime/helpers/getPrototypeOf' in '/Users/xxx/mini-program/mor-app/mor-app/src/mor-entries/pages/logs'
[mor] ✖ 编译 ./mor-entries/pages/logs/logs.jsx 失败:
=> Module not found: Error: Can't resolve '@babel/runtime/helpers/inherits' in '/Users/xxx/mini-program/mor-app/mor-app/src/mor-entries/pages/logs'

To Reproduce
Steps to reproduce the behavior:

  1. mkdir mor-app
  2. cd mor-app && pnpm create mor
  3. pnpm run dev

[bug] 微信小程序转qq小程序时调用原生request接口的问题

原本的代码中调用的是wx.request方法,但是编译为qq小程序时发现没有请求发出去,调试后发现这段中的函数没有调用
我当前的解决方案是把这段代码

if (actualApiName === 'request') return getOriginalRequest(global)

改为了

if (actualApiName === 'request') return getOriginalRequest(global) (obj)

我不知道这算不算具体的问题所在,不过还是麻烦你们看下

在window系统,构建mock错误

Describe the bug
MOCK_RUNTIME_FILE路径错误,导致无法构建。应该是**/**
D:\work\zuJianKu\mor-components>pnpm run dev

[email protected] dev D:\work\zuJianKu\mor-components
mor compile --watch --mock

D:\work\zuJianKu\mor-components\node_modules.pnpm@[email protected]\node_modules@morjs\plugin-mocker\lib\runtimes\mock.js >>>>>>>>>>>>>>>>>XXXX
[mor] i 发现配置文件: mor.config.ts
[mor] √ 配置文件加载成功: mor.config.ts
[mor] ‼ 已开启 mock 功能
[mor] i 准备配置中, 即将开始编译 👇
配置名称: ali
编译目标: 支付宝小程序
编译环境: development
编译类型: 小程序
编译模式: bundle
源码类型: wechat
源码目录: src
输出目录: dist\alipay
[mor] i 已开启缓存, 可通过 --no-cache 关闭
[mor] i 启动文件监听模式
[mor] i 开始编译 ...
[mor] i 依赖分析中 ...
[mor] i 依赖分析完成: 耗时: 190.8397 ms
[mor] √ 编译完成, 耗时: 2839.0836 ms

[mor] × 编译 D:workzuJianKumor-components
ode_modules.pnpm@[email protected]
untimesmock.js 失败:morjsplugin-mockerlib
=> Module build failed: UnhandledSchemeError: Reading from "D:workzuJianKumor-components
ode_modules.pnpm@[email protected]
untimesmock.js" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "d:" URIs.
at D:\work\zuJianKu\mor-components\node_modules.pnpm\[email protected]_ob4k3dxoir7qyq3qpk7cszlhlq\node_modules\webpack\lib\NormalModule.js:834:25
at Hook.eval [as callAsync] (eval at create (D:\work\zuJianKu\mor-components\node_modules.pnpm\[email protected]\node_modules\tapable\lib\HookCodeFactory.js:33:10), :6:1)
at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (D:\work\zuJianKu\mor-components\node_modules.pnpm\[email protected]\node_modules\tapable\lib\Hook.js:18:14)
at Object.processResource (D:\work\zuJianKu\mor-components\node_modules.pnpm\[email protected]_ob4k3dxoir7qyq3qpk7cszlhlq\node_modules\webpack\lib\NormalModule.js:831:8)
at processResource (D:\work\zuJianKu\mor-components\node_modules.pnpm\[email protected]\node_modules\loader-runner\lib\LoaderRunner.js:220:11)
at iteratePitchingLoaders (D:\work\zuJianKu\mor-components\node_modules.pnpm\[email protected]\node_modules\loader-runner\lib\LoaderRunner.js:171:10)
at runLoaders (D:\work\zuJianKu\mor-components\node_modules.pnpm\[email protected]\node_modules\loader-runner\lib\LoaderRunner.js:398:2)
at NormalModule._doBuild (D:\work\zuJianKu\mor-components\node_modules.pnpm\[email protected]_ob4k3dxoir7qyq3qpk7cszlhlq\node_modules\webpack\lib\NormalModule.js:821:3)
at NormalModule.build (D:\work\zuJianKu\mor-components\node_modules.pnpm\[email protected]_ob4k3dxoir7qyq3qpk7cszlhlq\node_modules\webpack\lib\NormalModule.js:965:15)
at D:\work\zuJianKu\mor-components\node_modules.pnpm\[email protected]_ob4k3dxoir7qyq3qpk7cszlhlq\node_modules\webpack\lib\Compilation.js:1371:12

To Reproduce
1.pnpm run dev
ps:"dev": "mor compile --watch --mock",

Expected behavior
能在window系统构建mock

solution
将MOCK_RUNTIME_FILE进行转斜杆.用.replace(/\/g, '/')
const initMockFileContent = [
import Mock from '${MOCK_RUNTIME_FILE}.replace(/\\/g, '/')';,
adapterImports.join(';\n'),
var mockContext = require.context(${JSON.stringify(path_1.default.resolve(cwd, mockOptions.path))}, true, /\\.(cjs|js|json|json5|jsonc|mjs|ts)$/),
// 传入的 adapters 是 new 后的对象实例组,可运行 run 方法获取返回结果
var adapters = [${adapterItems.join(', ')}],
var mock = new Mock(mockContext, '${JSON.stringify(mockOptions)}', '${globalObject}', adapters);,
mock.run();
].join('\n');
// 写入内存文件
this.wrapper.fs.mem.mkdirpSync(path_1.default.dirname(mockFilePath));
this.wrapper.fs.mem.writeFileSync(mockFilePath, initMockFileContent);
return mockFilePath;

微信小程序转头条小程序 nextTick 报错

微信原生项目转头条小程序,框架报错,业务项目中并没有使用 nextTick api
image

difineConfig配置

{
    name: 'toutiao-miniprogram',
    sourceType: 'wechat',
    target: 'bytedance',
    compileType: 'subpackage',
    compileMode: 'bundle',
    outputPath: 'dist/dev/mp-toutiao-pack/familyReserve/',
    alias: {
      '@': ''
    },
    autoClean: true,
    processNodeModules: { include: [Array] },
    webpackChain: [Function: webpackChain],
    conditionalCompile: { context: [Object] }
  }
]

vant 打包下 wxs 依赖缺失问题

Describe the bug
在使用vantui库时候,如果主包引用了 一个 vant-a组件,子包引用vant-b组件(需要是notice这类wxs还依赖公共wxs的组件),这个时候进行 build,产物中,子包的npm_package 中 vant缺少公共的wxs文件导致 函数不存在。

To Reproduce
初始化项目,添加 @vant/weapp
在主页面 pages/index 下引入 vant-icon
在子包页面中 src/subPackages/subPackage1/demo 中添加 van-notice-bar组件
然后执行 compile
子包的npm_components下 vant的 van-notice-bar 组件缺少公共的 wxs引入

Expected behavior
将公用的 wxs引入到子包的 npm_components中 或者 针对van这类ui组件同一放在 主包的 npm_components中

Screenshots
If applicable, add screenshots to help explain your problem.
image

代码示例
myapp.zip

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

Windows下,编译路径获取错误

错误代码:node_modules@morjs\plugin-compiler-web\lib\plugins\emitIntermediateAssetsPlugin.js
await utils_1.fsExtra.outputFile(path_1.default.join(intermediateAssetsDir, path_1.default.resolve('/', filePath)), source);

信息如何下:
[mor] ℹ 准备配置中, 即将开始编译 👇
配置名称: web
编译目标: Web 应用
编译环境: development
编译类型: 小程序
编译模式: bundle
源码类型: wechat
源码目录: src
输出目录: dist\web
[mor] ℹ 已开启缓存, 可通过 --no-cache 关闭
[mor] ℹ 已开启 web 转端中间产物输出: .mor\compiler\intermediate-assets\web
[mor] ℹ 开始编译 ...
[mor] ℹ 依赖分析中 ...
[mor] ℹ 依赖分析完成: 耗时: 417.9389 ms
[mor] ⠏ 正在编译, 进度: 10.00%
Debugger ending on ws://127.0.0.1:5858/1802ce6f-c74e-440d-9695-ef1a8c918f7b
[mor] ✔ 编译完成, 耗时: 2377504.3526 ms

[mor] ✖ 编译 ./mor-entries/app.jsx 失败:
=> Module build failed (from ../node_modules/@morjs/plugin-compiler/lib/loaders/postprocessLoader.js):
Error: Path contains invalid characters: C:\Work\MusicLabs\morjs\examples\wechat.mor\compiler\intermediate-assets\web\C:\src\mor-entries
at checkPath (C:\Work\MusicLabs\morjs\examples\wechat\node_modules\fs-extra\lib\mkdirs\utils.js:16:21)
at module.exports.makeDir (C:\Work\MusicLabs\morjs\examples\wechat\node_modules\fs-extra\lib\mkdirs\make-dir.js:12:3)
at Object. (C:\Work\MusicLabs\morjs\examples\wechat\node_modules\universalify\index.js:21:10)
at C:\Work\MusicLabs\morjs\examples\wechat\node_modules\fs-extra\lib\output-file\index.js:20:11
at C:\Work\MusicLabs\morjs\examples\wechat\node_modules\universalify\index.js:21:38
[mor] ✖ 编译错误, 请检查相关报错信息

tdesign-miniprogram如何多端转换

  1. 接入 TDesign 之后
  2. 添加组件库转端配置
import { defineConfig } from '@morjs/cli'

export default defineConfig([
  // {
  //   name: 'wechat-miniprogram',
  //   sourceType: 'wechat',
  //   target: 'wechat',
  //   compileType: 'miniprogram',
  //   compileMode: 'bundle'
  // },
  {
    name: 'web',
    sourceType: 'wechat',
    target: 'web',
    compileType: 'miniprogram',
    compileMode: 'bundle',
    processNodeModules: {
      include: [/tdesign\-miniprogram/]
    }
  }
])

image
image
image
引入的是tdesign-miniprogram属于是小程序组件是不是因为他本身就没有多端转换的能力,又想用这个ui组件库该怎么办呢

this.selectComponent is not a function

1、使用微信官方默认TS案例接入morjs
2、首页添加this.selectComponent代码

onLoad() {
        // @ts-ignore
        if (wx.getUserProfile) {
            this.setData({
                canIUseGetUserProfile: true
            });
        }
        const ele = this.selectComponent('.usermotto');
        console.log(ele)
    },

3、执行npm run dev:web,编译正常,但打开页面报错:

image

地图API问题

微信转支付宝时,地图API存在问题:
地图的polygons属性帮忙看看是不是转化有问题,微信polygons转化之后还是polygons,支付宝官方是polygon,而不是polygons

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.