Giter VIP home page Giter VIP logo

closurify's Introduction

Closurify

build status

Transform your amd modules to closure compiler dependency syntax. Relies on amd-to-closure.

Install

npm install closurify

Usage

var closurify = require('closurify');

gulp.src('src/**/*.js')
    .pipe(closurify({baseUrl: "./"}))
    .pipe(gulp.dest('./build'));

// If you want to write dependencies as well
var closureDeps = require('gulp-closure-deps'),
gulp.src(['src/**/*.js'])
    .pipe(closurify({baseUrl: './'}))
    .pipe(gulp.dest('./build'))
    .pipe(closureDeps({
        fileName: 'deps.js',
        prefix: '../../../'
    }))
    .pipe(gulp.dest('./build'));

Use gulp-closure-deps to create dependencies file;

Example with different namespaces:

gulp.task('transform', function() {
    gulp.src(['src/**/*.js'])
        .pipe(closurify({baseUrl: './', namespace: 'project'}))
        .pipe(gulp.dest('./build'))
        .pipe(closureDeps({
            fileName: 'deps.js',
            prefix: '../../../'
        }))
        .pipe(gulp.dest('./build'));

    gulp.src(['other-project/src/**/*.js'])
        .pipe(closurify({baseUrl: './', namespace: 'otherProject'}))
        .pipe(gulp.dest('./build/other-project'))
        .pipe(closureDeps({
            fileName: 'deps.js',
            prefix: '../../../'
        }))
        .pipe(gulp.dest('./build/other-project'));
});

options.baseUrl

Base url for module naming

Type: String Default: "./"

options.namespace

Prefix all modules with this namespace

Type: String Default: `` Example:

    gulp.src(['src/**/*.js'])
        .pipe(closurify({baseUrl: './', namespace: 'project'}));

    // module-a.js
    define(function() {
        return 'module-a';
    });


    // After closurify
    goog.provide('project.module_a$$');
    project.module_a$$ = 'module-a';

options.foreignLibs

Do not resolve paths for some modules

Type: Array Default: `` Example:

    gulp.src(['src/**/*.js'])
        .pipe(closurify({baseUrl: './', foreignLibs: ['proj2'], namespace: ['proj1']}));

    // module-a.js
    define(["module-b", "proj2/module-b"]function(ModuleB, OtherModuleB) {
        return 'module-a';
    });


    // After closurify
    goog.provide('proj1.module_a$$');
    goog.require('proj1.module_b$$');
    goog.require('proj2.module_b$$');
    proj1.module_a$$ = 'module-a';

    // Without foreignLibs option you would get
    goog.provide('proj1.module_a$$');
    goog.require('proj1.module_b$$');
    goog.require('proj1.proj2.module_b$$'); // You don't want this!
    proj1.module_a$$ = 'module-a';

closurify's People

Contributors

evindor avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.