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

Conditional compilation API via @define #26

Open
theseanl opened this issue Jul 23, 2019 · 1 comment
Open

Conditional compilation API via @define #26

theseanl opened this issue Jul 23, 2019 · 1 comment
Labels
enhancement New feature or request

Comments

@theseanl
Copy link
Owner

theseanl commented Jul 23, 2019

@define in Closure compiler is like environment variables in other build tools. It is a common practice for webpack or rollup to access environment variables in source code (process.env.NODE_ENV), so that the build tool replaces such expressions to a constant, and later a javascript minifier removes unvisited code blocks.
In closure compiler, such a functionality is achieved via @define JsDoc annotation. Can we provide a uniform API for conditional compilation that uses @define at closure compiler’s side and some custom plugin for rollup’s side?

Currently there are some caveats of using @define in goog.module scopes, angular/tsickle#434. Since we control closure compiler flags as well, I think it would be possible to implement an easy API.

@theseanl
Copy link
Owner Author

theseanl commented Jul 27, 2019

google/closure-compiler#1601 (comment)

  1. We could wait for the issue to be fixed (closure compiler implementing @defines without closure library)
  2. or we could rewrite @defines to goog.define with ts transformer.

@theseanl theseanl changed the title Env variable support via module-level @define for closure compiler API for module-level @define Aug 12, 2019
@theseanl theseanl changed the title API for module-level @define Conditional compilation API for using @define Aug 12, 2019
@theseanl theseanl changed the title Conditional compilation API for using @define Conditional compilation API via @define Aug 12, 2019
@theseanl theseanl added the enhancement New feature or request label Sep 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant