我已经能够毫无问题地导入一些简单的外部 js 库,例如 moment 到自定义 Stencil Web 组件,但最近我想构建一个依赖于 stomp-websocket 和 sockjs-client 的 stomp Web 组件。
我无法正确导入其中任何一个。在我使用的任何导入变体中,我在 npm start 的控制台上收到很多警告,在浏览器控制台上我得到
TypeError: Cannot read property 'map' of null at my-component.js:13771 "http://localhost:3333/build/mycomponent/my-component.js" @mycomponent.core.js:2193
npm 启动控制台:
[52:27.1] generate styles finished in 974 ms
preferring built-in module 'punycode' over local alternative at
'(...)/my-component/node_modules/punycode/punycode.js', pass
'preferBuiltins: false' to disable this behavior or 'preferBuiltins:
true' to disable this warning
preferring built-in module 'punycode' over local alternative at
'(...)/my-component/node_modules/punycode/punycode.js', pass
'preferBuiltins: false' to disable this behavior or 'preferBuiltins:
true' to disable this warning
preferring built-in module 'string_decoder' over local alternative at
(...)/my-component/node_modules/string_decoder/lib/string_decoder.js',
pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'string_decoder' over local alternative at
'(...)/my-component/node_modules/string_decoder/lib/string_decoder.js',
pass 'preferBuiltins: false' to disable this behavior or
'preferBuiltins: true' to disable this warning
[52:29.9] module map finished in 3.84 s
任何有关正在发生的事情的见解都值得赞赏。