It\'s already possible to convert commonjs modules to requirejs, but I still want to know whether it\'s possible to do the reverse. Is there any way to convert requireJS modules
Yes its possible if you use uRequire, a tool I wrote specifically for javascript module format conversion - AMD/Requirejs --> commonjs/nodejs and back (plus more).
It seems as a trivial AST manipulation & dependencies resolution @ start, but module formats are incompatible in many ways apart from syntax:
dependency/path resolution : commonjs uses fileRelative (eg '../PersonModel') whereas AMD can also use package-relative (eg 'Models/PersonModel')
execution environment: commonJs modules are loaded synchronously, whereas AMD are loaded asynchronously (AMD also has the asynchronous require
version require(['dep1', dep2'], function(dep1, dep2){})
as its targeted mainly for the browser).
These are also other differences (eg AMD loader plugins) but in general writing against each one 'locks' you in that format. .
uRequire enables you to author in AMD or commonJS and convert to the other easily (or convert to UMD), hence enjoying modular Javascript without the boilerplate.