Hi, I am using node:12 and importing bokehjs 2.0 into my js bundle. This gives me the following error:
zuifrontend_1 | Failed to compile.
zuifrontend_1 |
zuifrontend_1 | ./node_modules/@bokeh/bokehjs/build/js/lib/index.js 3:9
zuifrontend_1 | Module parse failed: Unexpected token (3:9)
zuifrontend_1 | File was processed with these loaders:
zuifrontend_1 | * ./node_modules/babel-loader/lib/index.js
zuifrontend_1 | You may need an additional loader to handle the result of these loaders.
zuifrontend_1 | | export { version } from "./version";
zuifrontend_1 | | export { index } from "./embed";
zuifrontend_1 | > export * as embed from "./embed";
zuifrontend_1 | | export * as protocol from "./protocol";
zuifrontend_1 | | export * as _testing from "./testing";
I should mention that the node setup was made using create-react-app with typescript template.
tsconfig.json:
Iām not an expert here, so I can give just some hints. IIRC the BokehJS NPM bundle contains ESM modules, and, just as the error says, you may need some additional loader to enable ESM modules compilation in your project.
Likely. Or maybe just some flag in tsconfig.json. Or maybe you will have to eject the app to be able to work with BokehJS. I think there was some other solution, but canāt find it right away. I will post it once a friend that has it sends it to me.
Sorry for the false hope - I was wrong. That solution was only to be able to run some specific test runner. And his tsconfig is virtually the same as yours. No idea what to do next. @mateusz should know more.
Right okā¦i think i will opt for the eject unfortunately
I think i can just run bokeh through babel after having ejected and it should workā¦but its a pity that i had to eject. I hope this will get fixed either by bokeh or CRA.
The solution the problem is available in its statement:
File was processed with these loaders:
zuifrontend_1 | * ./node_modules/babel-loader/lib/index.js
zuifrontend_1 | You may need an additional loader to handle the result of these loaders.
Module parse failed: Unexpected token (3:9)
export * as embed from ā./embedā;
The problem is not with node (12.x or whichever), because bokehjs is not a node library, but itās web browser library. So bokehjsā code is not run in node at any point in time, itās just being processed by node libraries like babel-loader, which apparently doesnāt recognize this pretty new ES export star syntax. You will need to consult babelās documentation to resolve this. However, assuming that they already added support for this syntax and released a new version of the offending libraries, then fixing this should simply require updating your development setup to the most recent version of babelās toolchain.
and unfortunately this does not resolve the issue, the building process now is passing but when trying on local with 2.1.1 version, no graph is showing up: