You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've encountered an issue with the .mjs file type while using mdbook quiz. When I open a page containing the quiz and test it through a server I get the following errors in different browsers:
Firefox:
Loading the module from https://xxx/mdbook/quiz/quiz-embed.mjs was blocked due to a disallowed MIME type.
Microsoft Edge:
Failed to load module script: Expected a JavaScript module script, but the server responded with a MIME type of "". Strict MIME type checking is enforced for module scripts per HTML spec.
To resolve this issue the server must serve the .mjs file appropriately. However, when you don't have control over the server or are publishing files for public use, this can lead to problems (as I am here). Some tools may also not support the .mjs extension.
A workaround to make the quiz-embed.mjs module work is to append .js to the end of .mjs files, like quiz-embed.mjs.js. This is accepted but it requires manual replacement of all artifacts in the generated code.
Is there a reason for using the .mjs file extension?
If it was for module clarity, preferred over .js, one could use .mjs during development and convert to .js during the build step. However, ensure that changing to a .js file does not introduce additional issues. Currently this workaround is working for me without any issues.
The text was updated successfully, but these errors were encountered:
There's not a particular reason -- it should be an IIFE target anyway with a .js extension. I will merge #41 and make a release soon that should fix this for you.
I've encountered an issue with the
.mjs
file type while using mdbook quiz. When I open a page containing the quiz and test it through a server I get the following errors in different browsers:Firefox:
Microsoft Edge:
To resolve this issue the server must serve the
.mjs
file appropriately. However, when you don't have control over the server or are publishing files for public use, this can lead to problems (as I am here). Some tools may also not support the.mjs
extension.A workaround to make the
quiz-embed.mjs
module work is to append.js
to the end of.mjs
files, likequiz-embed.mjs.js
. This is accepted but it requires manual replacement of all artifacts in the generated code.Is there a reason for using the
.mjs
file extension?If it was for module clarity, preferred over
.js
, one could use.mjs
during development and convert to.js
during the build step. However, ensure that changing to a.js
file does not introduce additional issues. Currently this workaround is working for me without any issues.The text was updated successfully, but these errors were encountered: