Giter Club home page Giter Club logo

generator-closure's Introduction

Closure Library Generator

Create a fully working Closure Library project in seconds.

NPM

Getting Started

The generator is using yeoman and relies on Grunt to operate. If you don't have them, install:

npm install -g yo grunt-cli

The generator itself can be globally installed and reused anywhere:

npm install -g generator-closure

Run it:

yo closure

After the generator is finished, you need to add the Closure Library in the app/closure-library path:

git clone https://github.com/google/closure-library app/closure-library

Finally, install all the dependencies:

npm install && bower install

The Library Version

There is a Library version of the generator:

yo closure:lib

The Library version is for closure libraries that have no web output. The location of your project's base changes to lib/ instead of the default one app/js/.

What you get

  • A fully working installation of closure compiler.
  • A battle-tested folder scaffolding for your closure application.
  • A skeleton sample application.
  • A third-party dependencies loader.
  • A set of helper and boilerplate code to speed up your time to productive code.
  • A Full Behavioral and Unit testing suite using Mocha with Chai.js and Sinon.js.
  • 52 BDD and TDD tests both for your development and compiled code.
  • Full open source boilerplace (README, LICENSE, .editorconfig, etc).
  • Vanilla and a special edition Closure Compiler that strips off all logger calls from your production code. (The special edition is used).
  • Sourcemap file for your compiled code.
  • A set of Grunt Tasks that will:
    • Manage your dependencies.
    • Compile your code.
    • Run a static webserver with livereload.
    • Test your code on the CLI & the browser.

Table Of Contents

Grunt Tasks

Tasks Overview

  • grunt server Start a static server
  • grunt or grunt deps Calculate Dependencies
  • grunt build Compile your code
  • grunt test Run tests on the command line
  • grunt server:test Run tests on the browser

Tasks In Detail

grunt server

