0

I am trying to get rollup setup with my ang2 project. I am unable to get past below error:-

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**

Really wasted almost a day on this.

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 is as below.

import typescript from 'rollup-plugin-typescript';

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

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

Any help, people???

Plankton
  • 388
  • 3
  • 13

1 Answers1

0

You should use the latest typescript version for angular, and use this in the config. You are trying to use rollup-plugin-typescript as some kind of typescript fork, but it isn't :) :

let typescriptLatest = require('typescript')

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

  plugins: [
    typescript({
       typescript: typescriptLatest
    }) 
  ]
}
Poul Kruijt
  • 69,713
  • 12
  • 145
  • 149
  • I am using v2.3.2 typescript and if i use ur code, it gives me a huge dump . this does not work – Plankton Jun 09 '17 at 12:12
  • @Plankton well what you are trying to do, is not working as well ;) what does the dump say? – Poul Kruijt Jun 09 '17 at 12:15
  • well it just outputted some library code. no error per say – Plankton Jun 09 '17 at 12:16
  • So maybe it does work :) Anyways, what's the reason you want to make your life harder with an outdated plugin. rollup-plugin-typescript uses a very old typescript version. One that's not compatible with angular any more. Why don't you save yourself the hassle and use the `angular-cli` to roll-up your project – Poul Kruijt Jun 09 '17 at 12:20
  • Didnt know i could do that. Its a topsyturvy world trying to keep updated with whats outdated n whats not. – Plankton Jun 09 '17 at 12:22
  • Yes, it really is madness keeping up with the young cool kids! – Poul Kruijt Jun 09 '17 at 12:24