【问题标题】:Unable to get rollup working with an angular2 project无法使用 angular2 项目进行汇总
【发布时间】:2017-06-09 12:02:15
【问题描述】:

我正在尝试使用我的 ang2 项目进行汇总设置。 我无法通过以下错误:-

D:\js\bundling\rollup_ng2_tes1\test1>D:\js\bundling\rollup_ng2_tes1\test1\node_modules\.bin\rollup -c
**?   typescript.readConfigFile is not a function**

真的浪费了将近一天的时间。

tsconfig.json

{
  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./dist/out-tsc",
    "baseUrl": "src",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2016",
      "dom"
    ]
  }
}

rollup.config.js如下。

import typescript from 'rollup-plugin-typescript';

export default 
{
  entry: './src/main.ts',

  plugins: [
    typescript({
       typescript: require('rollup-plugin-typescript')
    }) 
  ]
}

任何帮助,人们???

【问题讨论】:

    标签: angular typescript rollup


    【解决方案1】:

    您应该使用最新的 Angular 打字稿版本,并在配置中使用它。您正在尝试使用rollup-plugin-typescript 作为某种打字稿叉,但它不是:) :

    let typescriptLatest = require('typescript')
    
    export default {
      entry: './src/main.ts',
    
      plugins: [
        typescript({
           typescript: typescriptLatest
        }) 
      ]
    }
    

    【讨论】:

    • 我正在使用 v2.3.2 打字稿,如果我使用你的代码,它会给我一个巨大的转储。这不起作用
    • @Plankton 以及您正在尝试做的事情,但效果不佳;)转储说什么?
    • 它只是输出了一些库代码。每说没有错误
    • 所以也许它确实有效:) 无论如何,你想用一个过时的插件让你的生活变得更艰难的原因是什么。 rollup-plugin-typescript 使用非常旧的 typescript 版本。不再与 Angular 兼容的一种。您为什么不省去麻烦并使用angular-cli 来汇总您的项目
    • 不知道我能做到。这是一个颠倒的世界,试图不断更新过时的东西。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-17
    • 2017-04-19
    • 1970-01-01
    相关资源
    最近更新 更多