new JS(optionsopt, configFileopt)
JavaScript compilation tools.
Wraps JSCompiler to add static analysis and linting. If you don't want that, use JSCompiler directly.
Example
import {JS} from 'webcompiler';
// or - import {JS} from 'webcompiler/lib/JS';
// or - var JS = require('webcompiler').JS;
// or - var JS = require('webcompiler/lib/JS').JS;
import {join} from 'path';
const srcDir = join(__dirname, 'src'),
  libDir = join(__dirname, 'lib');
const js = new JS();
// compile for the browser
js.fe(join(srcDir, 'script.js'), join(libDir, 'script.js'));
// compile for Node.js
js.be(join(srcDir, 'script.js'), join(libDir, 'script.js'));
// compile entire directories for Node.js (non-JavaScript files are simply copied over)
js.be(srcDir, libDir);Parameters:
| Name | Type | Attributes | Default | Description | 
|---|---|---|---|---|
| options | JSCompilerConfig | <optional> | {} | configuration object | 
| configFile | string | <optional> | "webcompiler/.eslintrc.yaml" | path to the ESLint configuration file | 
Methods
(static) typecheck(callback)
Performs static analysis
Parameters:
| Name | Type | Description | 
|---|---|---|
| callback | function | a callback function, invoked only when successfully typechecked | 
be(inPath, outPath, lintPathsopt, callbackopt)
Wraps JSCompiler#be to add static analysis and linting.
If inPath is a directory, outPath has to be also.
Parameters:
| Name | Type | Attributes | Default | Description | 
|---|---|---|---|---|
| inPath | string | the input file/directory path | ||
| outPath | string | the output file/directory path | ||
| lintPaths | Array.<string> | <optional> | [] | an array of paths to files/directories to lint | 
| callback | function | <optional> | function () {} | a callback function | 
fe(inPath, outPath, lintPathsopt, callbackopt)
Wraps JSCompiler#fe to add static analysis and linting
Parameters:
| Name | Type | Attributes | Default | Description | 
|---|---|---|---|---|
| inPath | string | the input file path | ||
| outPath | string | the output file path | ||
| lintPaths | Array.<string> | <optional> | [] | an array of paths to files/directories to lint | 
| callback | function | <optional> | function () {} | a callback function | 
lint(paths, callback)
Performs linting
Parameters:
| Name | Type | Description | 
|---|---|---|
| paths | Array.<string> | an array of paths to files/directories to lint | 
| callback | function | a callback function, invoked only when successfully linted |