транспортир E / Launcher - Ошибка: ReferenceError: окно не определено - PullRequest
0 голосов
/ 28 августа 2018

Я создал угловую библиотеку с angular-cli v6 и ng-packagr, которые включают ngx-bootstrap 3.0.1 в качестве peerDependency. У меня нет проблем с запуском приложения, но если я запускаю транспортир, я получаю следующую ошибку:

I/launcher - Running 1 instances of WebDriver
I/direct - Using ChromeDriver directly...
DevTools listening on ws://127.0.0.1:12281/devtools/browser/e174b42c-8db0-494a-aba0-4366d555a98b
E/launcher - Error: ReferenceError: window is not defined
at Object. (\node_modules\ngx-bootstrap\bundles\webpack:ngx-bootstrap.umd\webpack\universalModuleDefinition:10:2)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
at Module.require (module.js:587:17)
at require (internal/module.js:11:18)
at \dist\sg-ng-core-components\bundles\sg-ng-core-components.umd.js:2:268
at Object. (\dist\sg-ng-core-components\bundles\sg-ng-core-components.umd.js:5:2)

это tsconfig.lib.ts:

{
  "extends": "../../tsconfig.json",
  "compilerOptions": {
    "outDir": "../../out-tsc/lib",
    "target": "es2015",
    "module": "es2015",
    "moduleResolution": "node",
    "declaration": true,
    "sourceMap": true,
    "inlineSources": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "importHelpers": true,
    "types": [],
    "lib": [
      "dom",
      "es2015"
    ]
  },
  "angularCompilerOptions": {
    "annotateForClosureCompiler": true,
    "skipTemplateCodegen": true,
    "strictMetadataEmit": true,
    "fullTemplateTypeCheck": true,
    "strictInjectionParameters": true,
    "flatModuleId": "AUTOGENERATED",
    "flatModuleOutFile": "AUTOGENERATED"
  },
  "exclude": [
    "src/test.ts",
    "**/*.spec.ts"
  ]
}

и это tsconfig.e2e:

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/e2e",
    "module": "commonjs",
    "target": "es2017",
    "types": [
      "jasmine",
      "node"
    ]
  }
}

Кажется, это связано с ngx-bootstrap.umd, но оно работает вне теста e2e. кто-нибудь знает, связано ли это с ng-packagr, транспортиром или ngx-bootstrap?

А может кто-нибудь объяснить мне, как это возможно, что транспортир выдает ошибку в исходном коде библиотеки (что он работает с ng serve)?

Заранее спасибо

...