I’m trying to implement PWA push notifications and I’m having an issue with the only thing I thought I would have an issue with.
I’m running a js script at the beginning of one of my views and it’s failing because const webpush = require('web-push'); cant find the module web-push. I know that I can add it with @JsModule but for that, as far as I know you need to have the file locally, I want that dependency to be downloaded with the rest of the js dependencies of the project, when Vaadin does a NPM install, how I set that up?
You can use the @NpmPackage annotation to make Vaadin fetch additional packages from the npm registry during the regular installation process. Alternatively, you can also do it the regular JS developer way, i.e. running npm install web-push since Vaadin also honors your regular package.json contents. The main difference is if you’re creating an add-on, since the @NpmPackage annotation will make it install automatically for anyone who adds the add-on to their Java classpath.