Blog · GitLab (User) Created at 2018-2-25 09:40:20 Updated at 2018-2-27 21:29:22 Tomáš Hübelbauer
Include a fix for the Rollup+TypeScript issue

Rollup

Installing

yarn global add rollup

I am using a fork with a fix that was preventing me from seeing TypeScript erros due to a sourcemap consumption problem.

The above allowed me to obtain and build the fork and in addition to it, I've changed the invocation of rollup to:

node node_modules/rollup/bin/rollup -c

Now my TypeScript errors flow right through.

Bundling

rollup index.js -o bundle.js -f iife

Or use a rollup.config.js file, see Configuring.

Configuring

rollup.config.js:

export default {
  input: 'index.js',
  output: {
    file: 'bundle.js',
    format: 'iife'
  }
};

rollup -c

Integrating

rollup-plugin-node-resolve

For importing Node packages.

rollup-plugin-commonjs

For Node packages which do not expose ES6 modules but use CJS.

rollup-plugin-typescript2

The real TypeScript plugin, rollup-plugin-typescript does not support TS2.

Troubleshooting

Cannot call a namespace:

Happens when using Rollup with code like this:

import * as qrcode from 'qrcode-generator';

The fix is this:

import * as qrcode_ from 'qrcode-generator';
const qrcode: typeof qrcode_ = qrcode_;
// WTF I know…

“version” is a required argument:

There is now a PR with a fix, see the related todo

This only obscures the real underlying issue, which is often Cannot call a namespace as seen above.

Changes (3)
2018-2-27 21:29:22 Tomáš Hübelbauer
Include a fix for the Rollup+TypeScript issue
2018-2-27 20:51:09 Tomáš Hübelbauer
Demonstrate the TypeScript problem
2018-2-25 09:42:07 Tomáš Hübelbauer
Document rollup issues faced while attempting to use it
Comments E-mail me!