closure-library icon indicating copy to clipboard operation
closure-library copied to clipboard

Consider removing / documenting .js files for continuous integration

Open Dominator008 opened this issue 10 years ago • 11 comments

As shown in https://github.com/google/closure-compiler/issues/1519 and https://groups.google.com/forum/#!topic/closure-compiler-discuss/wAQv1rYXDYA, files like browser_capabilities.js, alltests.js and protractor.conf.js have been confusing people.

We should remove them from the released archives and document the recommended exclusion patterns better for people using HEAD from GitHub.

Dominator008 avatar Feb 10 '16 19:02 Dominator008

@ChadKillingsworth also mentioned compiling with the CommonJS pass can be painful. Can the list of excluded files change if you're using that?

I was thinking a nice solution could be to create a closure_compile_ignore text file that contains a list of those exclusion patterns required to compile Closure Library with dep_mode LOOSE or NONE. Then we can just tell people to add --flagfile closure_compile_ignore. We'd need to document it still, of course.

joeltine avatar Feb 10 '16 22:02 joeltine

Here's the exclusion pattern I'm using with the --process_common_js_modules flag:

[
     'node_modules/google-closure-library/closure/**/*.js',
     'node_modules/google-closure-library/third_party/**/*.js',
     '!node_modules/google-closure-library/**/*test.js',
     '!node_modules/google-closure-library/**/*tester.js',
     '!node_modules/google-closure-library/**/*_perf.js',
     '!node_modules/google-closure-library/closure/goog/bootstrap/nodejs.js',
     '!node_modules/google-closure-library/closure/goog/bootstrap/bytestring_perf.js'
]

I'm using --dependency_mode=STRICT so we'd need some combination of these.

ChadKillingsworth avatar Feb 10 '16 23:02 ChadKillingsworth

For npm, it would be rather nice if the exclusion pattern were exported such that:

// name the property whatever you feel is appropriate
var closureGlobPatterns = require('google-closure-library').GLOB_PATTERN;

That should be as simple as adding the following to the NodeJS bootstrap file:

module.exports = {
    GLOB_PATTERN: [ ... ]
}

ChadKillingsworth avatar Feb 10 '16 23:02 ChadKillingsworth

Chad, why do you need to exclude the bootstrap/ stuff?

joeltine avatar Feb 16 '16 18:02 joeltine

There are 2 distinct use cases involved:

  1. Use within a NodeJS server/process
  2. Use as a traditional front-end library

For the first case, you need the bootstrap so that goog.require/provide calls work without compilation. For the second, you need to exclude them as they are not used and the commonjs rewrites cause errors.

ChadKillingsworth avatar Feb 16 '16 18:02 ChadKillingsworth

Also, I don't know if I'm sold that exporting the glob patterns in bootstrap/nodejs.js makes sense. It seems nicer to have a compilation-specific module that only handles these types of concerns. Then we could convert our compilation shell script to node.

joeltine avatar Feb 16 '16 18:02 joeltine

For the second, you need to exclude them as they are not used and the commonjs rewrites cause errors.

What errors are you seeing in compilation? Shouldn't this file pass compilation regardless?

joeltine avatar Feb 16 '16 18:02 joeltine

The bootstrap file contains references to core node modules - it has no place in a front end dev chain and the compiler doesn't know how to handle this:

/node_modules/google-closure-library/closure/goog/bootstrap/nodejs.js:43: ERROR - Failed to load module "fs"
var fs = require('fs');
         ^

/node_modules/google-closure-library/closure/goog/bootstrap/nodejs.js:44: ERROR - Failed to load module "path"
var path = require('path');
           ^

/node_modules/google-closure-library/closure/goog/bootstrap/nodejs.js:45: ERROR - Failed to load module "vm"
var vm = require('vm');
         ^

3 error(s), 0 warning(s)

ChadKillingsworth avatar Feb 16 '16 18:02 ChadKillingsworth

Ah. I wasn't sure if you supported node core modules in the commonjs pass. Thanks for the clarification.

joeltine avatar Feb 16 '16 18:02 joeltine

It's being actively discussed, but even then this would only apply to server side node uses. The front-end dev can't use a core node module.

ChadKillingsworth avatar Feb 16 '16 18:02 ChadKillingsworth

could you resolve this issue? my errors RROR in ./node_modules/google-closure-library/closure/goog/bootstrap/nodejs.js Module not found: Error: Can't resolve 'fs' in '/Users/gryn_alina/projects/registrationApp/node_modules/google-closure-library/closure/goog/bootstrap' ERROR in ./node_modules/google-closure-library/closure/goog/bootstrap/nodejs.js Module not found: Error: Can't resolve 'path' in '/Users/gryn_alina/projects/registrationApp/node_modules/google-closure-library/closure/goog/bootstrap' ERROR in ./node_modules/google-closure-library/closure/goog/promise/testsuiteadapter.js Module not found: Error: Can't resolve 'promises_aplus_tests' in '/Users/gryn_alina/projects/registrationApp/node_modules/google-closure-library/closure/goog/promise' ERROR in ./node_modules/google-closure-library/closure/goog/bootstrap/nodejs.js Module not found: Error: Can't resolve 'vm' in '/Users/gryn_alina/projects/registrationApp/node_modules/google-closure-library/closure/goog/bootstrap'

angryagr avatar Nov 28 '18 01:11 angryagr