tflori / angular-translator

translation module for angular
https://tflori.github.io/angular-translator/
MIT License
21 stars 6 forks source link

TranslateLogHandler.ts (and other files) is missing from the TypeScript compilation #68

Closed lucaritossa closed 6 years ago

lucaritossa commented 6 years ago

I've just tried to upgrade my package.json (devDependencies) to typescript to v2.6.2 but building in AOT I receive this error:

ERROR in ./node_modules/angular-translator/src/TranslateLogHandler.ts
Module build failed: Error: C:\git\myproject\src\node_modules\angular-translator\src\TranslateLogHandler.ts is missing from the TypeScript compilation. Please make sure it is in
your tsconfig via the 'files' or 'include' property.
The missing file seems to be part of a third party library. 
TS files in published libraries are often a sign of a badly packaged library. 
Please open an issue in the library repository to alert its author and ask them to package the library using the Angular Package Format (https://goo.gl/jB3GVv).

This type of error continue for the other files like TranslatePipe, Json, Translator etc
The error suggest you have to package the library using Angular Package Format

I'm also using angular v5.2.0

tflori commented 6 years ago

I don't get this error message. It says in the file the file itself is missing.

Unfortunately I'm not actively using this library and don't get all this errors. To use an established package format was not an option at the time of writing this library because there was nothing established in angular v2 and v4. It begins to annoying me that we get errors with every update of a package while the interpretation of JS is still valid in all browsers.

Maybe for version 3 I will use the suggested package format. But for know I just want to fix the problem.

Do you run ng build or ng serve?

tflori commented 6 years ago

Here is the output from my angular-translator-demo app:

$ node_modules/.bin/ng serve
@angular/compiler-cli@5.0.1 requires typescript@'>=2.4.2 <2.5.0' but 2.6.2 was found instead.
Using this version can result in undefined behaviour and difficult to debug problems.

Please run the following command to install a compatible version of TypeScript.

    npm install typescript@'>=2.4.2 <2.5.0'

To disable this warning run "ng set warnings.typescriptMismatch=false".

** NG Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
Date: 2018-01-16T05:57:30.359Z                                                          
Hash: fc4e6224feb9c60e9f12
Time: 4986ms
chunk {inline} inline.bundle.js (inline) 5.79 kB [entry] [rendered]
chunk {main} main.bundle.js (main) 52.6 kB [initial] [rendered]
chunk {polyfills} polyfills.bundle.js (polyfills) 609 kB [initial] [rendered]
chunk {styles} styles.bundle.js (styles) 34.4 kB [initial] [rendered]
chunk {vendor} vendor.bundle.js (vendor) 8.68 MB [initial] [rendered]

webpack: Compiled successfully.

So a typical "It works on my machine problem"...

Versions used:

tflori commented 6 years ago

I just updated angular cli to 1.6.4 - same result.

lucaritossa commented 6 years ago

Thank you for your test! I'm facing this problem only when running ng build --prod (the --prod flag enables the AOT and other optimization stuff)

Versions used:

tflori commented 6 years ago

Oh angular-translator 2.4.1 - I forgot about this release :smile:

But sorry: same result - just the warning about mismatching typescript version. I have no idea where this could come from.

lucaritossa commented 6 years ago

So if you don't get the error running ng build --prod I will try to test it on another machine... maybe it doesn't work only on my current machine...

tflori commented 6 years ago

Today I saw that my IDE wants to import from angular-translator/src/Translator instead of angular-translator.. Maybe this is causing the problem?

tflori commented 6 years ago

@lucaritossa could you solve your problem? If not please attach a minimal version that produces this error (or create a public repository with a minimal version). thanks in advance.

lucaritossa commented 6 years ago

@tflori I will prepare a minimal version to reproduce this issue and will provide to you.

lucaritossa commented 6 years ago

Ok, I was able to reproduce the issue with this ng -v

image

Here it is the attached minimal reproducible version angular-translator-aot-build-error.zip

To see the error run: npm run build

It is very important to have the typescript version 2.6.2 so I forced package.json to get it.

I also found a workaround modifiying tsconfig.app.json. I added this "include":

"include": [
    "../src/**/*.ts",
    "../node_modules/angular-translator/src/**/*.ts"
  ]
tflori commented 6 years ago

It's for sure a bug from ngc or tsc. Removing the .ts files solves the problem because the files are already compiled. Once there was a reason why I included them in the npm package - of course: now I cant remember. They should not be needed because it's already transpiled to js..

tflori commented 6 years ago

angular-translator 2.4.2 should solve the problem. lets hope there will not come regressions :smile: