jsvine / notebookjs

Render Jupyter/IPython notebooks on the fly, in the browser. (Or on the command line, if you'd like.)
MIT License
274 stars 48 forks source link

Please remove dependency on this being defined. #54

Closed kurmasz closed 1 month ago

kurmasz commented 4 months ago

Please remove the dependency on this being defined. Doing so will allow notebookjs to be use with import in addition to require.

Here is the problem: If I want to use notebookjs client-side in an enviroment that uses import instead of require, the import statement fails when it reaches line 6, because this (and therefore root) are undefined.

var root = this;
var isBrowser = root.window !== undefined;

(Changing line 5 to var root = this || globalThis addresses my issue; but, I don't know enough about different JavaScript module systems to say that this solution is robust or complete.)

jsvine commented 4 months ago

Thank you. Can you share a minimal script that reproduces the error you see, so that I can take it into account while reviewing the proposed change?

kurmasz commented 4 months ago

This repo both demonstrates the error and demonstrates how I intend to use the modified package: https://github.com/kurmasz/notebookjs_mre

jsvine commented 1 month ago

Thanks again, and apologies again for the delay in responding/merging. Let me know if you encounter issues even after the merge of #55.