Skip to content

Conversation

@optimalisatie
Copy link

Closure Compiler can split the output of a compilation into multiple files to support dynamic loading. This process uses the --chunk flag (before June 2018 it was named --module). See how do I split my javascript into modules

GCC Modules can be stitched together without a module loading logic enabling to achieve optimal compression and optimization with the ability to load modules selectively.

Source: https://github.com/google/closure-compiler/wiki/JS-Modules#code-splitting-output-modules

grunt.initConfig({
  'closure-compiler': {
    frontend: {
      closurePath: '/src/to/closure-compiler',
      modules: {
        "module-name": {
          src: ['js/source.js', 'js/other-source.js']
        },
        "extra-module": {
          src: ['js/extra-module.js'],
          dep: ['module-name']
        }
      },
      moduleOutputPath: 'static/js/',
      maxBuffer: 500,
      options: {
        compilation_level: 'ADVANCED_OPTIMIZATIONS',
        language_in: 'ECMASCRIPT5_STRICT'
      }
    }
  }
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant