google/closure-compiler

Add an Option To Prevent Rewriting Import/Require Statements for Specific Modules

Open

#1382 opened on Jan 10, 2016

View on GitHub
 (10 comments) (5 reactions) (0 assignees)Java (7,176 stars) (1,197 forks)batch import
help wanted

Description

When working with module systems, there needs to be some way to designate that certain import statements are intended to be runtime imports rather than compile time. This will only apply to CommonJS modules currently until such a time as the compiler recognizes and rewrites the WhatWG Loader Import Statements. See

The consensus around this discussion seems to be that this should be a flag, rather than an annotation.

The flag should meet the following criteria:

  • The same flag should work for ES6 and CommonJS modules
  • It MUST take into account all of the following cases:
    • The --module flags are used and thus both the import and export statements are provided to the compiler as input but divided into separate outputs for runtime loading
    • The export statement is not provided to the compiler and is therefore external code. This covers core NodeJS module imports.

Contributor guide