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

fix: issue where c type is any #8870

Conversation

vinayakkulkarni
Copy link

@vinayakkulkarni vinayakkulkarni commented Jul 28, 2023

While running nuxt app, I was getting the error c.toUpperCase is not a function, after digging in the vite builds, found out that these functions classify & camelize are the root cause.

  • This PR fixes the issue (we have c which is of type any & toUpperString() only works on String prototype.

Issue Repro –

  1. Clone – https://github.com/geoql/expenses
  2. npm ci
  3. npm run dev
Screenshot 2023-07-29 at 12 56 51 AM

For context, Nuxi info

------------------------------
- Operating System: Darwin
- Node Version:     v20.4.0
- Nuxt Version:     3.6.5
- Nitro Version:    2.5.2
- Package Manager:  [email protected]
- Builder:          vite
- User Config:      app, components, css, devtools, experimental, vue, ssr, modules, nitro, plugins, routeRules, runtimeConfig, typescript
- Runtime Modules:  @pinia/[email protected], @vueuse/[email protected], @nuxtjs/[email protected], @unocss/[email protected]
- Build Modules:    -
------------------------------

@github-actions
Copy link

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 85.8 kB (-60 B) 32.6 kB (-40 B) 29.4 kB (-35 B)
vue.global.prod.js 132 kB (-60 B) 49.3 kB (-14 B) 44.3 kB (-9 B)

Usages

Name Size Gzip Brotli
createApp 47.8 kB (-121 B) 18.9 kB (+8 B) 17.2 kB (+7 B)
createSSRApp 50.5 kB (-121 B) 19.9 kB (-4 B) 18.2 kB (-3 B)
defineCustomElement 50.1 kB (-121 B) 19.6 kB (-10 B) 17.9 kB (+5 B)
overall 61.1 kB (-100 B) 23.7 kB 21.6 kB (-3 B)

@vinayakkulkarni vinayakkulkarni force-pushed the fix/issue-with-component-names-in-SFCs branch from bddc128 to 55cafec Compare September 1, 2023 01:00
@skirtles-code
Copy link
Contributor

I'm not sure I understand the use case here. Is there a legitimate reason for these functions to accept values that aren't strings? Isn't calling toString() just hiding the problem rather than fixing it? Perhaps it would be better to add a warning somewhere further up the callstack to report the original mistake that led to these values not being strings in the first place?

@schelmo
Copy link

schelmo commented Oct 9, 2023

seems like the same unocss bug like here:
unocss/unocss#3206

@mklueh
Copy link

mklueh commented Nov 20, 2023

I ran into the same problem, more details here:

nuxt/nuxt#23937 (comment)

In my case, it was caused by the kebab case component property convention, which seems to not work anymore.

This does not work anymore / produces the hydration failures

      <PostItem :class="{'shadow-lg hover:-translate-y-1': useGridView}"
                v-for="post in posts"
                :key="post.id"
                :post="post"
                :show-border="!useGridView" />

while this works

      <PostItem :class="{'shadow-lg hover:-translate-y-1': useGridView}"
                v-for="post in posts"
                :key="post.id"
                :post="post"
                :showBorder="!useGridView" />

Not sure what causes this and I assume not everybody is facing this issue, as this would probably go viral.

@sodatea sodatea added the need more info Further information is requested label Mar 28, 2024
@skirtles-code
Copy link
Contributor

Based on the UnoCSS bug report linked above, I think this PR should be closed.

UnoCSS is rewriting some of the code in Vue. The original code contains this line:

const camelizeRE = /-(\w)/g

By the time it gets to the browser, it has been changed to this:

var camelizeRE = /-\w/g;

The parentheses have been removed, leading to the replace callback being passed the wrong arguments.

I've checked this myself and confirmed that this is what's happening in the original reproduction. I haven't dug in to confirm that UnoCSS is the root cause, but something is rewriting that RegExp, so there's nothing that needs to be done in Vue to fix it.

@vinayakkulkarni vinayakkulkarni deleted the fix/issue-with-component-names-in-SFCs branch April 20, 2024 04:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need more info Further information is requested
Projects
Status: Rejected
Development

Successfully merging this pull request may close these issues.

None yet

5 participants