Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module Code Splitting (--chunk / --module flag) #61

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

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