Skip to content

fix ipx provider options - #976

Closed
aaharu wants to merge 10 commits into
nuxt:mainfrom
aaharu:ipx-providers-options
Closed

fix ipx provider options#976
aaharu wants to merge 10 commits into
nuxt:mainfrom
aaharu:ipx-providers-options

Conversation

@aaharu

@aaharu aaharu commented Sep 11, 2023

Copy link
Copy Markdown
Contributor

https://image.nuxt.com/get-started/configuration#modifiers

According to the document, setting to default modifiers should be possible, but it wasn't working in typescript, so I fixed it.

@danielroe danielroe added the bug Something isn't working label Sep 13, 2023
@codecov-commenter

codecov-commenter commented Sep 13, 2023

Copy link
Copy Markdown

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (a578636) 89.63% compared to head (51cd14e) 89.73%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #976      +/-   ##
==========================================
+ Coverage   89.63%   89.73%   +0.09%     
==========================================
  Files          44       44              
  Lines        2924     2971      +47     
  Branches      329      331       +2     
==========================================
+ Hits         2621     2666      +45     
- Misses        302      305       +3     
+ Partials        1        0       -1     
Files Coverage Δ
src/ipx.ts 95.77% <100.00%> (+0.12%) ⬆️
src/module.ts 91.32% <100.00%> (-0.29%) ⬇️
src/provider.ts 98.34% <100.00%> (+0.82%) ⬆️
src/runtime/providers/ipx.ts 100.00% <100.00%> (ø)
src/types/module.ts 100.00% <100.00%> (ø)
src/runtime/image.ts 86.08% <50.00%> (-0.59%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment thread src/ipx.ts Outdated
maxAge: providerOptions.options?.maxAge || moduleOptions.ipx?.maxAge,
domains: moduleOptions.domains || moduleOptions.ipx?.domains,
sharp: moduleOptions.sharp || moduleOptions.ipx?.sharp,
alias: moduleOptions.alias || moduleOptions.ipx?.alias

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New options are updated for ipx v2 interface (https://github.com/nuxt/image/blob/main/src/ipx.ts#L32)

We probably don't need this anymore (but we can also spread entire moduleOptions.ipx (typed as new IPXRuntimeConfig)

Comment thread src/types/module.ts Outdated
strapi?: any
imageengine?: any
uploadcare?: Partial<UploadcareOptions>
ipx?: Partial<StaticOptions>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be IPXOptions i guess?

Comment thread src/types/module.ts
Comment thread src/module.ts
resolvedProvider,
BuiltInProviders.includes(resolvedProvider)
? { provider: resolvedProvider, options: options[resolvedProvider] }
: options[resolvedProvider]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this change necessary? (I think it would be nice to keep this arg unified with { options } interface always.)

@aaharu aaharu Oct 16, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's necessary.
The resolveProviders that take ModuleOptions as arguments also do this processing, so they need to do the same for ModuleOptions in the nitro:init hook.
https://github.com/nuxt/image/blob/v1.0.0-rc.3/src/provider.ts#L67-L71

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering this logic running within if (!options.provider || options.provider === 'ipx' || options.provider === 'ipxStatic'), possible values for resolvedProvider are ipx, ipxStatic and none, all are built-in so i think this line would not also reach...

@pi0 pi0 mentioned this pull request Oct 19, 2023
@pi0

pi0 commented Oct 19, 2023

Copy link
Copy Markdown
Member

Hi. I have merged in a slightly different fix via #1056 for options handling (sorry since was in rush for 1.0.0 release).

Would be nice if we can repurpose this changes to modifiers type+fix. (And thanks for all your helps on both nuxt image and IPX all the time ❤️ )

@aaharu

aaharu commented Nov 29, 2023

Copy link
Copy Markdown
Contributor Author

Thank you for reviewing! And sorry for the delay in getting back.

This PR makes some conflicts, so I remade it following.
#1132

@aaharu aaharu closed this Nov 29, 2023
@aaharu
aaharu deleted the ipx-providers-options branch November 29, 2023 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants