加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angular – 如何在汇总中导入stompjs

发布时间:2020-12-17 07:15:14 所属栏目:安全 来源:网络整理
导读:在使用打字稿的ng2应用程序上我使用stompjs,它没有汇总它工作正常. 我正在导入它: 从“stompjs”导入{Stomp} 运行汇总后,我得到“EXCEPTION:Stomp is not defined” 我的汇总配置是: import rollup from 'rollup';import nodeResolve from 'rollup-plugin
在使用打字稿的ng2应用程序上我使用stompjs,它没有汇总它工作正常.

我正在导入它:

从“stompjs”导入{Stomp}

运行汇总后,我得到“EXCEPTION:Stomp is not defined”

我的汇总配置是:

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,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 *作为Stomp从“stompjs”

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读