Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pipe could not be found with Angular 9 (Ivy enabled by default) #232

Closed
dsebastien opened this issue Mar 27, 2020 · 7 comments
Closed

Pipe could not be found with Angular 9 (Ivy enabled by default) #232

dsebastien opened this issue Mar 27, 2020 · 7 comments
Labels

Comments

@dsebastien
Copy link

Description of the Issue and Steps to Reproduce:
Create an Angular 9+ project and add ngx-moment to it.
Use any of the pipes and get the error, such as:

The pipe 'amDuration' could not be found

Did you search for duplicate issue? [Yes]

Please describe the issue and steps to reproduce, preferably with a code sample / plunker:

It seems that the pipes can't be found with Ivy enabled in the project. Not sure how to fix this as I'm not willing to disable Ivy

Ensure your issue is isolated to ngx-moment. Issues involving third party tools will be closed unless submitted by the tool's author/maintainer.

Environment:

Please answer the following questions:

  • Angular version? 9.1.0
  • TypeScript version? 3.8.3
  • moment version? 2.24.0
  • Are you using moment-timezone? Yes
  • Are you using the angular-cli? Yes, through Nrwl NX
  • Using Rollup/Webpack/System.js/Ionic/similar? No
@dsebastien
Copy link
Author

I've modified the ngcc-validation project locally, just in case as I saw that ngx-moment is part of it already, but the project did not contain any usage of the library.

I've added the module import, an example in the template and a test and could indeed reproduce the issue there.

Here are the changes that I've made: dsebastien/ngcc-validation@96fa000

(note that the test might be incorrect as I didn't go any further) :)

@urish urish added the bug label Mar 27, 2020
@urish
Copy link
Owner

urish commented Mar 27, 2020

I wonder whether building the library with Angular 9.1.0 will do the trick

@dsebastien
Copy link
Author

Mh, don't know if I did it correctly, but it didn't work.

I have:

  • updated dependencies of Angular to 9.1.0
  • ran npm run prepublish to generate the package in dist
  • removed ngx-moment in the node_modules folder of my locally installed ngcc-validation project
  • copied over the contents of the dist folder in ngcc-validation/node_modules
  • ran npx ngcc against from ngcc-validation
  • executed the test again

The test failed with the same error about the pipe not being found.

I found the following issues which all seem old/closed already but can't make sense of them:

@urish
Copy link
Owner

urish commented Mar 27, 2020

What you did sounds correct (though, next time, you can use npm link instead of having to copy the files manually).

Can you please create a small project that reproduces the issue and share it on github? This will make it easier for me to look for a solution

@dsebastien
Copy link
Author

Gaaaahhh my bad!

I was trying to understand why it was working with a fresh Angular CLI project. The fact is that in my project I'm using Storybook and forgot to add the module import in the story's test module (oh my...).

And it was the same stupid mistake I did in ngcc-validation. I added the import in app.module.ts, but not in the TestBed dummy module...

Anyways, sorry for the waste of time ❌

@urish
Copy link
Owner

urish commented Mar 27, 2020

Thank you for documenting your findings. I'm sure this will save time to some other folks in the future :)

@dsebastien
Copy link
Author

Let's hope so.. haha ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants