imgix / angular

A library for integrating imgix into Angular applications
BSD 2-Clause "Simplified" License
4 stars 3 forks source link

ERROR Cannot find module 'imgix-url-params/dist/parameters.json' #140

Open EmanH opened 4 years ago

EmanH commented 4 years ago

Can't build my angular project with this module.

ERROR in node_modules/@imgix/angular/lib/types.d.ts:1:32 - error TS2732: Cannot find module 'imgix-url-params/dist/parameters.json'. Consider using '--resolveJsonModule' to import module with '.json' extension

1 import imgixUrlParameters from 'imgix-url-params/dist/parameters.json';
frederickfogerty commented 4 years ago

Hey @EmanH, thanks (again) for opening this issue and the associated PR. As I discussed over in the PR, I think this is a valid bug so will think about a way to fix it. Let me know if you have any other ideas.

At the moment I think the best resolution is biting the bullet and exporting a TS definition from our imgix-url-params pacakge. In the short term, I think we might just have to set the type to a more generic type like { [k: string]: string | number }.

As a workaround for now until we fix this, is it possible for you to enable --resolveJsonModule in your tsconfig? This won't have any effect on the compiled code, since it's just for type checking.

By the way, in the future, could you please help us out by opening issues according to one of the issue templates? It really helps us!

EmanH commented 4 years ago

Thanks Frederick, I added resolveJsonModule into the tsconfig compiler options for the angular project, but it had no effect. Obviously didn't put it in the right place or right tsconfig file. Any tips on doing that in Angular?

EmanH commented 4 years ago

I got resolveJsonModule working in the end. No problem.

frederickfogerty commented 3 years ago

Hey @EmanH - glad you could get this working! We'll leave this open as we want to make it unnecessary to change your Typescript config to use this plugin.

jeremiahmark commented 2 years ago

Hey, I'm trying to use the library and getting the same issue how was this resolved in the past?

Cdrew92 commented 2 years ago

Angular 13.3.0 checking in. In addition to resolveJsonModule I had to set "allowSyntheticDefaultImports: true" in tsconfig to import ImgixAngularModule into my App Module