indutny / webpack-common-shake

CommonJS Tree Shaker plugin for WebPack
918 stars 13 forks source link

TypeError: Cannot read property 'bailouts' of undefined #11

Closed ruiaraujo closed 7 years ago

ruiaraujo commented 7 years ago

Hello,

I was trying to look the effects of running this plugin on my build and got this error.

I am webpack 3.1.0.

Happy to help with any debugging else that is needed.

TypeError: Cannot read property 'bailouts' of undefined
    at Module.mergeFrom (/Users/ruka/Projects/web/node_modules/common-shake/lib/shake/module.js:106:17)
    at Analyzer.resolve (/Users/ruka/Projects/web/node_modules/common-shake/lib/shake/analyzer.js:60:12)
    at module.reasons.forEach (/Users/ruka/Projects/web/node_modules/webpack-common-shake/lib/shake/plugin.js:77:26)
    at Array.forEach (native)
    at modules.forEach (/Users/ruka/Projects/web/node_modules/webpack-common-shake/lib/shake/plugin.js:70:24)
    at Array.forEach (native)
    at Compilation.compilation.plugin (/Users/ruka/Projects/web/node_modules/webpack-common-shake/lib/shake/plugin.js:69:15)
    at Compilation.applyPluginsBailResult (/Users/ruka/Projects/web/node_modules/webpack/node_modules/tapable/lib/Tapable.js:109:27)
    at sealPart2 (/Users/ruka/Projects/web/node_modules/webpack/lib/Compilation.js:586:10)
    at next (/Users/ruka/Projects/web/node_modules/webpack/node_modules/tapable/lib/Tapable.js:138:11)
    at Compilation.compilation.plugin (/Users/ruka/Projects/web/node_modules/webpack/lib/ProgressPlugin.js:111:6)
    at next (/Users/ruka/Projects/web/node_modules/webpack/node_modules/tapable/lib/Tapable.js:140:14)
    at /Users/ruka/Projects/web/node_modules/extract-text-webpack-plugin/dist/index.js:241:13
    at /Users/ruka/Projects/web/node_modules/extract-text-webpack-plugin/node_modules/async/dist/async.js:421:16
    at iteratorCallback (/Users/ruka/Projects/web/node_modules/extract-text-webpack-plugin/node_modules/async/dist/async.js:998:13)
    at /Users/ruka/Projects/web/node_modules/extract-text-webpack-plugin/node_modules/async/dist/async.js:906:16
    at /Users/ruka/Projects/web/node_modules/extract-text-webpack-plugin/dist/index.js:224:15
    at /Users/ruka/Projects/web/node_modules/extract-text-webpack-plugin/node_modules/async/dist/async.js:421:16
    at iteratorCallback (/Users/ruka/Projects/web/node_modules/extract-text-webpack-plugin/node_modules/async/dist/async.js:998:13)
    at /Users/ruka/Projects/web/node_modules/extract-text-webpack-plugin/node_modules/async/dist/async.js:906:16
    at /Users/ruka/Projects/web/node_modules/extract-text-webpack-plugin/dist/index.js:221:22
    at /Users/ruka/Projects/web/node_modules/extract-text-webpack-plugin/node_modules/async/dist/async.js:3083:16
    at eachOfArrayLike (/Users/ruka/Projects/web/node_modules/extract-text-webpack-plugin/node_modules/async/dist/async.js:1003:9)
    at eachOf (/Users/ruka/Projects/web/node_modules/extract-text-webpack-plugin/node_modules/async/dist/async.js:1051:5)
    at Object.eachLimit (/Users/ruka/Projects/web/node_modules/extract-text-webpack-plugin/node_modules/async/dist/async.js:3145:5)
    at /Users/ruka/Projects/web/node_modules/extract-text-webpack-plugin/dist/index.js:189:29
    at /Users/ruka/Projects/web/node_modules/extract-text-webpack-plugin/node_modules/async/dist/async.js:3083:16
    at eachOfArrayLike (/Users/ruka/Projects/web/node_modules/extract-text-webpack-plugin/node_modules/async/dist/async.js:1003:9)
    at eachOf (/Users/ruka/Projects/web/node_modules/extract-text-webpack-plugin/node_modules/async/dist/async.js:1051:5)
    at Object.eachLimit (/Users/ruka/Projects/web/node_modules/extract-text-webpack-plugin/node_modules/async/dist/async.js:3145:5)
