shlomiassaf / angular-library-starter

Your last library starter. A complete, @angular grade, library starter
MIT License
44 stars 12 forks source link

TypeError: Cannot read property 'path' of undefined #5

Open jogelin opened 7 years ago

jogelin commented 7 years ago

[14:52:11] Starting '!build:webpack'... Starting compilation using the angular compiler. Angular compilation done, starting webpack bundling. [14:52:16] '!build:webpack' errored after 4.11 s [14:52:16] TypeError: Cannot read property 'path' of undefined at TsickleCompilerHost.getSourceMapKeyForSourceFile (D:\dev\projects\viper\shared-js\node_modules\tsickle\src\tsickle_compiler_host.ts:197:61) at TsickleCompilerHost.closurize (D:\dev\projects\viper\shared-js\node_modules\tsickle\src\tsickle_compiler_host.ts:319:14) at TsickleCompilerHost.getSourceFile (D:\dev\projects\viper\shared-js\node_modules\tsickle\src\tsickle_compiler_host.ts:166:21) at findSourceFile (D:\dev\projects\viper\shared-js\node_modules\@angular\tsc-wrapped\node_modules\typescript\lib\typescript.js:67716:29) at processImportedModules (D:\dev\projects\viper\shared-js\node_modules\@angular\tsc-wrapped\node_modules\typescript\lib\typescript.js:67863:25) at findSourceFile (D:\dev\projects\viper\shared-js\node_modules\@angular\tsc-wrapped\node_modules\typescript\lib\typescript.js:67744:17) at processImportedModules (D:\dev\projects\viper\shared-js\node_modules\@angular\tsc-wrapped\node_modules\typescript\lib\typescript.js:67863:25) at findSourceFile (D:\dev\projects\viper\shared-js\node_modules\@angular\tsc-wrapped\node_modules\typescript\lib\typescript.js:67744:17) at processSourceFile (D:\dev\projects\viper\shared-js\node_modules\@angular\tsc-wrapped\node_modules\typescript\lib\typescript.js:67647:27) at processRootFile (D:\dev\projects\viper\shared-js\node_modules\@angular\tsc-wrapped\node_modules\typescript\lib\typescript.js:67535:13) at D:\dev\projects\viper\shared-js\node_modules\@angular\tsc-wrapped\node_modules\typescript\lib\typescript.js:66825:60 at Object.forEach (D:\dev\projects\viper\shared-js\node_modules\@angular\tsc-wrapped\node_modules\typescript\lib\typescript.js:1443:30) at Object.createProgram (D:\dev\projects\viper\shared-js\node_modules\@angular\tsc-wrapped\node_modules\typescript\lib\typescript.js:66825:16) at createProgram_1 (D:\dev\projects\viper\tools\@angular\tsc-wrapped\src\main.ts:58:17) at D:\dev\projects\viper\tools\@angular\tsc-wrapped\src\main.ts:160:28 at ERROR: Cannot read property 'path' of undefined [14:52:16] '!compile' errored after 43 s


* **package.json of the library**

{ "description": "forms", "keywords": [ ], "libConfig": { "inlineResources": true }, "dependencies": { "@ng2-dynamic-forms/core": "1.4.15", "@ng2-dynamic-forms/ui-ng-bootstrap": "1.4.15", "angular2-text-mask": "^8.0.1" }, "peerDependencies": { "@angular/core": "^4.2.3", "@angular/common": "^4.2.3", "@angular/forms": "^4.2.3", "rxjs": "^5.4.1" } }


* **javascript of the library**

import { NgModule } from '@angular/core'; import { DynamicFormsCoreModule } from '@ng2-dynamic-forms/core'; import { DynamicFormsNGBootstrapUIModule } from '@ng2-dynamic-forms/ui-ng-bootstrap';

@NgModule({ imports: [ DynamicFormsCoreModule.forRoot(), DynamicFormsNGBootstrapUIModule ], declarations: [ ], exports: [ ] }) export class AppFormsModule { }



* **What is the expected behavior?**
To not have an error :-)

Maybe it's caused by the [dynamic-form](https://github.com/udos86/ng2-dynamic-forms) library but I don't know why, so I can't open an issue...

It works very well with other libraries and thanks again because this project has a very good enterprise vision !
shlomiassaf commented 7 years ago

Yes, that's strange...

If you remove that lib it all works?

shlomiassaf commented 7 years ago

Looking at #6 got me thinking...

Did you install these 3rd party libs in node_modules within the package directory (as opposed to node_modules in the root of the project)

