dave / jsgo

GopherJS compiler, serving framework and CDN.
https://jsgo.io/<path>
MIT License
269 stars 11 forks source link

init() order might be different from other build systems #6

Open hajimehoshi opened 6 years ago

hajimehoshi commented 6 years ago

JS code from the same Go code both with and without minimizing worked on my local machine (I have confirmed gopherjs serve --tags=example -m). Is there a good way to debug this? Now it's hard since the js code is minimized.

prelude.d7be2bb7257fad35c0261c76fc03aed1a338ee9e.js:1 Uncaught Error: runtime error: invalid memory address or nil pointer dereference
    at $callDeferred (prelude.d7be2bb7257fad35c0261c76fc03aed1a338ee9e.js:1)
    at $panic (prelude.d7be2bb7257fad35c0261c76fc03aed1a338ee9e.js:1)
    at AS (runtime.862690a6e22bb9d83a495b05ae0a6de473c0b502.js:1)
    at Object.$throwNilPointerError (prelude.d7be2bb7257fad35c0261c76fc03aed1a338ee9e.js:1)
    at S (text.c1f0ba1fc72b86a5a68338ef75bc6e8c3dd215ea.js:1)
    at W (text.c1f0ba1fc72b86a5a68338ef75bc6e8c3dd215ea.js:1)
    at O (text.c1f0ba1fc72b86a5a68338ef75bc6e8c3dd215ea.js:1)
    at Object.Y [as Draw] (text.c1f0ba1fc72b86a5a68338ef75bc6e8c3dd215ea.js:1)
    at BS (blocks.9050cabd12c43380463b4c70de1321c1b5c9c52e.js:1)
    at AY (blocks.9050cabd12c43380463b4c70de1321c1b5c9c52e.js:1)
    at Object.$init (blocks.9050cabd12c43380463b4c70de1321c1b5c9c52e.js:1)
    at $init (blocks.dd312ccb279428b2ea789b6a1c5dab8df1c3d362.js:1)
    at n (prelude.d7be2bb7257fad35c0261c76fc03aed1a338ee9e.js:1)
    at $runScheduled (prelude.d7be2bb7257fad35c0261c76fc03aed1a338ee9e.js:1)
    at $schedule (prelude.d7be2bb7257fad35c0261c76fc03aed1a338ee9e.js:1)
    at $go (prelude.d7be2bb7257fad35c0261c76fc03aed1a338ee9e.js:1)
    at blocks.a11d29e748302e6e2eb5b63516e8341ff16c1d15.js:1
    at HTMLScriptElement.o [as onreadystatechange] (blocks.a11d29e748302e6e2eb5b63516e8341ff16c1d15.js:1)
dave commented 6 years ago

I'll have to investigate this. As far as I know I haven't changed the actual init code. My bootstrap code runs before the init - gets all the packages loaded and calls the $mainPkg.$init just like GopherJS.