AnsweredAssumed Answered

Using NPM in a Share widget; Ignoring node_modules

Question asked by emlync on Apr 12, 2016
I am currently attempting to use npm, the nodeJS package manager, to manage and install various javascript libraries that I'm using for a Share widget. It works by defining a package.json and using the cli program to install various javascript files, can also acts as a build system to bundle a javascript application before putting it in a share widget.

However Maven chokes when you attempt to build and run the project (
mvn clean install -Prun
). The problem is that the
attempts to move and minify (using the YUI compressor) all of the Javascript code in node_modules, FYI this was discovered by running
mvn -X install
and observing the following:

[DEBUG] file terminal-notifier has a filtered file extension
[DEBUG] filtering ../node_modules/node-notifier/vendor/ to ../target/amp/web/js/rubble-workflow/dashlets/widgets/node_modules/node-notifier/vendor/

It is rectified by moving the node_modules folder out of src tree.

It is possible to to get maven to ignore a file by it's file extension by using the
block in maven-resources-plugin and setting a
. However, this doesn't help for files that don't have a file extension, like the code above.

Another method would be to use the <excludes> element in the <build> section of the Share pom file and I've tried this:


However, this leads to:

[INFO] Installing /Users/emlyn/Documents/Rubble/Repo/rubble-workflow/alfresco-aio/rubble-workflow/rubble-workflow-share/target/rubble-workflow-share-1.0-SNAPSHOT.amp into /Users/emlyn/Documents/Rubble/Repo/rubble-workflow/alfresco-aio/rubble-workflow/share/target/share-1.0-SNAPSHOT
de.schlichtherle.truezip.fs.FsEntryNotFoundException: amp:file:/Users/emlyn/Documents/Rubble/Repo/rubble-workflow/alfresco-aio/rubble-workflow/rubble-workflow-share/target/rubble-workflow-share-1.0-SNAPSHOT.amp!/ (no such entry)

i.e. a broken amp file because is missing from the AMP.

Has anyone attempted this before? Any here know how to exclude a whole directory within the src/main/amp and not break the AMP?