Search code examples
javascriptbuild-processgoogle-closure-compilercommonjs

Can Closure Compiler build CommonJS modules


I would like to use Google Closure Compiler to build a set of CommonJS modules. Can this be done out of the box? Alternatively, is there some simple transformation that can be done to the CommonJS modules to allow them to be consumed by Closure Compiler?


Solution

  • Support has been added to Closure Compiler to make it is easier to work with Common JS and AMD/require.js modules using the following compiler flags:

    • --transform_amd_modules
    • --process_common_js_modules
    • --common_js_entry_module
    • --common_js_module_path_prefix

    See Experimental support for Common JS and AMD/require.js modules in Closure Compiler