Angular 6 include google closure library

2.3k Views Asked by At

I want to include google closure library into my angular 6 application. I have applied

npm install google-closure-compiler and npm install google-closure-library.

The app can be compiled and running. However, when I trying to run the tests I wrote with ng test, it has error messages:

ERROR in ./node_modules/google-closure-library/closure/goog/boostrap/nodejs.js
Module not found: Error: Can't resolve 'fs' in './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 './node_modules/google-closure-library/closure/goog/promise/testsuiteadapter.js'

I use the angular official demo example and I just added the test and installed these two libraries. My guesses are I need to configure karma.conf.js, but I don't know how to do that, does anyone know how to solve this?

1

There are 1 best solutions below

0
maxadorable On

Try adding this to your webpack config

node: {
  fs: 'empty'
}

You can also see how its implemented with this

https://github.com/angular/closure-demo