indutny commented 7 years ago

Hello!

I'm really sorry for this!

May I ask you to run it with DEBUG="common-shake*" webpack?

ruiaraujo commented 7 years ago

Sure, this generates a lot of output here it is some of it right above of the error.

Tell me if you need all of it.

  common-shake:analyzer resolve "/Users/ruka/Projects/web/src/containers/App/App.js":"components/InviteFriend/InviteFriendModal" => "/Users/ruka/Projects/web/src/components/InviteFriend/InviteFriendModal.js" +0ms
  common-shake:analyzer resolve "/Users/ruka/Projects/web/src/components/InviteFriend/InviteFriendModal.js":"./InviteFriendModal.scss" => "/Users/ruka/Projects/web/src/components/InviteFriend/InviteFriendModal.scss" +0ms
  common-shake:analyzer resolve "/Users/ruka/Projects/web/src/components/InviteFriend/InviteFriendModal.scss":"!!../../../node_modules/css-loader/index.js??ref--0-1!../../../node_modules/postcss-loader/lib/index.js??ref--0-2!../../../node_modules/sass-loader/lib/loader.js??ref--0-3!./InviteFriendModal.scss" => "/Users/ruka/Projects/web/src/components/InviteFriend/InviteFriendModal.scss" +0ms
  common-shake:module use this="/Users/ruka/Projects/web/src/components/InviteFriend/InviteFriendModal.scss" property="locals" from="/Users/ruka/Projects/web/src/components/InviteFriend/InviteFriendModal.scss" recursive=false +0ms
  common-shake:analyzer resolve "/Users/ruka/Projects/web/src/client.js":"./containers/App/ScrollToTop" => "/Users/ruka/Projects/web/src/containers/App/ScrollToTop.js" +0ms
  common-shake:analyzer resolve "/Users/ruka/Projects/web/src/client.js":"./redux/create" => "/Users/ruka/Projects/web/src/redux/create.js" +0ms
  common-shake:analyzer resolve "/Users/ruka/Projects/web/src/redux/create.js":"./middleware/clientMiddleware" => "/Users/ruka/Projects/web/src/redux/middleware/clientMiddleware.js" +0ms
  common-shake:analyzer resolve "/Users/ruka/Projects/web/src/redux/create.js":"./middleware/goalMiddleware" => "/Users/ruka/Projects/web/src/redux/middleware/goalMiddleware.js" +0ms
  common-shake:analyzer resolve "/Users/ruka/Projects/web/src/redux/create.js":"./middleware/tokenMiddleware" => "/Users/ruka/Projects/web/src/redux/middleware/tokenMiddleware.js" +0ms
  common-shake:analyzer resolve "/Users/ruka/Projects/web/src/redux/create.js":"./middleware/taskMiddleware" => "/Users/ruka/Projects/web/src/redux/middleware/taskMiddleware.js" +0ms
  common-shake:analyzer resolve "/Users/ruka/Projects/web/src/redux/create.js":"./middleware/heartbeatMiddleware" => "/Users/ruka/Projects/web/src/redux/middleware/heartbeatMiddleware.js" +0ms
  common-shake:analyzer resolve "/Users/ruka/Projects/web/src/client.js":"./helpers/ApiClient" => "/Users/ruka/Projects/web/src/helpers/ApiClient.js" +0ms
  common-shake:analyzer resolve "/Users/ruka/Projects/web/src/client.js":"./theme/bootstrap.theme.config" => "/Users/ruka/Projects/web/src/theme/bootstrap.theme.config.js" +0ms
  common-shake:analyzer resolve "/Users/ruka/Projects/web/src/client.js":"./fontLoading" => "/Users/ruka/Projects/web/src/fontLoading.js" +0ms
  common-shake:analyzer resolve undefined:"fontfaceobserver" => "/Users/ruka/Projects/web/node_modules/fontfaceobserver/fontfaceobserver.standalone.js" +0ms
  common-shake:analyzer resolve undefined:"offline-plugin/runtime" => "/Users/ruka/Projects/web/node_modules/offline-plugin/runtime.js" +0ms
  common-shake:analyzer resolve "/Users/ruka/Projects/web/src/client.js":"intl" => "/Users/ruka/Projects/web/node_modules/intl/index.js" +0ms
  common-shake:analyzer resolve "/Users/ruka/Projects/web/src/client.js":"intl" => "/Users/ruka/Projects/web/node_modules/intl/index.js" +0ms
  common-shake:analyzer resolve "/Users/ruka/Projects/web/node_modules/intl/index.js":"./lib/core.js" => "/Users/ruka/Projects/web/node_modules/intl/lib/core.js" +0ms
  common-shake:analyzer resolve "/Users/ruka/Projects/web/node_modules/intl/index.js":"./locale-data/complete.js" => undefined +0ms
  common-shake:analyzer resolve "/Users/ruka/Projects/web/src/client.js":"intl/locale-data/jsonp/de" => "/Users/ruka/Projects/web/node_modules/intl/locale-data/jsonp/de.js" +0ms
  common-shake:analyzer resolve "/Users/ruka/Projects/web/src/client.js":"intl/locale-data/jsonp/de" => "/Users/ruka/Projects/web/node_modules/intl/locale-data/jsonp/de.js" +0ms
  common-shake:analyzer resolve undefined:"./src/client.js" => undefined +1ms
  common-shake:analyzer resolve "/Users/ruka/Projects/web/src/containers/App/App.js":"containers/MyProducts/Credit" => undefined +0ms
  common-shake:analyzer resolve "/Users/ruka/Projects/web/src/containers/App/App.js":"containers/MyProducts/ProductApplication" => undefined +0ms
  common-shake:analyzer resolve undefined:"react-intl" => undefined +0ms
  common-shake:analyzer resolve undefined:"react-intl" => undefined +0ms
