tunapanda / h5p-standalone

Display H5P content without the need for an H5P server
MIT License
272 stars 117 forks source link

Interactive Book type: Javascript error - only one instance of babel-polyfill is allowed #52

Closed mikedawson closed 2 years ago

mikedawson commented 4 years ago

Hi,

I've been using h5p-standalone to run H5P's offline and it's really great for that! Unfortunately a small minority of files, in particular interactive book, seem to have a javascript conflict. If you try the interactive book example from the h5p.org website, you will get the following Javascript error on both Chrome and Firefox:

Uncaught Error: only one instance of babel-polyfill is allowed
    at Object.<anonymous> (h5p-interactive-book.js:1)
    at Object.<anonymous> (h5p-interactive-book.js:1)
    at n (h5p-interactive-book.js:1)
    at Module.<anonymous> (h5p-interactive-book.js:10)
    at n (h5p-interactive-book.js:1)
    at h5p-interactive-book.js:1
    at h5p-interactive-book.js:1
h5p-interactive-book.js:10 Uncaught TypeError: Cannot read property 'title' of undefined
    at new e (h5p-interactive-book.js:10)
    at Object.i.newRunnable (frame.bundle.js:3)
    at HTMLDivElement.<anonymous> (frame.bundle.js:3)
    at Function.each (frame.bundle.js:3)
    at init.each (frame.bundle.js:3)
    at Object.i.init (frame.bundle.js:3)
    at HTMLDocument.<anonymous> (frame.bundle.js:3)
    at u (frame.bundle.js:3)
    at Object.fireWith [as resolveWith] (frame.bundle.js:3)
    at Function.ready (frame.bundle.js:3)

I'm not a Javascript expert, but it seems like babel-polyfill has been used in both h5p-standalone and in the above h5p content type. Babel-polyfill states that it should not be used in libraries for this reason.

Does anyone have any idea where babel-polyfill is being used in h5p-standalone? I am willing to prepare a pull request to deal with this. I think babel-polyfill should either be removed as a dependency (as it is already being used by H5P where needed) or there should be some kind of option for it.

mikedawson commented 4 years ago

H5P Standalone is not including or using babel-polyfill. The problem is that somehow H5PStandalone has decided to load the interactive book Javascript twice (which uses babel-polyfill, which then causes the error):

main

contrerasjose commented 3 years ago

Hi, still not solved? Thanks for your comments

elmitxel commented 3 years ago

this problem is not solved yet, right? Thanks for your comments

AnimMouse commented 3 years ago

Any news for this?

0xMurage commented 3 years ago

Any news for this?

@busgurlu is already doing some great work that will fix the issue here #94

bryandonmarc commented 2 years ago

Seems this issue hasn't been resolved yet. I went ahead and tried building https://github.com/tunapanda/h5p-standalone/pull/102, but there was an error. Fixed it in https://github.com/tunapanda/h5p-standalone/pull/105.

Building this, then copying the output of the dist folder and using it directly makes it work perfectly.

github-actions[bot] commented 2 years ago

:tada: This issue has been resolved in version 3.4.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket: