google/closure-compiler
View on GitHubAdd an Option To Prevent Rewriting Import/Require Statements for Specific Modules
Open
#1382 opened on Jan 10, 2016
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
- https://groups.google.com/forum/#!searchin/closure-compiler-discuss/externalRequire/closure-compiler-discuss/4SpP-o7HKBk/h6NYu1eMIcMJ
- https://gist.github.com/Kegsay/2cb999a78dbd2b8bda95
- #1380
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
--moduleflags 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.
- The