Consider removing / documenting .js files for continuous integration
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.
@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.
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.
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: [ ... ]
}
Chad, why do you need to exclude the bootstrap/ stuff?
There are 2 distinct use cases involved:
- Use within a NodeJS server/process
- 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.
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.
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?
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)
Ah. I wasn't sure if you supported node core modules in the commonjs pass. Thanks for the clarification.
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.
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'