2017-04-19 61 views
5

我想我的捆綁文件打字稿彙總(https://rollupjs.org/
我用這個配置文件:與彙總捆綁打字稿 - 無法處理的編譯器選項

rollup.config.js:

import alias from 'rollup-plugin-alias'; 
import resolve from 'rollup-plugin-node-resolve'; 
import typescript from 'rollup-plugin-typescript'; 
import angular from 'rollup-plugin-angular'; 

export default { 
    entry: '../main.ts', 
    format: 'iife', 
    dest: 'dist/bundle.es2015.js', 
    sourceMap: true, 
    plugins: [ 
     angular(), 
     typescript(), 
     alias({ rxjs: __dirname + '/node_modules/rxjs-es' }), 
     resolve({ 
      jsnext: true, 
      main: true, 
      browser: true 
     }) 
    ], 
    external: [ 
     '@angular/core', 
     '@angular/common', 
     '@angular/compiler', 
     '@angular/core', 
     '@angular/http', 
     '@angular/platform-browser', 
     '@angular/platform-browser-dynamic', 
     '@angular/router', 
     '@angular/router-deprecated' 
    ], 
    globals: { 
     '@angular/common': 'vendor._angular_common', 
     '@angular/compiler': 'vendor._angular_compiler', 
     '@angular/core': 'vendor._angular_core', 
     '@angular/http': 'vendor._angular_http', 
     '@angular/platform-browser': 'vendor._angular_platformBrowser', 
     '@angular/platform-browser-dynamic': 'vendor._angular_platformBrowserDynamic', 
     '@angular/router': 'vendor._angular_router', 
     '@angular/forms': 'vendor._angular_forms' 
    } 
} 

vendor.js:

import * as _angular_common from '@angular/common'; 
import * as _angular_compiler from '@angular/compiler'; 
import * as _angular_core from '@angular/core'; 
import * as _angular_http from '@angular/http'; 
import * as _angular_platformBrowser from '@angular/platform-browser'; 
import * as _angular_platformBrowserDynamic from '@angular/platform-browser-dynamic'; 
import * as _angular_router from '@angular/router'; 
import * as _angular_forms from '@angular/forms'; 

export default { 
    _angular_common, 
    _angular_compiler, 
    _angular_core, 
    _angular_http, 
    _angular_platformBrowser, 
    _angular_platformBrowserDynamic, 
    _angular_router, 
    _angular_forms 
}; 

但我不斷收到此錯誤:

rollup-plugin-typescript: Argument for '--target' option must be 'ES3', 'ES5', or 'ES2015'. 
rollup-plugin-typescript: Unknown compiler option 'lib'. 
rollup-plugin-typescript: Couldn't process compiler options 

我在做什麼錯? (我在這個新的,所以如果我不寫一些需要的信息 - 請告訴我)

編輯:

這是我tsconfig.json:

{ 
    "compilerOptions": { 
    "target": "es2017", 
    "module": "commonjs", 
    "moduleResolution": "node", 
    "outDir": ".\\Compiled-JS\\Apps\\Client", 
    "sourceMap": true, 
    "emitDecoratorMetadata": true, 
    "experimentalDecorators": true, 
    "lib": [ "es2015", "dom" ], 
    "noImplicitAny": true, 
    "suppressImplicitAnyIndexErrors": true 
    } 
} 
+0

什麼是你的tsconfig.json? - 當typescript({tsconfig:false})''也工作嗎? –

+0

@DenisTsoi:我添加了我的tsconfig.json ...當我使用tsconfig:false時 - 我得到了一個「意外的字符'@'」錯誤,就好像它不知道它是打字稿一樣(因爲「@NgModule」 2)。 – Idov

+0

也是你使用https://github.com/ezolenko/rollup-plugin-typescript2? –

回答

10

您可能需要使用rollup-plugin-typescript2

Rollup-plugin-typescript似乎支持1.8.9作爲默認值,這也可能是問題的一部分。