rollup / rollup-plugin-commonjs

This module has moved and is now available at @rollup/plugin-commonjs / https://github.com/rollup/plugins/blob/master/packages/commonjs
MIT License
501 stars 126 forks source link

Cannot bundle Protobuf.js with rollup-plugin-commonjs #378

Closed mmacfadden closed 4 years ago

mmacfadden commented 5 years ago

How Do We Reproduce?

I have created a repo which demonstrates the issue here: https://github.com/mmacfadden/rollup-protobufjs

There are instructions in the readme of the Repo.

Expected Behavior

The generated UMD module is usable.

Actual Behavior

Uncaught TypeError: Cannot read property 'emptyArray' of undefined
   at types.js:110
   at createCommonjsModule (index.umd.js:10)
   at index.js:65
   at index.umd.js:4
   at index.umd.js:5

An exception is thrown to the console when merely loading the bundle, before even using it. The issue seems to be that an object is being referenced in the resulting bundle before the object itself is being created. I suspect this has to do with resolution of circular dependencies.

I noted that protobufjs seems to have a browserify'ed version of the library already bundles, and I have used this browser version before, through hotlinking, however I would like to actually bundle protobufjs up in my library now, and it this issue.

Crossposted here: https://github.com/rollup/rollup/issues/2747

mmacfadden commented 4 years ago

This might be of interest. The folks over at Rollup have a workaround. Wonder if this could be incorporated into the codebase here?

https://github.com/rollup/rollup/issues/2747#issuecomment-507676912

shellscape commented 4 years ago

@mmacfadden we're getting ready to move this plugin to https://github.com/rollup/plugins. If you'd like to open a discussion there for including a workaround into the plugin once the move is done, I'm sure it would be welcomed. We're going to close this for now, but thank you for opening this issue.