indutny / webpack-common-shake

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

Cannot read property 'has' of null || TypeError: Cannot read property 'has' of null #10

Closed niieani closed 7 years ago

niieani commented 7 years ago

Hi @indutny. I've updated again, however the build still crashes. Sorry ;)

[Step 5/6] [Compilation] : Cannot read property 'has' of null || TypeError: Cannot read property 'has' of null
    at Module.isUsed (/home/teamcity/agent-09/3b0ebbb1933d0dce/node_modules/common-shake/lib/shake/module.js:78:19)
    at analyzer.run.getDeclarations.filter (/home/teamcity/agent-09/3b0ebbb1933d0dce/node_modules/webpack-common-shake/lib/shake/replacement.js:100:26)
    at Array.filter (native)
    at ReplacementModule.source (/home/teamcity/agent-09/3b0ebbb1933d0dce/node_modules/webpack-common-shake/lib/shake/replacement.js:99:25)
    at ModuleTemplate.render (/home/teamcity/agent-09/3b0ebbb1933d0dce/node_modules/webpack/lib/ModuleTemplate.js:14:31)
    at /home/teamcity/agent-09/3b0ebbb1933d0dce/node_modules/webpack/lib/Template.js:110:28
    at Function.from (native)
    at ChunkTemplate.renderChunkModules (/home/teamcity/agent-09/3b0ebbb1933d0dce/node_modules/webpack/lib/Template.js:107:26)
    at ChunkTemplate.render (/home/teamcity/agent-09/3b0ebbb1933d0dce/node_modules/webpack/lib/ChunkTemplate.js:16:30)
    at Compilation.createChunkAssets (/home/teamcity/agent-09/3b0ebbb1933d0dce/node_modules/webpack/lib/Compilation.js:1255:35)
    at sealPart2 (/home/teamcity/agent-09/3b0ebbb1933d0dce/node_modules/webpack/lib/Compilation.js:628:10)
    at next (/home/teamcity/agent-09/3b0ebbb1933d0dce/node_modules/tapable/lib/Tapable.js:138:11)
    at Compilation.compilation.plugin (/home/teamcity/agent-09/3b0ebbb1933d0dce/node_modules/webpack/lib/ProgressPlugin.js:111:6)
    at Compilation.applyPluginsAsyncSeries (/home/teamcity/agent-09/3b0ebbb1933d0dce/node_modules/tapable/lib/Tapable.js:142:13)
    at Compilation.seal (/home/teamcity/agent-09/3b0ebbb1933d0dce/node_modules/webpack/lib/Compilation.js:578:8)
    at /home/teamcity/agent-09/3b0ebbb1933d0dce/node_modules/webpack/lib/Compiler.js:510:16
    at /home/teamcity/agent-09/3b0ebbb1933d0dce/node_modules/tapable/lib/Tapable.js:225:11
    at _combinedTickCallback (internal/process/next_tick.js:134:7)
    at process._tickCallback (internal/process/next_tick.js:201:9)

ChunkRenderError: 
    at Compilation.createChunkAssets (/home/teamcity/agent-09/3b0ebbb1933d0dce/node_modules/webpack/lib/Compilation.js:1274:22)
    at sealPart2 (/home/teamcity/agent-09/3b0ebbb1933d0dce/node_modules/webpack/lib/Compilation.js:628:10)
    at next (/home/teamcity/agent-09/3b0ebbb1933d0dce/node_modules/tapable/lib/Tapable.js:138:11)
    at Compilation.compilation.plugin (/home/teamcity/agent-09/3b0ebbb1933d0dce/node_modules/webpack/lib/ProgressPlugin.js:111:6)
    at Compilation.applyPluginsAsyncSeries (/home/teamcity/agent-09/3b0ebbb1933d0dce/node_modules/tapable/lib/Tapable.js:142:13)
    at Compilation.seal (/home/teamcity/agent-09/3b0ebbb1933d0dce/node_modules/webpack/lib/Compilation.js:578:8)
    at /home/teamcity/agent-09/3b0ebbb1933d0dce/node_modules/webpack/lib/Compiler.js:510:16
    at /home/teamcity/agent-09/3b0ebbb1933d0dce/node_modules/tapable/lib/Tapable.js:225:11
    at _combinedTickCallback (internal/process/next_tick.js:134:7)
    at process._tickCallback (internal/process/next_tick.js:201:9)
indutny commented 7 years ago

Hello!

No worries! :wink: Let's see how this can be fixed.

indutny commented 7 years ago

I suspect that there is a "double-resolution" happening somewhere, but not yet sure why... Just published common-shake@1.5.1 with extra debug logging.

Would you care to update it (with npm --depth=2 update, please double-check npm ls common-shake) and try to build it with DEBUG="common-shake:*" webpack (or any other command, but with DEBUG environment set to this).

It should print a bunch of lines prefixed with common-shake:analyzer.

Thanks!

indutny commented 7 years ago

Just updated webpack-common-shake as well. The latest is 1.2.5.

niieani commented 7 years ago

This seems to be fixed in the latest version.

indutny commented 7 years ago

Hooray! Out of curiosity, did it reduce the size in any way?

niieani commented 7 years ago

@indutny see #13.