This package has been deprecated

Author message:

no longer maintained

ncompiler
TypeScript icon, indicating that this package has built-in type declarations

1.1.5 • Public • Published

ncompiler

Optimize JavaScript code using Closure Compiler Service API, within CLI, gulp and webpack.

Install

npm install ncompiler -g

--no-optional flag can be added if you do not want to handle character encoding.

npm install ncompiler -g --no-optional

Usage

Command that is provided this package, has several options similar to Java based Closure Compiler application.

ncompiler --output_wrapper_file banner.js --js_output_file out.js lib/**/*.js 1.js 2.js 3.js

For more details, please run command with --help flag.

Use within Your App

You can also use API in this package to get communicate with Closure Compiler Service. To use, install this package locally.

npm install ncompiler

Included sources in this package are both JavaScript and TypeScript.

import { compile, CompilationLevel, IApiOption, IApiResult, IApiFailedResult } from 'ncompiler';

let options: IApiOption = {
  jsCode: 'console.log( "¡hola!" )',
  compilationLevel: CompilationLevel.WhitespaceOnly,
};

compile(options)
  .then(
    (result: IApiResult) => console.log(result.compiledCode),
    (reason: IApiFailedResult) => console.error(reason.message));

Use with Gulp

This package contains plugin for gulp. The plugin is stored in plugins.gulp field. Function of the plugin takes only one optional argument that is same as for compile().

let ncompiler = require('ncompiler');

gulp.task('...', () =>
  gulp
    .src(...)
    .pipe(ncompiler.plugins.gulp())
    .pipe(gulp.dest(...))
);

Use with Webpack

This package contains plugin for webpack. The plugin is stored in plugins.webpack field. Constructor of the plugin takes only one optional argument that is same as for compile().

let ncompiler = require('ncompiler');

module.exports = {
  ...,
  plugins: [
    ...,
    new ncompiler.plugins.webpack(),
  ],
};

Package Sidebar

Install

npm i ncompiler

Weekly Downloads

0

Version

1.1.5

License

BSD-2-Clause

Last publish

Collaborators

  • itokentr