Open suntong opened 2 years ago
What is your wechaty version?
Answer: wechaty@1.20.2
Which puppet are you using for wechaty? (puppeteer/padlocal/service...)
Answer: padlocal
What is your wechaty-puppet-XXX(padchat/puppeteer/) version?
Answer: wechaty-puppet-padlocal@1.20.1
What is your node version? (run node --version)
node --version
Answer: v16.14.0
Steps to reproduce the behavior:
main.mjs
helper.mjs
main.ts
node main.mjs
export WECHATY_PUPPET=wechaty-puppet-padlocal WECHATY_PUPPET_PADLOCAL_TOKEN=puppet_padlocal_xxx
will get ReferenceError: require is not defined:
ReferenceError: require is not defined
$ node main.mjs 19:21:45 INFO ============================================================ Welcome to Wechaty PadLocal puppet! - puppet-padlocal version: 1.20.1 - padlocal-ts-client version: 0.5.3 ============================================================ 19:21:45 INFO [PadLocalDemo] started. 19:21:47 INFO [PuppetPadlocal] start login with type: QrLogin 19:21:50 INFO [PadLocalDemo] onScan: Waiting(2) - https://wechaty.js.org/qrcode/http%3A%2F%2Fweixin.qq.com%2Fx%2FAbaw84QP3rB6uX6zHLAW ReferenceError: require is not defined at WechatyImpl.<anonymous> (file:///nodejs/step1/wechaty-puppet-padlocal-demo/main.mjs:22:7) at WechatyImpl.emit (node:events:520:28) at WechatyImpl.emit (file:///nodejs/step1/wechaty-puppet-padlocal-demo/node_modules/wechaty/dist/esm/src/wechaty-mixins/gerror-mixin.js:31:30) at PuppetPadlocal.<anonymous> (file:///nodejs/step1/wechaty-puppet-padlocal-demo/node_modules/wechaty/dist/esm/src/wechaty-mixins/puppet-mixin.js:343:34) at PuppetPadlocal.emit (node:events:532:35) at PuppetPadlocal.emit (file:///nodejs/step1/wechaty-puppet-padlocal-demo/node_modules/wechaty-puppet/dist/esm/src/puppet/puppet-skeleton.js:84:26) at Object.onQrCodeEvent (file:///nodejs/step1/wechaty-puppet-padlocal-demo/node_modules/wechaty-puppet-padlocal/dist/esm/src/puppet-padlocal.js:113:18) at Request.request.onMessageCallback (/nodejs/step1/wechaty-puppet-padlocal-demo/node_modules/padlocal-client-ts/dist/PadLocalClientApi.js:63:34) at Request.<anonymous> (/nodejs/step1/wechaty-puppet-padlocal-demo/node_modules/padlocal-client-ts/dist/Request.js:175:91) at Generator.next (<anonymous>) $ grep require /nodejs/step1/wechaty-puppet-padlocal-demo/node_modules/padlocal-client-ts/dist/Request.js const padlocal_pb_1 = require("./proto/padlocal_pb"); const ActionMessageUtils_1 = require("./utils/ActionMessageUtils"); const PromiseUtils_1 = require("./utils/PromiseUtils"); const WeChatShortLinkProxy_1 = require("./link/WeChatShortLinkProxy"); const verror_1 = __importDefault(require("verror")); const Utils_1 = require("./utils/Utils"); const SocketStreamHandler_1 = require("./link/SocketStreamHandler"); const LongLinkStreamHandler_1 = require("./link/LongLinkStreamHandler"); const PushStreamHandler_1 = require("./link/PushStreamHandler"); const GrpcClient_1 = require("./GrpcClient"); const PadLocalClientPlugin_1 = require("./PadLocalClientPlugin"); const FileUploadStreamHandler_1 = require("./link/FileUploadStreamHandler"); const ByteUtils_1 = require("./utils/ByteUtils"); const WeChatHttpProxy_1 = require("./link/WeChatHttpProxy"); const Log_1 = __importDefault(require("./utils/Log"));
Basically
require('./xx')
import {stuff} from './xx'
Somehow packaging from padlocal-client-ts for ESM is not done right.
padlocal-client-ts
Please double check.
the two code is almost the same. One works and one doesn't. Here is the key changes:
and now it is working. So I'd conclude that the ESM module support is broken.
Versions
Answer: wechaty@1.20.2
Answer: padlocal
Answer: wechaty-puppet-padlocal@1.20.1
Answer: v16.14.0
To Reproduce
Steps to reproduce the behavior:
main.mjs
andhelper.mjs
from here, and put them wheremain.ts
isnode main.mjs
afterexport WECHATY_PUPPET=wechaty-puppet-padlocal WECHATY_PUPPET_PADLOCAL_TOKEN=puppet_padlocal_xxx
The bug
will get
ReferenceError: require is not defined
:Basically
require('./xx')
syntax, whileimport {stuff} from './xx'
syntaxSomehow packaging from
padlocal-client-ts
for ESM is not done right.Please double check.