0

I was following the tutorial here http://blog.mgechev.com/2016/06/26/tree-shaking-angular2-production-build-rollup-javascript/

When I try to run rollup, I got this error. Module /Users/gordon/workspace/CraigsMenu/craigsmenu-web/node_modules/@angular2-material/input/input.js does not export MdInputModule (imported by /Users/gordon/workspace/CraigsMenu/craigsmenu-web/dist/app.module.js)

I'm not sure which thing caused the problem. Is it possible that angular2 material input did not support es2015 properly and is still commonjs module?

Anything helps. Thanks in advance!

Gordon Sun
  • 278
  • 1
  • 19

1 Answers1

0

Correct, that's a CommonJS module (scroll to the end, you'll see things like exports.MdInputModule = MdInputModule. To convert it you'll need to use rollup-plugin-commonjs.

Rich Harris
  • 28,091
  • 3
  • 84
  • 99
  • Hi Rich, so my modules are built into ES2015 modules, so I have a project that is a mix of CommonJS modules and ES2015 modules. How do I rollup that? What the rollup.config.js should look like? – Gordon Sun Aug 14 '16 at 19:04
  • In your rollup.config.js, you just need to add an `import commonjs from 'rollup-plugin-commonjs'`, and add a `plugins: [commonjs()]` option. The plugin will identify CommonJS modules and convert them – Rich Harris Aug 15 '16 at 19:23