This achieves consistency with the require calls used throughout the
source code.
This also makes it easier to use the modules with RequireJS.
One way to use RequireJS with CommonJS-style modules is by wrapping
them inside an AMD-style wrapper. The CommonJS Loader Plugin for
RequireJS (https://github.com/guybedford/cjs) does this.
However, RequireJS automatically appends ".js" to the module path,
which means a call such as "require('../messagehandler.js')" makes
RequireJS look for the file "../messagehandler.js.js", which is
clearly invalid. The simplest solution is to avoid the ".js"
altogether, which makes the path compatible with both Browserify and
RequireJS. The CJS plugin takes care of the rest.
neelabhg/sysbuild@8f1764c3d5f95d5d9e1f582c7b2c10b9bcea17bb details the
motivation for supporting RequireJS.
This achieves consistency with the require calls used throughout the source code.
This also makes it easier to use the modules with RequireJS. One way to use RequireJS with CommonJS-style modules is by wrapping them inside an AMD-style wrapper. The CommonJS Loader Plugin for RequireJS (https://github.com/guybedford/cjs) does this.
However, RequireJS automatically appends ".js" to the module path, which means a call such as "require('../messagehandler.js')" makes RequireJS look for the file "../messagehandler.js.js", which is clearly invalid. The simplest solution is to avoid the ".js" altogether, which makes the path compatible with both Browserify and RequireJS. The CJS plugin takes care of the rest.
neelabhg/sysbuild@8f1764c3d5f95d5d9e1f582c7b2c10b9bcea17bb details the motivation for supporting RequireJS.