indutny commented 7 years ago

Thanks!

indutny commented 7 years ago

Just published 1.5.1, please give it a try!

indutny commented 7 years ago

(BTW, I'm very curious about the results. Please keep my in the loop! :wink: )

ruiaraujo commented 7 years ago

It works but now it fails the build in OfflinePlugin. It removes the runtime from the build.

indutny commented 7 years ago

Do you think you could help me create a reduced test case for this? I have very little experience with offline-plugin.

ruiaraujo commented 7 years ago

https://github.com/indutny/webpack-common-shake-demo/pull/1

Done.

indutny commented 7 years ago

Thank you!

indutny commented 7 years ago

@ruiaraujo fixed! :wink: Please give a try to 1.5.2 !

ruiaraujo commented 7 years ago

@indutny Good job, it works now.

The differences are really tiny, like 0.05% but it is something. :man_shrugging:

Thanks for the very quick turnaround with the bug fixes. 👍

indutny commented 7 years ago

You're more than welcome! I'm thinking about working on CommonJS hoisting soon, this should have more measurable impact on the output.

If you want - there is potentially a way to further reduce your output size. Just add warnings: true to the plugin options and it will print a bunch of information on the source lines that were preventing the optimization.

ruiaraujo commented 7 years ago

Thanks for the hint.

indutny commented 7 years ago

No problem. Btw, is 0.05% improvement measured on minimified (production) output? This plugin heavily relies on dead code removal by UglifyJS.

ruiaraujo commented 7 years ago

Yes after gzip which it is what I care about.

indutny commented 7 years ago

Ah, great. Thank you for this information!