卷起错误:意外的令牌:名称

时间:2016-10-11 21:42:47

标签: typescript ecmascript-6 rollupjs

我正在尝试使用Rollup捆绑和树木现有项目。但是,我收到以下错误。

  

导出'客户'未定义为' C:\ Users \ George \ Source \ Repos \ docs \ client \ service \ search.service.js'   使用' uglify'转换捆绑包时出错plugin:SyntaxError:意外的标记:name(UiService)

这是我的search.service.ts:

from bs4 import BeautifulSoup

myHTML = 'what you posted above'
soup = BeautifulSoup(myHTML, "html5lib")
div = soup.find('div')
title = div.get('title', '')  # safe way to check for the title, incase the div doesn't contain it

这是我的ui.service.ts:

import { Injectable } from '@angular/core';
import * as elasticsearch from 'elasticsearch';
//declare var elasticsearch: any;

@Injectable()
export class SearchService {
    private Client: elasticsearch.Client;
    constructor() {
        var connectionString = 'https://paas:2664f39b6a927d0873b43fab6893ace6@bifur-eu-west-1.searchly.com';
        this.Client = new elasticsearch.Client({
            host: connectionString,
            log: 'trace'
        });
    }

    search(term: string): any {
        return this.Client.search({
            index: 'plugins',
            type: 'ds044699_mlab_com_cdc1',
            body: {
                query: {
                    multi_match: {
                        query: term,
                        fields: ['name', 'description']
                    }
                }
            }
        });
    }
}

我无法看到这两个文件有什么问题? - 我应该在哪里看?

1 个答案:

答案 0 :(得分:2)

对于第一个错误(Export 'Client' is not defined by...),您可能需要将namedExports选项与rollup-plugin-commonjs一起使用。我们刚刚发布了一个新版本的Rollup,它使这条消息更加不言自明,并链接到Troubleshooting页面。

第二条消息看起来可能与UglifyJS有关,而不是缩小ES6代码。您可能需要在TypeScript配置中定位ES5(我认为 - 我不做TypeScript)或添加像rollup-plugin-bublerollup-plugin-babel之类的转换,以便在缩小之前将其转换为ES5。