fknop / angular-pipes

Useful pipes for Angular
https://fknop.gitbook.io/angular-pipes/
MIT License
732 stars 157 forks source link

Bundling / packaging issue ? Comment here! #37

Closed fknop closed 6 years ago

fknop commented 7 years ago

If you encounter a bundling or packaging issue, comment here!

I'm planning to change the bundling / packaging setup to include UMD bundles and tree-shakeable code. I prefer having a centralized issue for this.

fknop commented 7 years ago

No issue have been reported in a month. Closing this for now.

chrgeor commented 6 years ago

I think that I found something going wrong. I try to build for prod but cli fails

ERROR in ./node_modules/angular-pipes/src/math/bytes.pipe.ts
Module build failed: Error: C:\...\node_modules\angular-pipes\src\math\bytes.pipe.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).
    at AngularCompilerPlugin.getCompiledFile (C:\...\node_modules\@ngtools\webpack\src\angular_compiler_plugin.js:656:23)
    at plugin.done.then (C:\...\node_modules\@ngtools\webpack\src\loader.js:467:39)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
 @ ./src/modules/marketing/presentations/components/item/item.component.ngfactory.js 20:23-67
 @ ./src/modules/marketing/presentations/presentations.module.ngfactory.js
 @ ./src/$$_lazy_route_resource lazy
 @ ./node_modules/@angular/core/esm5/core.js
 @ ./src/main.ts
 @ multi ./src/main.ts

I have tried to include the module only, the pipes only and various other combinations.

gschafra commented 6 years ago

Also here with

ng build --prod

[exec] ERROR in ./node_modules/angular-pipes/src/object/keys.pipe.ts [exec] ERROR in ./node_modules/angular-pipes/src/object/keys.pipe.ts [exec] Module build failed: Error: /var/data/workspace/sws/SALT/node_modules/angular-pipes/src/object/keys.pipe.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property. [exec] Module build failed: Error: /var/data/workspace/sws/SALT/node_modules/angular-pipes/src/object/keys.pipe.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property. [exec] 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). [exec] 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). [exec]  at AngularCompilerPlugin.getCompiledFile (/var/data/workspace/sws/SALT/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:674:23) [exec]  at AngularCompilerPlugin.getCompiledFile (/var/data/workspace/sws/SALT/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:674:23) [exec]  at plugin.done.then (/var/data/workspace/sws/SALT/node_modules/@ngtools/webpack/src/loader.js:467:39) [exec]  at process._tickCallback (internal/process/next_tick.js:109:7) [exec]  at plugin.done.then (/var/data/workspace/sws/SALT/node_modules/@ngtools/webpack/src/loader.js:467:39) [exec]  at process._tickCallback (internal/process/next_tick.js:109:7) [exec] info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. [exec] error Command failed with exit code 1.

Angular-CLI v1.7.1 Angular v5.2.6 angular-pipes v6.5.3

fknop commented 6 years ago

I'm going ot publish a new version following the angular package format as @next tag for now. If it works without issues, I'm going to publish it as main version.

fknop commented 6 years ago

You can now try installing with npm i angular-pipes@next -S.

I'll publish it as 7.0.0 tomorrow if no issues are found.

gschafra commented 6 years ago

Now, on

ng serve --prod

I've got

ERROR in : Unexpected value 'NgArrayPipesModule in D:/vlinux/frontend/salt/node_modules/angular- pipes/angular-pipes.d.ts' imported by the module 'OrdersModule in D:/vlinux/frontend/salt/src/ap p/appdata/orders/orders.module.ts'. Please add a @NgModule annotation.

within following module definition

import { NgArrayPipesModule, NgObjectPipesModule } from 'angular-pipes';

@NgModule({
    imports: [
        NgArrayPipesModule,
        NgObjectPipesModule
         [
...
})
export class OrdersModule
{
}

What I am doing wrong?

Angular-CLI v1.7.2 Angular v5.2.7 angular-pipes v7.0.0

fknop commented 6 years ago

Could you provide a minimal reproduction of the issue ?

hohler commented 6 years ago

Production build is not working.

angular-pipes v7.0.1

ERROR in : Unexpected value 'BytesPipe in C:/Users/xxx/Documents/xxx/xxx/xxx/xxx-ui/node_modules/angular-pipes/angular-pipes.d.ts' declared by the module 'AdminModule in C:/Users/xxx/Documents/xxx/xxx/xxx/xxx-ui/src/app/admin/admin.module.ts'.
 Please add a @Pipe/@Directive/@Component annotation.

This happens, when including BytesPipe in the module.

When including the whole NgMathPipesModule, following error appears while building:

ERROR in : Unexpected value 'NgMathPipesModule in C:/Users/xxx/Documents/xxx/xxx/xxx/xxx-ui/node_modules/angular-pipes/angular-pipes.d.ts' imported by the module 'AdminModule in C:/Users/xxx/Documents/xxx/xxx/xxx/xxx-ui/src/app/admin/admin.mod
ule.ts'. Please add a @NgModule annotation.
fknop commented 6 years ago

Are you using the CLI ?

I've tried with a CLI repository, it worked. If you're not using the CLI, could you please provide a minimal reproduction so that I can trace the error ?

josp70 commented 6 years ago

I have created a repository which reproduces the error in production build. It happens either when ng build --aot or ng build --production

https://github.com/josp70/TestAngularPipes

The error message is:

ERROR in : Unexpected value 'NgMathPipesModule in 
TestAngularPipes/node_modules/angular-pipes/angular-pipes.d.ts' imported by the module
'AppModule in Angular/TestAngularPipes/src/app/app.module.ts'. Please add a @NgModule annotation.
fknop commented 6 years ago

I think I know where the error comes from. I'll take a look into it later this evening.

fknop commented 6 years ago

Issue is probably resolved now, it was an issue with ng-packagr or AOT which didn't generate metadata when exporting * from a index.ts. I changed every export to explicit export, and it should now work with version 7.1.0.

josp70 commented 6 years ago

I confirm that this issue is solved.

thanks!!!

gethinoakes commented 6 years ago

I'm getting a 'Metadata version mismatch' error when serving my CLI project, it only happens on the first run and when I save a file it compiles successfully. No errors in the web app itself and the pipes seem to work just fine.

However when it comes to building the app, it fails completely on the same issue.

ERROR in Error: Metadata version mismatch for module 
/.../node_modules/angular-pipes/angular-pipes.d.ts, 
found version 4, expected 3, resolving symbol AppModule in 
/.../src/app/app.module.ts, resolving symbol AppModule in.. /.../src/app/app.module.ts

Any ideas? Thanks in advance :)

fknop commented 6 years ago

What version of angular are you using ?

gethinoakes commented 6 years ago

4.0.3, is 5 minimum for this?

fknop commented 6 years ago

Yes, I think the AOT metadata on the latest version is not compatible with the V4 compiler. You could try to make it work with an older version of angular-pipes.

fknop commented 6 years ago

I'm gonna do a little bit of research to see if it's possible to generate multiple versions.

gethinoakes commented 6 years ago

Thanks. We'll be in the process of moving to angular 5 soon and will check this library out again then, we've managed a different solution for now.