Angular 5升级 - 模块构建失败:CustomPackage不是汇编输出的一部分



我正在将Angular 4.4项目更新为Angular 5的过程。解决。

以下错误是多次输出的,对于我个人创建的NPM软件包中的不同模块导入(全部用TypeScript编写)。

Module build failed: Error: /Users/username/Developer/parent-project/node_modules/custom-package-X/src/app/app-routing.module.ts is not part of the compilation output.

我有三个自定义库导入,并且为三个中的每个库都输出了类似的错误。这些错误仅出现在我的自定义软件包中;因此,它必须与我设置它们的方式有关。

我有一种感觉是因为我的NPM软件包正在公开 typescript(.ts)文件,而不是汇总的 javascript(.js) files。P>

有人有类似的问题,还是有任何建议?


依赖性文件结构

/Users/username/Developer/custom-package-X
├── node_modules
|  ├── ...
├── package-lock.json
├── package.json
├── src
|  ├── auth.service.ts
|  ├── authenticationtoken.ts
|  ├── authorizationtoken.ts
|  ├── resource.service.ts
|  ├── authentication-guard.service.ts
|  ├── authorization-guard.service.ts
|  └── index.ts
└── tsconfig.json

index.ts

export { AuthService } from './auth.service';
export { ResourceService } from './resource.service';
export { AuthenticationToken } from './authenticationtoken';
export { AuthorizationToken } from './authorizationtoken';
export { AuthenticationGuard } from './authentication-guard.service';
export { AuthorizationGuard } from './authorization-guard.service';

tsconfig.json

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "src",
    "lib": ["es2016", "DOM"],
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5"
  }
}

package.json 什么都不是普通的,只有一些元数据和 test> test 脚本。。

的存根

我遇到了相同的问题,在我的案例文件名称中不匹配导入语句,有一个大写字母ex:原始文件名是accountstatus.model.ts

部署语句中的错误,但在构建中正常工作:

import { AccountStatus } from './AccountStatus.model';

更改文件名称语句:

import { AccountStatus } from './accountStatus.model';

最新更新