You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 14, 2024. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+72-9Lines changed: 72 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,37 +7,100 @@ Any bugs not related to the plugins themselves should be reported to the [main r
7
7
8
8
Unlike other packages, this allows Closure Compiler to run entirely in JS.
9
9
*Java is not required.*
10
-
However, this has a few tradeoffs- some features are not available and performance is not on-par with the Java implementation.
10
+
11
+
This is an experimental release- some features are not available and performance may not be on-par with the Java implementation.
11
12
12
13
## Usage
13
14
14
-
### Installation
15
+
First, install the latest version-
15
16
16
17
```bash
17
18
npm install --save google-closure-compiler-js
18
19
```
19
20
20
-
### Grunt/Gulp
21
-
22
-
As of July 2016, neither a Grunt Task nor a Gulp Plugin is available.
23
-
Contributions are welcome.
24
-
25
21
### Native Node Usage
26
22
27
23
The module provides `compile` as a low-level method to compile JavaScript.
28
24
By default, this compiles ES6 to ES5 and includes the default set of ECMAScript externs files.
29
-
For now, the flags are [listed in source](https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/gwt/client/GwtRunner.java#L73).
jsOutputFile:'output.min.js', // outputs single file
83
+
createSourceMap:true,
84
+
}))
85
+
.pipe(gulp.dest('./dist'));
86
+
});
87
+
```
88
+
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
+
96
+
Notably, unless you're using a build system, you have to specify code via flags.
97
+
Both `jsCode` and `externs` accept an array containing objects with `src`, `path`, and `sourceMap` properties.
98
+
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}`.
99
+
100
+
<!--
101
+
Using `path`, you can construct a virtual filesystem for use with ES6 imports or CommonJS imports (although don't forget to specify `processCommonJsModules: true`).
0 commit comments