notebookjs icon indicating copy to clipboard operation
notebookjs copied to clipboard

Please remove dependency on this being defined.

Open kurmasz opened this issue 1 year ago • 2 comments

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.)

kurmasz avatar May 21 '24 16:05 kurmasz

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?

jsvine avatar May 28 '24 20:05 jsvine

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

kurmasz avatar May 29 '24 15:05 kurmasz

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

jsvine avatar Aug 18 '24 23:08 jsvine