richgilbank/Scratch-JS

Check for _babelPolyfill first

r-murphy opened this issue · 3 comments

Would it be possible to see if window._babelPolyfill is set before loading the babel polyfill? I use babel polyfill in my own site and then when I switch to Scratch JS, babel polyfill rejects with an exception and devtools jumps over to debugger mode and stops at a couple exception breakpoints. Also I get an error popup, but that's coming from my own app when in debug mode.

It only happens the first time I use Scratch JS in that tab.

Thanks

Oooh, good call. That makes sense, right now I believe it's just stomping on any existing version. Should be a fairly simple fix. I'll try to take a look in a bit, but in the meanwhile, this would be a good first bug for anyone interested in contributing!

I took a shot at solving this. It's my first time developing on an extension so I'm not sure what's possible exactly. I added to the existing script insert condition. It would only support a one-liner rather than more complex logic, but it does the job. Let me know what you think.

I also found that the babel-polyfill npm dependency was missing so I added that and updated the path (it's no longer in babel-core).

Unrelated, I fixed the gulpfile in a separate commit. The del module returns a Promise now and doesn't seem to support the callback API anymore. Luckily gulp has Promise support.

Nice! Mind opening PRs for those commits? I just added babel-polyfill to the project to fix another bug, so the conditional script insertion commit may have to be rebased. Thanks!