The grunt server task will do quite a few things for you.

  • A static server will listen on port 9000 (or anything you'd like, with: --port=8080).
  • A live reload server will be launched.
  • All your codebase will be wathed for changes and trigger livereload events
  • Finally, your browser will open on the project page

grunt deps

The grunt deps task will calculate the dependencies of your project and output to the deps file: app/js/deps-app.js.

It will also run the dependencies task for the behavioral and unit tests updating the files: test/bdd/deps-test-bdd.js and test/unit/deps-test-tdd.js. Find more about testing bellow.

↑ Back to TOC

grunt build

The build task employs a long flow so it can enable you to bundle third-party dependencies on your production file. Here is the overview of what happens:

  1. Temporary folder temp is cleared.
  2. All the defined third-party dependencies are minified using uglify. The output can be found in temp/vendor.js.
  3. Closure Compiler will compile your closure codebase using ADVANCED_OPTIMIZATIONS. The output can be found at: temp/compiled.js
  4. Produce the final file by concatenating the vendor and compiled files to: app/jsc/app.js

Configure build options

The build operation is easily configured down to the most edge case. Everything you need is in the Gruntfile which is at the root of your project: Gruntfile.js.

At the top of the file you will find a few build related variables:

  // The folder that contains all the externs files.
  var EXTERNS_PATH = 'build/externs/';

  // define the main namespace of your app
  var ENTRY_POINT = 'app';
Third-Party Libraries

Read about Configuring Third-Party dependencies for your build.

EXTERNS_PATH

Define the folder that will be scanned for externs files. The Closure Generator comes packed with these externs for you:

  • jQuery 1.9
  • Angular
  • Facebook Javascript SDK
  • When.js 1.8
ENTRY_POINT

The entry point is the top-most namespace level of your application. In the included sample application that namespace is app.

Advanced Build Configuration

Locate the directive closureBuilder in the Gruntfile. The full documentation for all the options and directives can be found in the Grunt Closure Tools plugin that is being used to compile your code.

One thing to take note of is the line where the compiled is defined:

compilerFile: compiler.getPathSS(),

The compiler variable is the Superstartup Closure Compiler npm package that includes two versions of the Closure Compiler. The original closure compiler and a modified one. In this line, the modified compiler is used so all logger debug calls are stripped from the production built.

grunt test & grunt server:test

The test tasks for the CLI and the browser. Read more on the Testing section.

↑ Back to TOC

Your Closure Application

The scaffold of the closure application gives you a kickstart on writing your own app. A lot of different practices and techniques are incorporated in the scaffolding. They are based on distilled experiences and problems faced over years of developing closure applications. Feel free to rip everything off and start from scratch or checkout what's included...

Folder Layout

The root folder of the Closure Application is in: app/js/. Only two files two files should exist in the root folder:

  • main.js This is the main bootstrap file. No code should exist in this file, only require statements. Sequence matters.
  • deps-app.js The dependencies file. This file is auto-generated by the grunt deps task.

The other folders and their meaning:

core/

The core folder is where the core of your application resides. The standard core/core.js file defines the core class and initializes your application.

The exports.js file is where you define what parts of your application will get exposed after compilation.

The response.core.js is an optional library that will help your library provide uniform, standardized and properly exposed responses. E.g. event objects, callback parameters, etc.

helpers/

Put helpers here. A set of some utility functions is included in the ssd.helpers namespace. Read the helpers/helpers.js file, they are well documented.

libs/

Stand alone closure libraries for your project. The third-party loader is in this folder: libs/vendor.loader.js. Read more about it in the Third-party dependencies section.

The file module.js is an empty class that all other applications extend, it can be accessed is the app.Module namespace. The app.Module class extends goog.events.EventTarget which extends goog.Disposable. This provides with all your classes event and disposing capabilities.

A typical way to extend the app.Module base class:

/**
 * @fileoverview Performs some function.
 */
goog.provide('app.SomeClass');

goog.require('app.Module');

/**
 * @constructor
 * @extends {app.Module}
 */
app.SomeClass = function() {
  goog.base(this);

  /** .. */
};
goog.inherits(app.SomeClass, app.Module);

network/

The network folder contains a persistent storage layer abstraction. The top-most class is the app.sync which only has one function: app.sync.send(). app.sync is a this wrapper for app.ajax which provides some abstraction over Closure's XhrIo library.

The result is that when your app interfaces with app.sync it has the option to work with a promise or callback. Both of which return a standardized response object that is defined in the response.sync.js file. Should that be the case at a later point, you can easily intercept calls in the sync class and use sockets over xhr or local storage or...

While this is possibly quite a stretch for your use-case, it is generaly advisable to retain such a level of abstraction to the persistent storage layer. That includes the network layer (xhr or socket calls).

structs/

The structs folder should contain all your data abstractions. These are the building blocks of your models.

vendor/

All third-party libraries should be in here. Read more about Third-Party Dependencies.

Your Application Folders

Create new folders as you see fit. In the generator the folder app/ is included which contains a skeleton app.

↑ Back to TOC

Third-Party Dependencies

Closure Library has a hard time working with third-party libraries that are not closure compatible. Hopefully, with the use of externs files, this dependency loader and the community's help we can soften these hurdles.

This is more of a technique, rather than a stand alone library. The library itself is only usefull for developing. For building your application the ball is on Grunt's hands.

IMPORTANT: All third-party dependencies must be in the app/js/vendor folder.

Configure Third-Party for Development

You need to edit the third-party library file which is located at: app/js/libs/vendor.loader.js.

  /**
   * EDIT THIS ARRAY.
   *
   * @type {Array} define the 3rd party deps.
   */
  ssd.vendor.files = [
    'when.js',
    'jQuery-1.9.1.js'
  ];

Add or remove strings in the array as you see fit.

Configure Third-Party Building

To define what third-party files will get bundled with your production file you need to edit the Gruntfile. At the top of the Gruntfile the vendorFiles Array is defined:

  // define the path to the app
  var APP_PATH = 'app/js';

  // the file globbing pattern for vendor file uglification.
  var vendorFiles = [
    // all files JS in vendor folder
    APP_PATH + '/vendor/*.js',
    // and jQuery, we'll use a CDN for it.
    '!' + APP_PATH + '/vendor/jQuery*'
  ];

This configuration will include every javascript file in the app/js/vendor/ directory, except any jQuery file. We don't want to include jQuery in the production file as it is faster to include from a public CDN.

↑ Back to TOC

The Test Suites

The test suite uses Mocha with Chai.js and Sinon.js. Two seperate types are included, Behavioral and Unit tests.

Behavioral Driven Development

BDD tests are supposed to test against the development and compiled code. They ensure your API is properly exposed and all functionality and behavior happens as expected.

24 tests are included that can run against your development or compiled code. Launch them on your browser with grunt:

grunt server:test

Test Drive Development

Unit tests are designed to test your codebase only in development state. They will fail if run against your compiled code.

This provides you with the ability to unit test down to the most granular level your code. 4 unit tests are included to get you started. You can view them in the browser after you click on the Unit Tests link at the top of your browser:

grunt server:test

Tests on the CLI

grunt test

'nough said.

Common Browser Pitfalls

You may noticed that to switch from BDD to Unit tests or to Compiled codebase on the browser, a GET param is added on the url. E.g. to view the unit tests the url is http://localhost:4242/test/?unit=1.

If you want to drill down on a specific test that GET param ?unit=1 will be lost. For example, if you click on the isjQ() test you will be redirected to this url and see nothing:

http://localhost:4242/test/?grep=ssd.helpers%20isjQ

The reason this is blank is because the unit GET param is not there. You need to add it manually:

http://localhost:4242/test/?grep=ssd.helpers%20isjQ&unit=1

Sorry about that, please share your thoughts.

↑ Back to TOC

Contributing

Closure is so vast and we need to have a common place to document all the techniques and best practises used today.

The ssd Namespace

The ssd namespace that's included in some libraries stands for SuperStartup Development. It is the development namespace used by the Superstartup library.

Release History

  • v0.1.15, 10 Jan 2014
    • Update SourceMap definition to latest spec, thanks @xasima #23
    • Switched to Vanilla Closure Compiler for production build #24.
  • v0.1.13, 06 Jan 2014
    • Force create temp/ folder.
    • Updated grunt-closure-tools package to ~0.9.0, latest.
  • v0.1.12, 05 Dec 2013
    • Updated all dependencies to latest.
  • v0.1.9, 14 Oct 2013
    • Allow overriding hostname and port of grunt server.
    • Fix generator green bug.
    • Enables defining closure-library location using the CLOSURE_PATH env var #3
  • v0.1.8, 8 Jun 2013
    • Fix event handling so it works with recent closure changes.
  • v0.1.7, 3 Jun 2013
    • Bug fix for library generation
  • v0.1.6, 1 May 2013
    • Several bugfixes, all found thanks to @JayGray.
  • v0.1.5, 07 May 2013
    • Renamed component.json to bower.json
    • Linted Gruntfile
    • Minor color tweaks
  • v0.1.4, 14 Apr 2013
    • Added Closure Linter task, thanks @pr4v33n
  • v0.1.3, 14 Apr 2013
    • Minor bugs
  • v0.1.2, 21 Mar 2013
    • Added Library generator
    • Added Bower support
    • Instruction changes
  • v0.1.1, 20 Mar 2013
    • Added Source Map option
    • Minor typo fixes
  • v0.1.0, Mid Mar 2013
    • Big Bang

License

Copyright (c) 2013 Thanasis Polychronakis Licensed under the MIT.

↑ Back to TOC

generator-closure's People

Contributors

casio avatar jzacsh avatar mortonfox avatar pr4v33n avatar thanpolas avatar vergun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

generator-closure's Issues

Compatibility with AngularJS?

Hi,

Have you tried this with an AngularJS App? I wonder if the dependency injection system of AngularJS works well with Closure. Maybe it's better to not use the AngularJS IoC?
If you have a sample app it will be great!

grunt server opens the page, but it doesn't depict anything

I made the grunt build and point my standalone web-server nginx to the /app folder of the generator-closure project, so can see the 'The Closure Library Boilerplate'-page on my localhost that works well. It seems that grunt clean and build phase are ok.

If starting grunt server command then the browser is opened on localhost:9000, but there is no any actual content shown on the page, but it stated to the waiting status forever instead.

>> grunt server -v --stack --debug

Running "server" task

Running "clean:server" (clean) task
Verifying property clean.server exists in config...OK
Files: temp -> server
Options: force=false, no-write=false
Options: force=false, no-write=false
Cleaning temp...OK

Running "connect:app" (connect) task
Verifying property connect.app exists in config...OK
File: [no files]
Options: protocol="http", port=9000, hostname="localhost", base=".", directory=null, keepalive=false, debug=false, livereload=false, open=false, middleware=undefined
Started connect web server on 127.0.0.1:9000.

Running "open:server" (open) task
Verifying property open.server exists in config...OK
File: [no files]

Running "watch:livereload" (watch) task
Waiting...Verifying property watch exists in config...OK
Verifying property watch.livereload.files exists in config...OK
Live reload server started on port: 35729
Watching app/js/app/showcase-debug.js for changes.
Watching app/js/app/ui-events.js for changes.
Watching app/js/core/core.js for changes.
Watching app/js/core/exports.js for changes.
Watching app/js/core/response.core.js for changes.
Watching app/js/deps.js for changes.
Watching app/js/libs for changes.
Watching app/js/app for changes.
Watching app/js/structs for changes.
Watching app/js/core for changes.
Watching app/js/network for changes.
Watching app/js/vendor for changes.
Watching app/js/main.js for changes.
Watching app/js/libs/invocator.js for changes.
Watching app/js/libs/module.js for changes.
Watching app/js/libs/vendor.loader.js for changes.
Watching app/js/network/ajax.js for changes.
Watching app/js/network/response.sync.js for changes.
Watching app/js/network/sync.js for changes.
Watching app/js/vendor/when.js for changes.

The same if changing the initial Gruntfile.js to switch off livereload (from default true to false), or /and running grunt open:server -v --stack --debug

grunt.initConfig({ watch: { livereload: { options: { livereload: false }, files: [ CONF.appPath + '/**/*.js' ], },

It seems that something bad with the path to the initial /app in a grunt

Global install

Generators can now be installed globally. Please update readme:

npm install -g generator-closure

Consider env var for the closure library

Instead having to clone the closure lib over and over again, it would be nice if users could just set an env var pointing to their local copy.

I dont remember really, but I think there were issues with depswriter.py depending on the cwd, so using deps.js in the browser might pose a problem.

Will have a try with this..maybe you have a solution already?

Missing 'helpers' folder

After generating project the 'helpers' folder is missing.

Used versions:
yo v1.0.0-beta.5
npm v1.2.18
grunt-cli v0.1.6
grunt v0.4.1
bower v0.8.5

TypeError when installing yo closure

Hi guys - new to Yeoman, so looking for the right place to ask questions. Apologies if this is not it.

I installed generator-closure because I'm interested in exploring Google Closure. That went fine, but yo closure comes up with an error:

...
create Gruntfile.js
create README.md
create LICENSE-MIT

TypeError: Cannot read property 'green' of undefined
at getStep (/usr/local/lib/node_modules/generator-closure/app/base.js:31:33)
at Generator.onEnd (/usr/local/lib/nodemodules/generator-closure/app/base.js:43:19)
at Generator.EventEmitter.emit (events.js:117:20)
at /usr/local/lib/node_modules/generator-closure/node_modules/yeoman-generator/lib/base.js:306:14
at process._tickCallback (node.js:415:13)
at Function.Module.runMain (module.js:499:11)
at startup (node.js:119:16)
at node.js:901:3

Errors in default /jsc/app.js after compilation

The compiled version of app.js from the fresh-generated project contains error. The firebug shows

Uncaught ReferenceError: $ is not defined app.js:17
Q.init app.js:17
h.init app.js:17
(anonymous function) app.js:18
(anonymous function) app.js:31

Some details on the recreation are below.
I had created the default yo closure project and clone the closure library. The default grunt server works fine. So I have recreated deps using grunt deps and built the compiled version with grunt build.

The following changes of app/index.html are made (replace to /jsc/app.js)

  -      <script src="/closure-library/closure/goog/base.js"></script>
  -      <script src="/js/deps.js"></script>
  -      <script src="/js/main.js"></script>

 +      <script src="/jsc/app.js"></script>

Here is the output of the buid

Running "closureBuilder:app" (closureBuilder) task
Executing: python app/closure-library/closure/bin/build/closurebuilder.py  -i app/js/main.js --root=app/js/ --root=app/closure-library --root=app/components -o compiled --output_file=temp/compiled.js --compiler_jar=node_modules/superstartup-closure-compiler/build/sscompiler.jar --compiler_flags="--compilation_level=ADVANCED_OPTIMIZATIONS" --compiler_flags="--externs=build/externs/angular.externs.js" --compiler_flags="--externs=build/externs/fb-api.externs.js" --compiler_flags="--externs=build/externs/jquery-1.9.js" --compiler_flags="--externs=build/externs/when.extern.js" --compiler_flags="--define='goog.DEBUG=false'" --compiler_flags="--warning_level=verbose" --compiler_flags="--jscomp_off=checkTypes" --compiler_flags="--jscomp_off=fileoverviewTags" --compiler_flags="--summary_detail_level=3" --compiler_flags="--only_closure_dependencies" --compiler_flags="--closure_entry_point=app" --compiler_flags="--create_source_map=app/jsc/sourcemap.js.map" --compiler_flags="--source_map_format=V3" --compiler_flags="--output_wrapper=(function(){%output%}).call(this);//@sourceMappingURL=app/jsc/sourcemap.js.map"
app/closure-library/closure/bin/build/closurebuilder.py: Scanning paths...
app/closure-library/closure/bin/build/closurebuilder.py: 1098 sources scanned.
app/closure-library/closure/bin/build/closurebuilder.py: Building dependency tree..
app/closure-library/closure/bin/build/closurebuilder.py: Compiling with the following command: java -client -jar node_modules/superstartup-closure-compiler/build/sscompiler.jar --js app/closure-library/closure/goog/base.js --js app/js/libs/vendor.loader.js --js app/closure-library/closure/goog/json/json.js --js app/closure-library/closure/goog/object/object.js --js app/closure-library/closure/goog/dom/nodetype.js --js app/closure-library/closure/goog/debug/error.js --js app/closure-library/closure/goog/string/string.js --js app/closure-library/closure/goog/asserts/asserts.js --js app/closure-library/closure/goog/array/array.js --js app/components/closure-helpers/lib/helpers.js --js app/closure-library/closure/goog/events/eventid.js --js app/closure-library/closure/goog/events/listenable.js --js app/closure-library/closure/goog/events/listener.js --js app/closure-library/closure/goog/events/listenermap.js --js app/closure-library/closure/goog/useragent/useragent.js --js app/closure-library/closure/goog/events/browserfeature.js --js app/closure-library/closure/goog/debug/entrypointregistry.js --js app/closure-library/closure/goog/events/eventtype.js --js app/closure-library/closure/goog/disposable/idisposable.js --js app/closure-library/closure/goog/disposable/disposable.js --js app/closure-library/closure/goog/events/event.js --js app/closure-library/closure/goog/reflect/reflect.js --js app/closure-library/closure/goog/events/browserevent.js --js app/closure-library/closure/goog/events/events.js --js app/closure-library/closure/goog/events/eventhandler.js --js app/js/libs/invocator.js --js app/closure-library/closure/goog/events/eventtarget.js --js app/js/libs/module.js --js app/closure-library/closure/goog/debug/relativetimeprovider.js --js app/closure-library/closure/goog/debug/formatter.js --js app/closure-library/closure/goog/structs/circularbuffer.js --js app/closure-library/closure/goog/structs/collection.js --js app/closure-library/closure/goog/structs/structs.js --js app/closure-library/closure/goog/functions/functions.js --js app/closure-library/closure/goog/math/math.js --js app/closure-library/closure/goog/iter/iter.js --js app/closure-library/closure/goog/structs/map.js --js app/closure-library/closure/goog/structs/set.js --js app/closure-library/closure/goog/debug/debug.js --js app/closure-library/closure/goog/debug/logrecord.js --js app/closure-library/closure/goog/debug/logbuffer.js --js app/closure-library/closure/goog/debug/logger.js --js app/closure-library/closure/goog/debug/debugwindow.js --js app/closure-library/closure/goog/dom/classes.js --js app/closure-library/closure/goog/dom/tagname.js --js app/closure-library/closure/goog/math/size.js --js app/closure-library/closure/goog/dom/browserfeature.js --js app/closure-library/closure/goog/math/coordinate.js --js app/closure-library/closure/goog/dom/dom.js --js app/closure-library/closure/goog/debug/fancywindow.js --js app/js/app/showcase-debug.js --js app/components/closure-helpers/lib/debug.js --js app/js/app/ui-events.js --js app/js/core/core.js --js app/closure-library/closure/goog/uri/utils.js --js app/closure-library/closure/goog/uri/uri.js --js app/closure-library/closure/goog/timer/timer.js --js app/closure-library/closure/goog/net/errorcode.js --js app/closure-library/closure/goog/net/httpstatus.js --js app/closure-library/closure/goog/net/xhrlike.js --js app/closure-library/closure/goog/net/xmlhttpfactory.js --js app/closure-library/closure/goog/net/wrapperxmlhttpfactory.js --js app/closure-library/closure/goog/net/xmlhttp.js --js app/closure-library/closure/goog/net/eventtype.js --js app/closure-library/closure/goog/log/log.js --js app/closure-library/closure/goog/net/xhrio.js --js app/js/core/response.core.js --js app/js/network/response.sync.js --js app/js/network/ajax.js --js app/js/network/sync.js --js app/js/core/exports.js --js app/js/main.js --compilation_level=ADVANCED_OPTIMIZATIONS --externs=build/externs/angular.externs.js --externs=build/externs/fb-api.externs.js --externs=build/externs/jquery-1.9.js --externs=build/externs/when.extern.js --define='goog.DEBUG=false' --warning_level=verbose --jscomp_off=checkTypes --jscomp_off=fileoverviewTags --summary_detail_level=3 --only_closure_dependencies --closure_entry_point=app --create_source_map=app/jsc/sourcemap.js.map --source_map_format=V3 --output_wrapper=(function(){%output%}).call(this);//@sourceMappingURL=app/jsc/sourcemap.js.map
0 error(s), 0 warning(s)
app/closure-library/closure/bin/build/closurebuilder.py: JavaScript compilation succeeded.

Command complete for target: app
File statistics for temp/compiled.js
Compiled size:  17.50 kb    (17916 bytes)
GZipped size:   6.71 kb     (6866 bytes) -61.68%

Running "concat:production" (concat) task
File "app/jsc/app.js" created.


Application tests will not work

After running the generator, the built-in tests will fail.

Failure originates from the compiled source and most probably the cause has to do with debug and not properly stripping all log related lines.

SS-compiler had been just recently rebuilt so changes in CC could break the logging-removal functionality

grunt build command failed

I'm learning Google Closure. The build command of the generated is not working.
The closurebuilder.py script seems to be deprecated, maybe using the compiler only will resolve this problem?
I'm using OSX 10.9. Thanks!

Error: Command failed: app/closure-library/closure/bin/build/closurebuilder.py: Scanning paths...
app/closure-library/closure/bin/build/closurebuilder.py: 1666 sources scanned.
app/closure-library/closure/bin/build/closurebuilder.py: Building dependency tree..
app/closure-library/closure/bin/build/closurebuilder.py: Closure Compiler now natively understands and orders Closure dependencies and
is prefererred over using this script for performing JavaScript compilation.

Please migrate your codebase.

See:
https://github.com/google/closure-compiler/wiki/Manage-Closure-Dependencies

app/closure-library/closure/goog/base.js:236: ERROR - illegal initialization of @define variable goog.DISALLOW_TEST_ONLY_CODE
goog.define('goog.DISALLOW_TEST_ONLY_CODE', COMPILED && !goog.DEBUG);
^

1 error(s), 27 warning(s)
Traceback (most recent call last):
File "app/closure-library/closure/bin/build/closurebuilder.py", line 287, in
main()
File "app/closure-library/closure/bin/build/closurebuilder.py", line 276, in main
compiler_flags=options.compiler_flags)
File "/Users/zx/Documents/workspace/js/google-closure/app/closure-library/closure/bin/build/jscompiler.py", line 135, in Compile
raise JsCompilerError('JavaScript compilation failed.')
jscompiler.JsCompilerError: JavaScript compilation failed.
FAILED to run command for target: app
Warning: Task "closureBuilder:app" failed. Use --force to continue.

Aborted due to warnings.

BDD Tests Failing -- RangeError: Maximum Call Stack Size Exceeded

Issue

Running 'grunt server:test' is consistently failing the following BDD test:

CoreAPI :: appOne()

  • Invoke appOne() and listen for all events and callbacks
    • Excecuting appOne() and follow up ready methods
      • should boot up the appOne and emit and event

Error Message

RangeError: Maximum call stack size exceeded
at Object.goog.typeOf (http://localhost:4242/app/closure-library/closure/goog/base.js:735:23)
at Object.goog.isArray (http://localhost:4242/app/closure-library/closure/goog/base.js:870:15)
at Object.goog.events.listen (http://localhost:4242/app/closure-library/closure/goog/events/events.js:153:12)
at app.Core.listen (http://localhost:4242/app/js/core/core.js:139:22)
at Object.goog.events.listen (http://localhost:4242/app/closure-library/closure/goog/events/events.js:163:25)
at app.Core.listen (http://localhost:4242/app/js/core/core.js:139:22)
at Object.goog.events.listen (http://localhost:4242/app/closure-library/closure/goog/events/events.js:163:25)
at app.Core.listen (http://localhost:4242/app/js/core/core.js:139:22)
at Object.goog.events.listen (http://localhost:4242/app/closure-library/closure/goog/events/events.js:163:25)
at app.Core.listen (http://localhost:4242/app/js/core/core.js:139:22)

Reproduction

  1. Install a fresh copy of the closure boilerplate app with yeoman.

yo closure

  1. Follow final install instructions.

git clone https://code.google.com/p/closure-library/ app/closure-library
npm install && bower install

  1. Build project for the first time.

grunt deps
grunt build

  1. Run tests in browser.

grunt server:test

Environment

OS X 10.7.5 (Darwin 11.4.2 x86_64)
Chrome 27.0.1453.110
or
Safari 6.0.4 (7536.29.13)

Notes

The same test fails both in compiled and uncompiled modes. In compiled mode the error output changes the filenames accordingly to app.js; otherwise it is identical.

Also, CLI tests via 'grunt test' fail with the following unhelpful message:

Warning: 2/16 tests failed (4.90s) Use --force to continue.
Aborted due to warnings.

As noted above, the problem persists through both Chrome as well as Safari.

If I left any information out or can provide further specifics, please let me know.

SourceMapping fix is needed

It seems that both comments for sourcemap are needed.
The first one is presented in generator-closure already, the second one needs to be added.

//@sourceMappingURL=app/jsc/sourcemap.js.map
//# sourceMappingURL=/jsc/sourcemap.js.map

The Chrome Canary doesn't perform the additional GET to sourcemap with appropriate option enabled without the latest comment.

Cannot read property 'src' of undefined, on most of grunt tasks

I have generated the closure project with a very fresh yoman closure-generator. Also I had tried to git clone the closure-library to the default app/closure-library. I had done well sudo npm install && bower install too.

But grunt clean, grunt server, grunt build causes the stop of the task due to the warning. If I run the grunt build with the --stack and --force params then it does the compilation whereas producing the details on the warning (see below)

grunt build -v --stack --force
...
Initializing config...OK
Loading "Gruntfile.js" tasks...OK
+ build, default, deps, fixstyle, lint, server, test

Running tasks: build
Running "build" task
Running "clean:dist" (clean) task
Verifying property clean.dist exists in config...OK
Files: [no src] -> dist
Options: (none)
Options: (none)
Warning: Cannot read property 'src' of undefined Used --force, continuing.

if i run the same with no --force then

Initializing config...OK
Loading "Gruntfile.js" tasks...OK
+ build, default, deps, fixstyle, lint, server, test

Running tasks: clean

Running "clean" task
[D] Task source: /home/weblab/projects/spiderapus3/node_modules/grunt-contrib-clean/tasks/clean.js

Running "clean:dist" (clean) task
[D] Task source: /home/weblab/projects/spiderapus3/node_modules/grunt-contrib-clean/tasks/clean.js
Verifying property clean.dist exists in config...OK
Files: [no src] -> dist
Options: (none)
Options: (none)
Warning: Cannot read property 'src' of undefined Use --force to continue.
TypeError: Cannot read property 'src' of undefined
    at Object.<anonymous> (/home/weblab/projects/spiderapus3/node_modules/grunt-contrib-clean/tasks/clean.js:20:14)
    at Object.task.registerMultiTask.thisTask (/home/weblab/projects/spiderapus3/node_modules/grunt/lib/grunt/task.js:264:15)
    at Object.task.registerTask.thisTask.fn (/home/weblab/projects/spiderapus3/node_modules/grunt/lib/grunt/task.js:82:16)
    at Object.Task.start._running (/home/weblab/projects/spiderapus3/node_modules/grunt/lib/util/task.js:282:30)
    at Task.runTaskFn (/home/weblab/projects/spiderapus3/node_modules/grunt/lib/util/task.js:235:24)
    at Task.<anonymous> (/home/weblab/projects/spiderapus3/node_modules/grunt/lib/util/task.js:281:12)
    at Task.<anonymous> (/home/weblab/projects/spiderapus3/node_modules/grunt/lib/util/task.js:215:7)
    at Task.runTaskFn (/home/weblab/projects/spiderapus3/node_modules/grunt/lib/util/task.js:238:9)
    at Task.<anonymous> (/home/weblab/projects/spiderapus3/node_modules/grunt/lib/util/task.js:281:12)
    at Task.start (/home/weblab/projects/spiderapus3/node_modules/grunt/lib/util/task.js:290:5)

I had found something gruntjs/grunt-contrib-clean#19 with similar complains, but It seems I didn't have any permissions problem on that file or on top of closure project

Ubuntu 12.04. grunt 0.4.2

Cannot find module rebuild-optipng.js (0.2.0) at postinstall

I have a problem when doing npm install after Yo had generated the closure project. Here is the log with a problem when doing postinstall for optipng-bin with 0.2.0 version

[email protected] postinstall /home/weblab/projects/spiderapus/node_modules/grunt-contrib-imagemin/node_modules/optipng-bin
> node rebuild-optipng.js


module.js:340
    throw err;
          ^
Error: Cannot find module '/home/weblab/projects/spiderapus/node_modules/grunt-contrib-imagemin/node_modules/optipng-bin/rebuild-optipng.js'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.runMain (module.js:492:10)
    at process.startup.processNextTick.process._tickCallback (node.js:245:9)


I had also tried the npm cache clean with no success.

The regular npm install --save optipng-bin works well and installs the optipng-bin 0.3.1 (take a look on version) in node_modules/

I do have the following versions of certain packages on ubuntu 12.04

node v0.8.26
npm 1.3.0
yo 1.0.4
grunt-cli v0.1.11
grunt v0.4.2
bower 1.2.7

I'm not sure, but this may relate to https://github.com/isaacs/npm/issues/3207, so bumping up the version of optipng-bin may resolve the issue, but not sure how to do that.

Don't you know how to resolve this at least locally and make the closure generator finished well?

Wrong path in vendor.loader.js to jQuery

Path in vendor.loader.js points to components/jquery.... but is vendor/jQuery.js

Used versions:
yo v1.0.0-beta.5
npm v1.2.18
grunt-cli v0.1.6
grunt v0.4.1
bower v0.8.5

closurebuilder problem with grunt build

There is an error ''IOError: [Errno 2] No such file or directory: 'temp/compiled.js'' during building source code.
This happens in this grunt task:

https://github.com/closureplease/generator-closure/blob/master/templates/Gruntfile.js#L210

app: {
  src: [
    CONF.appPath,
    CONF.closureLibrary,
    CONF.componentPath
  ],
  dest: 'temp/compiled.js'
},

if I create 'temp' folder, after running task it get removed.

Had made quick fix for closurebuilder.py for this

if options.output_file:
    output_dir = os.path.dirname(options.output_file)
    if not os.path.exists(output_dir):
        os.makedirs(output_dir)
    out = open(options.output_file, 'w+')
  else:
    out = sys.stdout

but I think this is not an closurebuilder's issue.

Run 'deps' in server & build tasks

Generating a project with the generator and subsequently running grunt server will open the app without the deps.js file existing yet.

Since the tasks is rather fast, IMHO deps should be run at the beginning of server and maybe `build, as well.

Wrong link to dependencies file

The script tag refers to deps-all.js instead of deps.js.

Used version:
yo v1.0.0-beta.5
npm v1.2.18
grunt-cli v0.1.6
grunt v0.4.1
bower v0.8.5

cannot find module superstartup-closure-compiler - missing grunt step?

After following some instructions, in a brand new empty, inited git repo, get error about unfound module. New to tools like grunt, but I'm assuming just some extra grunt step just needs to be added to re0download dependencies?

Or maybe I am the one who missed a step? Here's how I started:

$ npm install generator-closure &&
  yo closure &&
  git clone https://code.google.com/p/closure-library/ app/closure-library

Here was my next step, where the error happened:

$ grunt server
  Loading "Gruntfile.js" tasks...ERROR
  >> Error: Cannot find module 'superstartup-closure-compiler'
  Warning: Task "server" not found. Use --force to continue.

  Aborted due to warnings.

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.