First of all, points for adding a decent code example.
The problem is easy to solve actually.
Simply change:
var utilsObject = require('./js/bundle/utils.js');
to:
var utilsObject = require('./utils');
Now the build tool and the app will work.
By adding a .js
suffix you were bypassing the baseUrl
rules that RequireJS applies to module paths. From the docs:
RequireJS also assumes by default that all dependencies are scripts, so it does not expect to see a trailing ".js" suffix on module IDs.
There may be times when you do want to reference a script directly and not conform to the "baseUrl + paths" rules for finding it. If a module ID has one of the following characteristics, the ID will not be passed through the "baseUrl + paths" configuration, and just be treated like a regular URL that is relative to the document:
- Ends in ".js".
- Starts with a "/".
- Contains an URL protocol, like "http:" or "https:".