-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Conversation
β Deploy Preview for nuxt3-docs canceled.
|
|
||
/** vite glob import utility - https://vitejs.dev/guide/features.html#glob-import */ | ||
globEager?(pattern: string, options?: ViteGlobOptions): Record<string, Record<string, any>> | ||
glob (glob: string | string[], options?: ViteGlobOptions): Record<string, () => Promise<Record<string, any>>> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tricky. This is meant to be optional as the declaration is also present in webpack builder.
It might be worth reconsidering whether we add these types within vite-builder
rather than schema, so it can be more precisely targeted to both the vite version and the builder that is being used. wdyt @pi0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea of moving types but that also makes a tricky question of how we tie vite versions to Nuxt releases (it uses caret). As you also mentioned, reason to have types here was that they are shared between different bundlers. I think we can revise this refactor later but you are right about being optional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
glob (glob: string | string[], options?: ViteGlobOptions): Record<string, () => Promise<Record<string, any>>> | |
glob?(glob: string | string[], options?: ViteGlobOptions): Record<string, () => Promise<Record<string, any>>> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@brownsugar seemed to say that optional chaining would break the usage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It really seems a bug in vite to me with static replacement (import.meta by spec is an object while static replacement is not covering another valid syntax of optional chaining...)
Okay then let's keep it non optional until issue is fixed by either a refactor or upstream. Webpack is not that important for being optional (we might even polyfill import.meta.glob
for webpack)
π Linked issue
β Type of change
π Description
globEager
is deprecatedglob
will always exists inimport.meta
, I think there is no need to set it as an optional field here?If we try to use optional chain in the code, it will break this feature in Vite 3:
π Checklist