Skip to content
This repository was archived by the owner on Jun 14, 2024. It is now read-only.

Commit 322a71f

Browse files
committed
Update README.md with flags, cleanup page
1 parent 9371523 commit 322a71f

File tree

1 file changed

+39
-21
lines changed

1 file changed

+39
-21
lines changed

README.md

Lines changed: 39 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ First, install the latest version-
1818
npm install --save google-closure-compiler-js
1919
```
2020

21-
### Native Node Usage
22-
23-
The module provides `compile` as a low-level method to compile JavaScript.
21+
The module supports modern web browsers as well as Node v4 LTS, and provides `compile` as a low-level method to compile JavaScript.
2422
By default, this compiles ES6 to ES5 and includes the default set of ECMAScript externs files.
2523
For example-
2624

@@ -34,9 +32,9 @@ const out = compile(flags);
3432
console.info(out.compiledCode); // will print 'var x = 3;\n'
3533
```
3634

37-
### Build Systems
35+
## Build Systems
3836

39-
#### Webpack
37+
### Webpack
4038

4139
Your `webpack.config.js` should look like this-
4240

@@ -65,7 +63,7 @@ module.exports = {
6563
};
6664
```
6765

68-
#### Gulp
66+
### Gulp
6967

7068
Your `gulpfile.js` should contain a task like this-
7169

@@ -86,21 +84,41 @@ gulp.task('script', function() {
8684
});
8785
```
8886

89-
As of release v20160822, commonJS imports may be broken: we recommend that you compile a single file only (e.g. via Browserify or other tools), or use ES6 imports.
90-
91-
### Flags
92-
93-
The Closure Compiler in JS supports many of the flags supported by the Java-based Closure Compiler.
94-
For now, the supported flags are [listed in source](https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/gwt/client/GwtRunner.java#L93).
95-
Specify these flags as `camelCase` format, and not like `camel_case` or `--camel_case`.
96-
97-
Notably, unless you're using a build system, you have to specify code via flags.
98-
Both `jsCode` and `externs` accept an array containing objects with `src`, `path`, and `sourceMap` properties.
99-
For those of you familiar with [Closure syntax](https://developers.google.com/closure/compiler/docs/js-for-compiler), that's `Array<{src: string, path: string, sourceMap: string}>`.
100-
101-
<!--
102-
Using `path`, you can construct a virtual filesystem for use with ES6 imports or CommonJS imports (although don't forget to specify `processCommonJsModules: true`).
103-
-->
87+
## Flags
88+
89+
| Flag | Default | Usage |
90+
|----------------------------------|---------|-------|
91+
| angularPass | false | Generate $inject properties for AngularJS for functions annotated with @ngInject |
92+
| assumeFunctionWrapper | false | Enable additional optimizations based on the assumption that the output will be wrapped with a function wrapper. This flag is used to indicate that "global" declarations will not actually be global but instead isolated to the compilation unit. This enables additional optimizations. |
93+
| checksOnly | false | Don't generate output. Run checks, but no optimization passes. |
94+
| compilationLevel | SIMPLE | Specifies the compilation level to use.<br /> Options: WHITESPACE_ONLY, SIMPLE, ADVANCED |
95+
| dartPass | false | |
96+
| env | BROWSER | Determines the set of builtin externs to load.<br /> Options: BROWSER, CUSTOM |
97+
| exportLocalPropertyDefinitions | false | |
98+
| generateExports | false | Generates export code for those marked with @export. |
99+
| languageIn | ES6 | Sets what language spec that input sources conform to. |
100+
| languageOut | ES5 | Sets what language spec the output should conform to. |
101+
| newTypeInf | false | Checks for type errors using the new type inference algorithm. |
102+
| polymerPass | false | Rewrite Polymer classes to be compiler-friendly. |
103+
| preserveTypeAnnotations | false | |
104+
| processCommonJsModules | false | Process CommonJS modules to a concatenable form, i.e., support `require` statements. |
105+
| renamePrefixNamespace | | Specifies the name of an object that will be used to store all non-extern globals. |
106+
| rewritePolyfills | false | Rewrite ES6 library calls to use polyfills provided by the compiler's runtime. |
107+
| useTypesForOptimization | false | Enable or disable the optimizations based on available type information. Inaccurate type annotations may result in incorrect results. |
108+
| warningLevel | DEFAULT | Specifies the warning level to use.<br /> Options: QUIET, DEFAULT, VERBOSE |
109+
| jsCode | [] | Specifies the source code to compile. |
110+
| externs | [] | Additional externs to use for this compile. |
111+
| createSourceMap | false | Generates a source map mapping the generated source file back to its original sources. |
112+
113+
### Languages
114+
115+
The Closure Compiler supports languages `ECMASCRIPT3`, `ECMASCRIPT5`, `ECMASCRIPT5_STRICT` for input and output, `ECMASCRIPT6`, `ECMASCRIPT6_STRICT` for input only, and `ECMASCRIPT6_TYPED` (experimental) for both.
116+
117+
### Source Code
118+
119+
Unless you're using the Gulp or Webpack plugins, you'll need to specify code via flags.
120+
Both `jsCode` and `externs` accept an array containing objects in the form `{src, path, sourceMap}`.
121+
Using `path`, you can construct a virtual filesystem for use with ES6 or CommonJS imports&mdash;although for CommonJS, be sure to set `processCommonJsModules: true`.
104122

105123
## License
106124

0 commit comments

Comments
 (0)