I am currently working on a npm project and trying to ensure it is browser-compatible with browserify. One of the dependencies in this project is underscore. In order to build the project using browserify without including underscore in the final file, I have configured my grunt settings as follows:
options: {
exclude: {
'underscore'
}
}
By implementing this configuration, I have managed to reduce the size of the destination file (approximately the size of underscore). However, after attempting to run the project in a browser, I encountered the following error:
Uncaught Error: Cannot find module 'underscore'
It's worth noting that I received this error even when I had already included underscore
before incorporating my project (using a <script>
tag).
Does anyone know how I can instruct browserify to recognize that underscore will be loaded externally by myself?