NPM works if the Maven module supplies JavaScript that will undergo transpilation / minimization / concatenation. If sharing pre-compiled modules is required, I successfully use web-fragment.xml (defined in Servlet 3.0 specifications) and set my JavaScript, etc. under META-INF / resources. Depending on your front end technology, you will need to use some approach related to code splitting or web components.
In fact, the client side will have to download and execute its library code before starting everything that depends on it.
If you have a small (-ish) library with a specific API that you want to share between your Maven modules, and all this is part of the same ecosystem, npm publish and npm link is the way to go. For larger blocks of functionality, especially those that have specific usage profiles (for example, the user profile editor or configuration page - are not used every time), they can be dynamically loaded).
While there is nothing new in this, this area (POM, JARs, NPM and JS / ES6 modules) seems to be in search of the best approach, and it will take some time to plunge into a couple of reliable technicians. I donβt know clean, absolutely no means of support, a set of rules and settings to cope with this.
source share