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

Native ES6 Module support #25

Closed sparanoid closed 3 years ago

sparanoid commented 5 years ago

I tried to import this library with a React application:

import nb from "notebookjs"

...but got the following errors:

Compiled with warnings.

./node_modules/notebookjs/notebook.js
Critical dependency: the request of a dependency is an expression

I think the problem is the whole script is wrapped inside an IIFE. That would work if this script can be packaged with Webpack or Rollup.

jsvine commented 5 years ago

Thanks for raising this issue @sparanoid. Ideally, I'd like to avoid adding a dependency, such as Webpack or Rollup, to this project. Unfortunately, I haven't followed ES6 closely. Can you think of another way of modifying notebookjs to fix your problem without adding a dependency?

jsvine commented 3 years ago

The source of the problem appears to have been the use of dynamic require statements in condRequire(...), which Webpack does not like: https://github.com/webpack/webpack/issues/196

The commit above should resolve this, now reflected in notebookjs v0.6.2. Closing for now, but feel free to reopen if the issue persists.