How should I configure multiple paths for require?
I have the following structure:
application
|-server
| |-main.js
| |-myClass.js
| |-myClass.js
| |-implementationClass.js
|-common
| |-myOtherClass.js
| |-anotherClass.js
| |-yetAnotherClass.js
|-client
| |-aClientClass.js
| |-anotherClientClass.js
| |-implementationClass.js
I want to be able to do something like this:
require('myClass');
require('myOtherClass');
How should I configure the multiple paths?
currently using require.paths gives me an error : Error: require.paths is removed.
I want to keep this structure as my application has to serve static .js files from shared and I want to avoid sharing server-side .js files.
Also the files use a require() function on the client which emulates the node.js require() and I don't want to use relative paths.
the catch is that when I call require('anotherClass') it has to work on the client and on the server. So using relative paths could work but I also have the require('implementationClass') which returns either the client implementation or the server implementation, and when they are called from the common classes this approach will fail.