-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wechaty v1.x API #125
Wechaty v1.x API #125
Conversation
Have removed the ESM from this PR with the latest commits. I hope we can upgrade to Wechaty v1 soon! |
我把esm分支拉到本地跑了一下,发现安装依赖并没有问题,action 跑的时候可能是超时导致的失败。不过安装完依赖在运行
|
Hi @leochen-g Thank you very much for taking look at this PR! The error messages you have posted is very wired because we can require wechaty without any problem with CLI: $ node
Welcome to Node.js v16.13.2.
Type ".help" for more information.
> require('wechaty-puppet/types')
{
ContactGender: [Getter],
Contact: [Getter],
FriendshipScene: [Getter],
Friendship: [Getter],
Image: [Getter],
Message: [Getter],
Post: [Getter],
Tap: [Getter],
Sayable: [Getter],
Payload: [Getter],
Dirty: [Getter],
ScanStatus: [Getter],
YOU: [Getter],
CHAT_EVENT_DICT: [Getter],
PUPPET_EVENT_DICT: [Getter]
} So I added another minimum unit test that loads the $ ./tests/wechaty-login.spec.ts
TAP version 13
# Subtest: smoke testing
ok 1 - bot has created
1..1
ok 1 - smoke testing # time=6.318ms
1..1
# time=17.664ms Tap source code: puppet-padlocal/tests/tap.spec.ts Lines 1 to 10 in 593c615
So I guess the problem might relate to the Not sure about it but hope the above information could be helpful for the future investigating. |
@huan 有点不太明白哈,就是现在1.x版本使用的应该是esm的导入方式引入包,但是我看报错,引入的wechaty是cjs的,这个是不是不太对,packages.json 里我看并没有 |
This is partially correct. The 1.x version of Wechaty is built with a Dual-ESM-CJS pattern, which means that when it is loaded by an ESM module then it will be an ESM module, otherwise when it is loaded by a CJS module then it will be a CJS module. When the Wechaty is loading by the correct version of the wechaty-puppet-padlocal (which is a CJS module), then it will act as a CJS module and be loaded as CJS.
This is expected. According to my above explanation: when the CJS wechaty-puppet-padlocal load the wechaty, the wechaty will be in CJS mode.
If the package.json specifies a wechaty-puppet-padlocal has no
wechaty, wechaty-puppet, and other Wechaty ecosystem modules have And we have enabled the Dual-ESM-CJS for them when they have been built, so they can be used either by ESM or CJS. I hope my explanations help you understand the situation, please feel free to let me know if you have more questions. |
好的 谢谢解惑 我再研究一下 |
@leochen-g You are welcome! |
any progress? |
Finally! Congratulations! 🎉 |
@padlocal I have upgraded the code base with the ES Module & Wechaty v1.x, please review and let me know what you think.
Thank you very much!
Related to: