Angular 10 ОШИБКА в ../shared-library/src/index.ts - PullRequest
0 голосов
/ 09 июля 2020

Я только что установил проект с angular cli и у меня проблема с использованием библиотеки. Я использую свою библиотеку в проекте через npm link. Он работал в Angular 9. Но с 10 у меня такая ошибка:

ERROR in ../shared-library/src/index.ts
Module build failed (project/node_modules/@ngtools/webpack/src/index.js):
Error: projects/shared-library/src/index.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.

Пакет общей библиотеки. json:

{
  "name": "@mylib/shared-library",
  "version": "0.0.1",
  "main": "src/index.ts",
  "peerDependencies": {
    "@angular/common": "^10.0.3",
    "@angular/core": "~10.0.3",
    "@angular/cdk": "^10.0.1",
    "@angular/flex-layout": "^10.0.0-beta.32",
    "@angular/forms": "~10.0.3",
    "@angular/material": "^10.0.3"
  },
  "dependencies": {
    "tslib": "^2.0.0"
  }
}

Моя библиотека tsconfig.lib. json:

{
  "extends": "../../tsconfig.base.json",
  "compilerOptions": {
    "outDir": "../../out-tsc/lib",
    "target": "es2015",
    "declaration": true,
    "inlineSources": true,
    "types": [],
    "lib": [
      "dom",
      "es2018"
    ]
  },
  "angularCompilerOptions": {
    "annotateForClosureCompiler": true,
    "skipTemplateCodegen": true,
    "strictMetadataEmit": true,
    "fullTemplateTypeCheck": true,
    "strictInjectionParameters": true,
    "enableResourceInlining": true
  },
  "exclude": [
    "src/test.ts",
    "**/*.spec.ts"
  ]
}

Мой проект tsconfig.app. json:

{
  "extends": "../../tsconfig.base.json",
  "compilerOptions": {
    "outDir": "../../out-tsc/app",
    "types": []
  },
  "files": [
    "src/main.ts",
    "src/polyfills.ts"
  ],
  "include": [
    "src/**/*.d.ts",
    "../../node_modules/@mylib/shared-library/**/*.ts",
  ],
    "exclude": [
    "src/test.ts",
    "src/**/*.spec.ts"
  ],
  "paths": {
    "@angular/*": ["../../node_modules/@angular/*"]
  },
  "angularCompilerOptions": {
    "preserveSymlinks": true
  }
}

tsconfig.base. json:

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "downlevelIteration": true,
    "experimentalDecorators": true,
    "moduleResolution": "node",
    "importHelpers": true,
    "target": "es2015",
    "module": "es2020",
    "lib": [
      "es2018",
      "dom"
    ],
  },
  "angularCompilerOptions": {
    "fullTemplateTypeCheck": true,
    "strictInjectionParameters": true,
    "preserveSymlinks": true
  }
}

Любые идеи как исправить?

...