- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
在带有 typescript 的 ng2 应用程序上,我使用的是 stompjs,它在没有汇总的情况下工作正常。
我正在导入它:
从“stompjs”导入 {Stomp}
运行 rollup 后我得到“异常:Stomp 未定义”
我的汇总配置是:
import rollup from 'rollup';
import nodeResolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
export default {
entry: 'aot/app/src/boot-aot.js',
dest: 'dist/bundle.es2015.js', // output a single application bundle
sourceMap: true,
useStrict: false,
format: 'iife',
treeshake: true,
plugins: [
nodeResolve({
module: true,
jsnext: true,
main: true,
browser: true,
extensions: ['.js']
}),
commonjs({
include: [
'node_modules/rxjs/**',
'node_modules/stompjs/**'
],
namedExports: {
'node_modules/stompjs/lib/stomp.min.js': [ 'Stomp' ]
}
})
]
}
stompjs 的 TypeScript 类型定义文件
declare module "stompjs" {
export interface Client {
heartbeat: any;
debug(...args: string[]);
connect(...args: any[]);
disconnect(disconnectCallback: () => any, headers?: any);
send(destination: string, headers?:any, body?: string);
subscribe(destination: string, callback?: (message: Message) => any, body?: string);
unsubscribe();
begin(transaction: string);
commit(transaction: string);
abort(transaction: string);
ack(messageID: string, subscription: string, headers?: any);
nack(messageID: string, subscription: string, headers?: any);
}
export interface Message {
command: string;
headers: any;
body: string;
ack(headers?: any);
nack(headers?: any);
}
export interface Frame {
constructor(command: string, headers?: any, body?: string);
toString(): string;
sizeOfUTF8(s: string);
unmarshall(datas: any);
marshall(command: string, headers?, body?);
}
export interface Stomp {
client: Client;
Frame: Frame;
over(ws: WebSocket);
}
export default Stomp;
}
最佳答案
使用 import * as Stomp from "stompjs"
关于angular - 如何在 rollup 中导入 stompjs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40114618/
我正在尝试关注this有关如何使用 websockets 的 Spring 教程。我使用 webpack 捆绑我的代码,并使用 babel 将其从 ES6 转换。我正在尝试使用正常的 import 语
我们使用 RabbitMQ + StompJS(使用 SockJS 和 Spring Websocket 作为中间件,FWIW)来促进通过 websocket 广播消息。一切都很好,除了无论我们尝试什
我在 angular(1.5.x) 中使用 SockJS + stomp 客户端来使用 spring (mvc) 服务器建立 websocket。除此以外一切正常:如果我终止服务器,stomp 客户端
在带有 typescript 的 ng2 应用程序上,我使用的是 stompjs,它在没有汇总的情况下工作正常。 我正在导入它: 从“stompjs”导入 {Stomp} 运行 rollup 后我得到
我有支持 Spring Websocket 的 Spring 服务器。我想使用 STOMP 子协议(protocol)来处理网络套接字上的通信,因此 STOMP 端点的配置如下所示: @Configu
遇到找不到 stompJS-lib 的问题,我收到以下错误消息: Module not found: Error: Can't resolve 'net' in '/../../../.../../.
我只在页面加载时尝试连接到远程一次,然后在必要时订阅 channel 。 为了保证代码可以被不同页面共享,我编写的代码(闭包)如下,导出函数webSocket如下: export function w
你好我有一个 Spring MVC 4.0.4 项目完全使用 Wildfly 8.1 服务器内的注释配置,唯一的问题是当我使用以下 javascript 代码使用 Stompjs 初始化 Sockjs
我最初以为我无法让网络套接字在 IE 11 下工作。现在,在添加大量调试细节后,我注意到套接字被正确调用。 问题是 IE 以某种方式返回旧数据。我注意到,在使用 IE 11 更新应用程序中的对象后,每
我是一名优秀的程序员,十分优秀!