jogelin commented 7 years ago

If I remove it, indeed it works...

Yes it was the case, like I said in the #6, I am doing that with other libraries and it works...

So I tried to put those dependencies in the devDependencies of the root project but I have a lot of errors:

============================================
Compiling library forms
=============================================

[09:00:15] Starting '!build:webpack'...
Starting compilation using the angular compiler.
Angular compilation done, starting webpack bundling.
[09:00:21] '!build:webpack' errored after 6.21 s
[09:00:21] Error: Error File 'D:/dev/projects/viper/shared-js/node_modules/@ng2-dynamic-forms/core/src/component/dynamic-form-control-relation.utils.ts' is not under 'rootDir' 'D:/dev/projects/viper/shared-js/src/@sxpbelux'. 'rootDir' is expected to contain all source files.
Error File 'D:/dev/projects/viper/shared-js/node_modules/@ng2-dynamic-forms/core/src/component/dynamic-form-control.component.ts' is not under 'rootDir' 'D:/dev/projects/viper/shared-js/src/@sxpbelux'. 'rootDir' is expected to contain all source files.
Error File 'D:/dev/projects/viper/shared-js/node_modules/@ng2-dynamic-forms/core/src/core.module.ts' is not under 'rootDir' 'D:/dev/projects/viper/shared-js/src/@sxpbelux'. 'rootDir' is expected to contain all source files.
Error File 'D:/dev/projects/viper/shared-js/node_modules/@ng2-dynamic-forms/core/src/decorator/serializable.decorator.ts' is not under 'rootDir' 'D:/dev/projects/viper/shared-js/src/@sxpbelux'. 'rootDir' is expected to contain all source files.
Error File 'D:/dev/projects/viper/shared-js/node_modules/@ng2-dynamic-forms/core/src/directive/dynamic-id.directive.ts' is not under 'rootDir' 'D:/dev/projects/viper/shared-js/src/@sxpbelux'. 'rootDir' is expected to contain all source files.
Error File 'D:/dev/projects/viper/shared-js/node_modules/@ng2-dynamic-forms/core/src/directive/dynamic-template.directive.ts' is not under 'rootDir' 'D:/dev/projects/viper/shared-js/src/@sxpbelux'. 'rootDir' is expected to contain all source files.
Error File 'D:/dev/projects/viper/shared-js/node_modules/@ng2-dynamic-forms/core/src/model/checkbox/dynamic-checkbox-group.model.ts' is not under 'rootDir' 'D:/dev/projects/viper/shared-js/src/@sxpbelux'. 'rootDir' is expected to contain all source files.
Error File 'D:/dev/projects/viper/shared-js/node_modules/@ng2-dynamic-forms/core/src/model/checkbox/dynamic-checkbox.model.ts' is not under 'rootDir' 'D:/dev/projects/viper/shared-js/src/@sxpbelux'. 'rootDir' is expected to contain all source files.
...
same errors on 59000 lines ;)
...
Error File 'D:/dev/projects/viper/shared-js/node_modules/@ng2-dynamic-forms/ui-ng-bootstrap/src/ui-ng-bootstrap.module.ts' is not under 'rootDir' 'D:/dev/projects/viper/shared-js/src/@sxpbelux'. 'rootDir' is expected to contain all source files.
    at new UserError (D:\dev\projects\viper\tools\@angular\tsc-wrapped\src\tsc.ts:33:5)
    at check (D:\dev\projects\viper\tools\@angular\tsc-wrapped\src\tsc.ts:81:11)
    at Tsc.typeCheck (D:\dev\projects\viper\tools\@angular\tsc-wrapped\src\tsc.ts:168:5)
    at D:\dev\projects\viper\tools\@angular\tsc-wrapped\src\main.ts:143:11
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:169:7)
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I think it is because it tries to compile all .ts files of this library but it is not in the lib folder anymore... We shouldn't publish ts files when we make a library...should we ? How can I ignore those files ?

DDeis commented 7 years ago

Hi @jogelin, I'm having a similar issue, did you find a solution for the TypeError: Cannot read property 'path' of undefined at TsickleCompilerHost.getSourceMapKeyForSourceFile error?

jogelin commented 7 years ago

Hi @DDeis, I am sorry but I can't help you. I did not solve this issue...

DDeis commented 7 years ago

Thanks for the feedback @jogelin, for my part the issue happens because the TsickleCompiler host was trying to resolve the index.ts of the failing library instead of the typings file (index.d.ts).