How to import JavaScript files (fabric.js) in a vaadin Application

Viewed 36

I'm working on a Vaadin application which is using spring boot. I want to use the fabric.js framework, but have not managed to import the files without running into Errors yet.

When trying to use the @JavaScript Annotation, I run into following Error:

[v-server-output] c.v.b.devserver.DevServerOutputTracker : ERROR in ./fabric.min.js

[v-server-output] c.v.b.devserver.DevServerOutputTracker : Module not found: Error: Can't resolve 'jsdom' in 'C:\entwicklung\grw2_new\app-and-run\applications\grw\grw-desktop\frontend'

After trying it with a npm installation(https://vaadin.com/directory/component/niiyeboahfabric-canvas), I ran into a similar Error:

[ERROR] ERROR in ../node_modules/tunnel-agent/index.js

[ERROR] Module not found: Error: Can't resolve 'net' in '/.../node_modules/tunnel-agent' ... [ERROR] @ ../node_modules/jsdom/lib/api.js

[ERROR] @ ./fabric.min.js

To avoid the jsdom Error I tried to import the file in a onAttach Method using UI.getCurrent().getPage().addJavaScript("frontend/fabric.min.js"); But Vaadin does not manage to find the specified file, whether I put them in the frontend folder of my project or in META-INF/resources/frontend.

0 Answers
Related