I think I have a solution ! Well, I have another problem afterwards, but at least now I can import BokehJS into my angular app.
Turns out my application was using an old version of Angular. I created a new prototype from scratch, using the latest version Angular 10, and this prototype can import Bokeh just fine with the following statement in a .ts component file : import * as Bokeh from "@bokeh/bokehjs"
However, when I’m attempting to actually make use of the library, I encounter the following issue :
My code snippet :
var item = JSON.parse('[...a JSON string exported from python via bokeh.embed.json_item()...]');
Bokeh.embed.embed_item(item, "bokeh-plot");
And the error message:
Failed to compile.
./node_modules/@bokeh/bokehjs/build/js/lib/index.js 3:9
Module parse failed: Unexpected token (3:9)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| export { version } from "./version";
| export { index } from "./embed";
> export * as embed from "./embed";
| export * as protocol from "./protocol";
| export * as _testing from "./testing";
I have found a reference to this issue here (the first method described in the opening post). However I do not understand the proposed solution, and how to implement it with Angular. It seems that Babel is not an issue with Angular, according to this: angular5 - Is Babel being used as compiler (AOT or JIT) in angular 5 - Stack Overflow
I see that @mateusz was very helpful in this other topic: if you could give me a few pointers regarding this issue with angular, it would help me tremendously.