-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Is it possible to use Closure compiler to produce a standalone CommonJS module, for use by dependent external (not managed by the compiler) JS code? That is, to produce a single file that exports its public symbols via CommonJS special exports variable?
The problem I'm running into is that:
- with
--process_common_js_modules, the compiler renamesexportstomodule$path$to$source, making it impossible to import the compiled source as a CommonJS module - without
--process_common_js_modules, the compiler does not resolve CommonJSrequireimports, so other CommonJS modules can't be used as the target module's building blocks.
I believe I understand the motivation for renaming exports (prevent name clashes between multiple CommonJS modules concatenated in the single compiled file), but this is not enough if the compiled file is meant to be imported by some other code. Ideally, the exports variable would not be renamed in the top-level module that defines the module's public symbols (it still needs to be renamed, as is already the case, in implementation modules the top-level module imports itself).