s-macke / jor1k

Online OR1K Emulator running Linux
http://jor1k.com
BSD 2-Clause "Simplified" License
1.73k stars 196 forks source link

Remove ".js" from module paths in require calls #110

Closed neelabhg closed 8 years ago

neelabhg commented 8 years ago

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.

s-macke commented 8 years ago

Thanks. That's an easy fix.

neelabhg commented 8 years ago

Great! Thank you!